@silexlabs/silex 3.0.0-alpha.39 → 3.0.0-alpha.41

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 (110) hide show
  1. package/.silex.js +38 -8
  2. package/dist/client/client/config.d.ts +11 -41
  3. package/dist/client/client/grapesjs/LoginDialog.d.ts +13 -0
  4. package/dist/client/client/grapesjs/PublicationManager.d.ts +69 -0
  5. package/dist/client/client/grapesjs/PublicationUi.d.ts +58 -0
  6. package/dist/client/client/grapesjs/index.d.ts +18 -44
  7. package/dist/client/client/grapesjs/storage.d.ts +1 -0
  8. package/dist/client/client/services.d.ts +35 -0
  9. package/dist/client/constants.d.ts +17 -0
  10. package/dist/client/css/admin.css +86 -3
  11. package/dist/client/js/main.js +201 -90
  12. package/dist/client/js/main.js.LICENSE.txt +6 -0
  13. package/dist/client/types.d.ts +200 -29
  14. package/dist/constants.d.ts +21 -0
  15. package/dist/constants.js +38 -1
  16. package/dist/constants.js.map +1 -0
  17. package/dist/events.d.ts +2 -0
  18. package/dist/events.js +17 -0
  19. package/dist/events.js.map +1 -0
  20. package/dist/plugins/AuthPlugin.d.ts +1 -0
  21. package/dist/plugins/AuthPlugin.js +38 -0
  22. package/dist/plugins/AuthPlugin.js.map +1 -0
  23. package/dist/plugins/Cache.d.ts +2 -0
  24. package/dist/plugins/Cache.js +32 -0
  25. package/dist/plugins/Cache.js.map +1 -0
  26. package/dist/plugins/FtpBackend.d.ts +92 -0
  27. package/dist/plugins/FtpBackend.js +604 -0
  28. package/dist/plugins/FtpBackend.js.map +1 -0
  29. package/dist/plugins/HooksPlugin.d.ts +7 -0
  30. package/dist/plugins/HooksPlugin.js +76 -0
  31. package/dist/plugins/HooksPlugin.js.map +1 -0
  32. package/dist/plugins/PublicationPlugin.d.ts +17 -0
  33. package/dist/plugins/PublicationPlugin.js +170 -0
  34. package/dist/plugins/PublicationPlugin.js.map +1 -0
  35. package/dist/plugins/SslPlugin.d.ts +1 -0
  36. package/dist/plugins/SslPlugin.js +86 -0
  37. package/dist/plugins/SslPlugin.js.map +1 -0
  38. package/dist/plugins/StaticPlugin.d.ts +1 -0
  39. package/dist/plugins/StaticPlugin.js +66 -0
  40. package/dist/plugins/StaticPlugin.js.map +1 -0
  41. package/dist/plugins/WebsitePlugin.d.ts +14 -0
  42. package/dist/plugins/WebsitePlugin.js +302 -0
  43. package/dist/plugins/WebsitePlugin.js.map +1 -0
  44. package/dist/server/backends/FsBackend.d.ts +42 -0
  45. package/dist/server/backends/FsBackend.js +269 -0
  46. package/dist/server/backends/FsBackend.js.map +1 -0
  47. package/dist/server/backends/index.d.ts +95 -0
  48. package/dist/server/backends/index.js +255 -0
  49. package/dist/server/backends/index.js.map +1 -0
  50. package/dist/server/cli.js +0 -1
  51. package/dist/server/config.d.ts +58 -0
  52. package/dist/server/config.js +128 -24
  53. package/dist/server/config.js.map +1 -0
  54. package/dist/server/express.js +31 -3
  55. package/dist/server/index.js +9 -20
  56. package/dist/server/jobs.d.ts +6 -0
  57. package/dist/server/jobs.js +75 -0
  58. package/dist/server/jobs.js.map +1 -0
  59. package/dist/server/utils/validation.d.ts +7 -0
  60. package/dist/server/utils/validation.js +37 -0
  61. package/dist/server/utils/validation.js.map +1 -0
  62. package/dist/types.d.ts +270 -0
  63. package/dist/types.js +35 -28
  64. package/dist/types.js.map +1 -0
  65. package/package.json +19 -8
  66. package/public/silex.js +17 -0
  67. package/src/css/dialog.scss +9 -2
  68. package/src/css/grapesjs.scss +79 -0
  69. package/src/css/project-bar.scss +2 -2
  70. package/src/example-client-config.js +17 -0
  71. package/src/html/templates/includes.pug +0 -1
  72. package/src/ts/client/config.ts +7 -6
  73. package/src/ts/client/grapesjs/LoginDialog.ts +190 -0
  74. package/src/ts/client/grapesjs/PublicationManager.ts +333 -0
  75. package/src/ts/client/grapesjs/PublicationUi.ts +320 -0
  76. package/src/ts/client/grapesjs/index.ts +88 -85
  77. package/src/ts/client/grapesjs/storage.ts +110 -0
  78. package/src/ts/client/index.ts +5 -7
  79. package/src/ts/client/services.ts +129 -0
  80. package/src/ts/constants.ts +21 -0
  81. package/src/ts/plugins/AuthPlugin.ts +38 -0
  82. package/src/ts/plugins/Cache.ts +28 -0
  83. package/src/ts/plugins/FtpBackend.ts +689 -0
  84. package/src/ts/plugins/HooksPlugin.ts +79 -0
  85. package/src/ts/plugins/PublicationPlugin.ts +170 -0
  86. package/src/{plugins/SslPlugin.js → ts/plugins/SslPlugin.ts} +24 -6
  87. package/src/ts/plugins/StaticPlugin.ts +68 -0
  88. package/src/ts/plugins/WebsitePlugin.ts +318 -0
  89. package/src/ts/server/backends/FsBackend.ts +266 -0
  90. package/src/ts/server/backends/index.ts +309 -0
  91. package/src/ts/server/cli.ts +0 -2
  92. package/src/ts/server/config.ts +103 -33
  93. package/src/ts/server/express.ts +37 -3
  94. package/src/ts/server/index.ts +24 -14
  95. package/src/ts/server/jobs.test.ts +74 -0
  96. package/src/ts/server/jobs.ts +77 -0
  97. package/src/ts/server/utils/validation.ts +33 -0
  98. package/src/ts/types.ts +167 -59
  99. package/dist/client/client/grapesjs/publish.d.ts +0 -18
  100. package/dist/page.js +0 -15
  101. package/src/plugins/AuthPlugin.js +0 -21
  102. package/src/plugins/Cache.js +0 -11
  103. package/src/plugins/DefaultBackend.js +0 -149
  104. package/src/plugins/ExpressPlugin.js +0 -39
  105. package/src/plugins/HooksPlugin.js +0 -58
  106. package/src/plugins/PublishPlugin.js +0 -69
  107. package/src/plugins/StaticPlugin.js +0 -48
  108. package/src/plugins/WebsitePlugin.js +0 -207
  109. package/src/ts/client/grapesjs/publish.ts +0 -403
  110. /package/.silex/default/{.silex.data.json → website.json} +0 -0
@@ -11,6 +11,12 @@
11
11
 
12
12
  /*! @silexlabs/grapesjs-loading - 1.0.8 */
13
13
 
14
+ /**
15
+ * @license
16
+ * Copyright 2017 Google LLC
17
+ * SPDX-License-Identifier: BSD-3-Clause
18
+ */
19
+
14
20
  /**
15
21
  * @license
16
22
  * Copyright 2018 Google LLC
@@ -1,35 +1,9 @@
1
+ /// <reference types="node" />
1
2
  /**
2
3
  * @fileoverview define types for Silex client and server
3
4
  */
4
- export declare const defaultPublicationSettings: PublicationSettings;
5
- export declare const defaultSite: WebsiteData;
6
- export interface WebsiteSettings {
7
- description: string;
8
- title: string;
9
- lang: string;
10
- head: string;
11
- favicon: string;
12
- 'og:title': string;
13
- 'og:description': string;
14
- 'og:image': string;
15
- }
16
- export interface WebsiteData {
17
- pages: Page[];
18
- assets: Asset[];
19
- styles: Style[];
20
- name: string;
21
- settings: WebsiteSettings;
22
- fonts: Font[];
23
- symbols: symbol[];
24
- publication: PublicationSettings;
25
- }
26
- export interface Font {
27
- name: string;
28
- value: string;
29
- variants: string[];
30
- }
31
5
  export interface PublicationSettings {
32
- path?: string;
6
+ backend?: BackendData;
33
7
  url?: string;
34
8
  autoHomePage?: boolean;
35
9
  assets?: {
@@ -46,12 +20,118 @@ export interface PublicationSettings {
46
20
  ext?: string;
47
21
  };
48
22
  }
49
- export interface File {
23
+ export interface WebsiteFile {
50
24
  html: string;
51
25
  css: string;
52
26
  htmlPath: string;
53
27
  cssPath: string;
54
28
  }
29
+ export type ApiResponseError = {
30
+ message: string;
31
+ };
32
+ export type ApiPublicationPublishRequestBody = WebsiteData;
33
+ export type ApiPublicationPublishRequestQuery = {
34
+ id: WebsiteId;
35
+ };
36
+ export type ApiPublicationPublishResponse = {
37
+ url: string;
38
+ job: PublicationJobData;
39
+ };
40
+ export type ApiPublicationStatusRequestQuery = {
41
+ jobId: JobId;
42
+ };
43
+ export type ApiPublicationStatusResponse = PublicationJobData;
44
+ export type ApiWebsiteReadRequestQuery = {
45
+ id?: WebsiteId;
46
+ backendId?: BackendId;
47
+ };
48
+ export type ApiWebsiteReadResponse = WebsiteMeta[] | WebsiteData;
49
+ export type ApiWebsiteWriteRequestQuery = {
50
+ id: WebsiteId;
51
+ backendId?: BackendId;
52
+ };
53
+ export type ApiWebsiteWriteRequestBody = WebsiteData;
54
+ export type ApiWebsiteWriteResponse = {
55
+ message: string;
56
+ };
57
+ export type ApiWebsiteDeleteRequestQuery = {
58
+ id: WebsiteId;
59
+ backendId?: BackendId;
60
+ };
61
+ export type ApiWebsiteAssetsReadRequestQuery = {
62
+ id: WebsiteId;
63
+ backendId?: BackendId;
64
+ };
65
+ export type ApiWebsiteAssetsReadRequestParams = {
66
+ path: string;
67
+ };
68
+ export type ApiWebsiteAssetsReadResponse = string;
69
+ export type ApiWebsiteAssetsWriteRequestQuery = {
70
+ id: WebsiteId;
71
+ backendId?: BackendId;
72
+ };
73
+ export type ApiWebsiteAssetsWriteRequestBody = ClientSideFile[];
74
+ export type ApiWebsiteAssetsWriteResponse = {
75
+ data: string[];
76
+ };
77
+ export type ApiBackendListRequestQuery = {
78
+ type: BackendType;
79
+ };
80
+ export type ApiBackendListResponse = BackendData[];
81
+ export type ApiBackendLoginRequestQuery = {
82
+ backendId: BackendId;
83
+ type: BackendType;
84
+ options?: string;
85
+ error?: string;
86
+ };
87
+ export type ApiBackendLoggedInPostMessage = {
88
+ type: string;
89
+ error: boolean;
90
+ message: string;
91
+ backendId: BackendId;
92
+ };
93
+ export type ApiBackendLogoutRequestQuery = {
94
+ backendId: BackendId;
95
+ type: BackendType;
96
+ };
97
+ export type ApiBackendLoginStatusRequestQuery = {
98
+ id?: WebsiteId;
99
+ backendId?: BackendId;
100
+ type: BackendType;
101
+ };
102
+ export type ApiBackendLoginStatusResponse = {
103
+ user: BackendUser;
104
+ backend: BackendData;
105
+ websiteMeta?: WebsiteMeta;
106
+ };
107
+ export interface WebsiteData {
108
+ pages: Page[];
109
+ assets: Asset[];
110
+ styles: Style[];
111
+ name: string;
112
+ settings: WebsiteSettings;
113
+ fonts: Font[];
114
+ symbols: symbol[];
115
+ publication: PublicationSettings;
116
+ }
117
+ export interface PublicationData extends WebsiteData {
118
+ files?: WebsiteFile[];
119
+ }
120
+ export interface WebsiteSettings {
121
+ description: string;
122
+ title: string;
123
+ lang: string;
124
+ head: string;
125
+ favicon: string;
126
+ 'og:title': string;
127
+ 'og:description': string;
128
+ 'og:image': string;
129
+ }
130
+ export interface Font {
131
+ name: string;
132
+ value: string;
133
+ variants: string[];
134
+ }
55
135
  export interface Page {
56
136
  name?: string;
57
137
  id: string;
@@ -97,3 +177,94 @@ export type Selector = string | {
97
177
  name: string;
98
178
  type: number;
99
179
  };
180
+ /**
181
+ * Type for a backend id
182
+ */
183
+ export type BackendId = string;
184
+ /**
185
+ * Type for a client side file
186
+ * @see backend/File
187
+ */
188
+ export interface ClientSideFile {
189
+ path: string;
190
+ content: Buffer | string;
191
+ }
192
+ /**
193
+ * Type for file listing
194
+ */
195
+ export interface FileMeta {
196
+ name: string;
197
+ isDir: boolean;
198
+ size: number;
199
+ createdAt: Date;
200
+ updatedAt: Date;
201
+ metadata?: object;
202
+ }
203
+ /**
204
+ * Enum to express if the backend is a storage or a hosting
205
+ */
206
+ export declare enum BackendType {
207
+ STORAGE = "STORAGE",
208
+ HOSTING = "HOSTING"
209
+ }
210
+ /**
211
+ * Type for a website id
212
+ */
213
+ export type WebsiteId = string;
214
+ /**
215
+ * Back end data sent to the front end
216
+ */
217
+ export interface BackendData {
218
+ backendId: BackendId;
219
+ type: BackendType;
220
+ displayName: string;
221
+ icon: string;
222
+ disableLogout: boolean;
223
+ isLoggedIn: boolean;
224
+ authUrl: string | null;
225
+ }
226
+ /**
227
+ * Back end data sent to the front end
228
+ */
229
+ export interface BackendUser {
230
+ name: string;
231
+ email?: string;
232
+ picture?: string;
233
+ metadata?: object;
234
+ }
235
+ /**
236
+ * Back end data sent to the front end
237
+ * Meta data can be the root path of the websites, or the bucket name, etc.
238
+ */
239
+ export interface WebsiteMeta {
240
+ websiteId: WebsiteId;
241
+ createdAt: Date;
242
+ updatedAt: Date;
243
+ metadata?: object;
244
+ }
245
+ /**
246
+ * Enum to express if the job is in progress or finished or errored
247
+ */
248
+ export declare enum JobStatus {
249
+ IN_PROGRESS = "IN_PROGRESS",
250
+ SUCCESS = "SUCCESS",
251
+ ERROR = "ERROR"
252
+ }
253
+ /**
254
+ * Id used to track the progress of a publication
255
+ */
256
+ export type JobId = string;
257
+ /**
258
+ * Data structure which is sent to the client to display the progress of a job
259
+ */
260
+ export interface JobData {
261
+ jobId: JobId;
262
+ status: JobStatus;
263
+ message: string;
264
+ url?: string;
265
+ _timeout?: ReturnType<typeof setTimeout>;
266
+ }
267
+ export interface PublicationJobData extends JobData {
268
+ logs: string[][];
269
+ errors: string[][];
270
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview define constants for Silex client and server
3
+ */
4
+ export declare const WEBSITE_DATA_FILE_NAME = "website.json";
5
+ export declare const DEFAULT_WEBSITE_ID = "default";
6
+ export declare const DEFAULT_BACKEND_ID = "";
7
+ export declare const DEFAULT_LANGUAGE = "en";
8
+ export declare const CLIENT_CONFIG_FILE_NAME = "silex.js";
9
+ export declare const API_BACKEND_LOGIN_STATUS = "api/backend/login/status/";
10
+ export declare const API_BACKEND_LIST = "api/backend/";
11
+ export declare const API_BACKEND_LOGOUT = "api/backend/logout/";
12
+ export declare const API_BACKEND_LOGIN = "api/backend/login/";
13
+ export declare const API_BACKEND_LOGIN_CALLBACK = "api/backend/login/";
14
+ export declare const API_PUBLICATION_PUBLISH = "api/publication/";
15
+ export declare const API_PUBLICATION_STATUS = "/api/publication/status/";
16
+ export declare const API_WEBSITE_READ = "api/website/";
17
+ export declare const API_WEBSITE_WRITE = "api/website/";
18
+ export declare const API_WEBSITE_DELETE = "api/website/";
19
+ export declare const API_WEBSITE_LIST = "api/website/";
20
+ export declare const API_WEBSITE_ASSETS_READ = "assets/:path";
21
+ export declare const API_WEBSITE_ASSETS_WRITE = "assets/";
package/dist/constants.js CHANGED
@@ -1,4 +1,41 @@
1
1
  "use strict";
2
+ /*
3
+ * Silex website builder, free/libre no-code tool for makers.
4
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLIENT_CONFIG_FILE_NAME = void 0;
19
+ exports.API_WEBSITE_ASSETS_WRITE = exports.API_WEBSITE_ASSETS_READ = exports.API_WEBSITE_LIST = exports.API_WEBSITE_DELETE = exports.API_WEBSITE_WRITE = exports.API_WEBSITE_READ = exports.API_PUBLICATION_STATUS = exports.API_PUBLICATION_PUBLISH = exports.API_BACKEND_LOGIN_CALLBACK = exports.API_BACKEND_LOGIN = exports.API_BACKEND_LOGOUT = exports.API_BACKEND_LIST = exports.API_BACKEND_LOGIN_STATUS = exports.CLIENT_CONFIG_FILE_NAME = exports.DEFAULT_LANGUAGE = exports.DEFAULT_BACKEND_ID = exports.DEFAULT_WEBSITE_ID = exports.WEBSITE_DATA_FILE_NAME = void 0;
20
+ /**
21
+ * @fileoverview define constants for Silex client and server
22
+ */
23
+ exports.WEBSITE_DATA_FILE_NAME = 'website.json';
24
+ exports.DEFAULT_WEBSITE_ID = 'default';
25
+ exports.DEFAULT_BACKEND_ID = '';
26
+ exports.DEFAULT_LANGUAGE = 'en';
4
27
  exports.CLIENT_CONFIG_FILE_NAME = 'silex.js';
28
+ exports.API_BACKEND_LOGIN_STATUS = 'api/backend/login/status/';
29
+ exports.API_BACKEND_LIST = 'api/backend/';
30
+ exports.API_BACKEND_LOGOUT = 'api/backend/logout/';
31
+ exports.API_BACKEND_LOGIN = 'api/backend/login/';
32
+ exports.API_BACKEND_LOGIN_CALLBACK = 'api/backend/login/';
33
+ exports.API_PUBLICATION_PUBLISH = 'api/publication/';
34
+ exports.API_PUBLICATION_STATUS = '/api/publication/status/';
35
+ exports.API_WEBSITE_READ = 'api/website/';
36
+ exports.API_WEBSITE_WRITE = 'api/website/';
37
+ exports.API_WEBSITE_DELETE = 'api/website/';
38
+ exports.API_WEBSITE_LIST = 'api/website/';
39
+ exports.API_WEBSITE_ASSETS_READ = 'assets/:path';
40
+ exports.API_WEBSITE_ASSETS_WRITE = 'assets/';
41
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/ts/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;GAEG;AAEU,QAAA,sBAAsB,GAAG,cAAc,CAAA;AAEvC,QAAA,kBAAkB,GAAG,SAAS,CAAA;AAC9B,QAAA,kBAAkB,GAAG,EAAE,CAAA;AACvB,QAAA,gBAAgB,GAAG,IAAI,CAAA;AACvB,QAAA,uBAAuB,GAAG,UAAU,CAAA;AAEpC,QAAA,wBAAwB,GAAG,2BAA2B,CAAA;AACtD,QAAA,gBAAgB,GAAG,cAAc,CAAA;AACjC,QAAA,kBAAkB,GAAG,qBAAqB,CAAA;AAC1C,QAAA,iBAAiB,GAAG,oBAAoB,CAAA;AACxC,QAAA,0BAA0B,GAAG,oBAAoB,CAAA;AAEjD,QAAA,uBAAuB,GAAG,kBAAkB,CAAA;AAC5C,QAAA,sBAAsB,GAAG,0BAA0B,CAAA;AAEnD,QAAA,gBAAgB,GAAG,cAAc,CAAA;AACjC,QAAA,iBAAiB,GAAG,cAAc,CAAA;AAClC,QAAA,kBAAkB,GAAG,cAAc,CAAA;AACnC,QAAA,gBAAgB,GAAG,cAAc,CAAA;AACjC,QAAA,uBAAuB,GAAG,cAAc,CAAA;AACxC,QAAA,wBAAwB,GAAG,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const EVENT_STARTUP_START = "silex:startup:start";
2
+ export declare const EVENT_STARTUP_END = "silex:startup:end";
package/dist/events.js CHANGED
@@ -1,5 +1,22 @@
1
1
  "use strict";
2
+ /*
3
+ * Silex website builder, free/libre no-code tool for makers.
4
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.EVENT_STARTUP_END = exports.EVENT_STARTUP_START = void 0;
4
20
  exports.EVENT_STARTUP_START = 'silex:startup:start';
5
21
  exports.EVENT_STARTUP_END = 'silex:startup:end';
22
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/ts/events.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEU,QAAA,mBAAmB,GAAG,qBAAqB,CAAA;AAC3C,QAAA,iBAAiB,GAAG,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export default function (config: any, opts?: {}): Promise<void>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*
3
+ * Silex website builder, free/libre no-code tool for makers.
4
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ async function default_1(config, opts = {}) {
20
+ // config.on('silex:startup:start', ({app}) => {
21
+ // const router = express.Router()
22
+ // router.post(['/publish', '/website', '/assets'], async function(req, res, next) {
23
+ // try {
24
+ // const token = req.body.token || opts.directusToken
25
+ // const directus = new Directus(opts.directusUrl)
26
+ // directus.storage.auth_token = token
27
+ // const me = await directus.users.me.read()
28
+ // next()
29
+ // } catch(err) {
30
+ // console.error('Publish failed in auth module. Did you provide a directus token?', err.message)
31
+ // res.status(403).json({ message: err.message })
32
+ // }
33
+ // })
34
+ // app.use(router)
35
+ // })
36
+ }
37
+ exports.default = default_1;
38
+ //# sourceMappingURL=AuthPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthPlugin.js","sourceRoot":"","sources":["../../src/ts/plugins/AuthPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAKY,KAAK,oBAAU,MAAM,EAAE,IAAI,GAAG,EAAE;IAC/C,iDAAiD;IACjD,qCAAqC;IACrC,uFAAuF;IACvF,aAAa;IACb,4DAA4D;IAC5D,yDAAyD;IACzD,6CAA6C;IAC7C,mDAAmD;IACnD,gBAAgB;IAChB,sBAAsB;IACtB,wGAAwG;IACxG,wDAAwD;IACxD,SAAS;IACT,QAAQ;IACR,qBAAqB;IACrB,MAAM;AACN,CAAC;AAjBD,4BAiBC"}
@@ -0,0 +1,2 @@
1
+ export declare function noCache(req: any, res: any, next: any): void;
2
+ export declare function withCache(req: any, res: any, next: any): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*
3
+ * Silex website builder, free/libre no-code tool for makers.
4
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.withCache = exports.noCache = void 0;
20
+ function noCache(req, res, next) {
21
+ res.header('Cache-Control', 'private,no-cache,no-store,must-revalidate,proxy-revalidate');
22
+ res.header('Expires', '-1');
23
+ res.header('Pragma', 'no-cache');
24
+ next();
25
+ }
26
+ exports.noCache = noCache;
27
+ function withCache(req, res, next) {
28
+ res.header('Cache-Control', 'public,max-age=86400,immutable'); // 24h
29
+ next();
30
+ }
31
+ exports.withCache = withCache;
32
+ //# sourceMappingURL=Cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/ts/plugins/Cache.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,SAAgB,OAAO,CAAE,GAAG,EAAE,GAAG,EAAE,IAAI;IACrC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,4DAA4D,CAAC,CAAA;IACzF,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IAC3B,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAChC,IAAI,EAAE,CAAA;AACR,CAAC;AALD,0BAKC;AAED,SAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;IACtC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,gCAAgC,CAAC,CAAA,CAAC,MAAM;IACpE,IAAI,EAAE,CAAA;AACR,CAAC;AAHD,8BAGC"}
@@ -0,0 +1,92 @@
1
+ import { File, HostingProvider, StatusCallback, StorageProvider } from '../server/backends';
2
+ import { BackendData, BackendType, BackendUser, WebsiteMeta, FileMeta, JobData, WebsiteId } from '../types';
3
+ import { ServerConfig } from '../server/config';
4
+ /**
5
+ * @fileoverview FTP backend for Silex
6
+ * This is a backend for Silex, which allows to store the website on a FTP server
7
+ * and to publish the website on a FTP server
8
+ * FIXME: As a hosting provider, this backend should only store the password in the session and the rest in the website data
9
+ * to prevent publishing a site on the wrong server + multiple sites on 1 server
10
+ * FIXME: Allow reuse of FTP session between calls
11
+ */
12
+ export interface FtpSessionData {
13
+ host: string;
14
+ user: string;
15
+ pass: string;
16
+ port: number;
17
+ secure: boolean;
18
+ storageRootPath?: string;
19
+ publicationPath?: string;
20
+ websiteUrl?: string;
21
+ }
22
+ export interface FtpSession {
23
+ [BackendType.STORAGE]?: FtpSessionData;
24
+ [BackendType.HOSTING]?: FtpSessionData;
25
+ }
26
+ interface FtpOptions {
27
+ type: BackendType;
28
+ rootPath?: string;
29
+ authorizeUrl?: string;
30
+ authorizePath?: string;
31
+ }
32
+ interface FtpOptionsWithDefaults {
33
+ type: BackendType;
34
+ rootPath: string;
35
+ authorizeUrl: string;
36
+ authorizePath: string;
37
+ }
38
+ /**
39
+ * @class FtpBackend
40
+ * @implements {HostingProvider}
41
+ * @implements {StorageProvider}
42
+ */
43
+ export default class FtpBackend implements HostingProvider<FtpSession>, StorageProvider<FtpSession> {
44
+ id: string;
45
+ displayName: string;
46
+ icon: string;
47
+ options: FtpOptionsWithDefaults;
48
+ type: BackendType;
49
+ constructor(config: ServerConfig, opts: FtpOptions);
50
+ sessionData(session: FtpSession): FtpSessionData;
51
+ storageRootPath(session: FtpSession): string;
52
+ checkAuth({ host, user, pass, port, secure }: {
53
+ host: any;
54
+ user: any;
55
+ pass: any;
56
+ port: any;
57
+ secure: any;
58
+ }): Promise<void>;
59
+ authorizeForm(session: FtpSession, query: {
60
+ error: string;
61
+ type: string;
62
+ }): Promise<string>;
63
+ getClient({ host, user, pass, port, secure }: {
64
+ host: any;
65
+ user: any;
66
+ pass: any;
67
+ port: any;
68
+ secure: any;
69
+ }): Promise<any>;
70
+ authorize(session: FtpSession, body: any): Promise<FtpSession>;
71
+ getUserData(session: FtpSession): Promise<BackendUser>;
72
+ getSiteMeta(session: FtpSession, id: WebsiteId): Promise<WebsiteMeta>;
73
+ isLoggedIn(session: FtpSession): Promise<boolean>;
74
+ getAuthorizeURL(session: FtpSession): Promise<string>;
75
+ logout(session: FtpSession): Promise<void>;
76
+ getAdminUrl(session: FtpSession, id: WebsiteId): Promise<any>;
77
+ /**
78
+ * Create necessary folders
79
+ * Assets and root folders
80
+ */
81
+ init(session: FtpSession, id: WebsiteId): Promise<void>;
82
+ readFile(session: FtpSession, id: string, path: string): Promise<File>;
83
+ writeFiles(session: any, id: WebsiteId, files: File[], statusCbk?: StatusCallback): Promise<string[]>;
84
+ deleteFiles(session: FtpSession, id: any, paths: any): Promise<void>;
85
+ listWebsites(session: FtpSession): Promise<WebsiteMeta[]>;
86
+ listDir(session: FtpSession, id: WebsiteId, path: string): Promise<FileMeta[]>;
87
+ createDir(session: FtpSession, id: WebsiteId, path: string): Promise<void>;
88
+ deleteDir(session: FtpSession, id: WebsiteId, path: string): Promise<void>;
89
+ getWebsiteUrl(session: FtpSession, id: WebsiteId): Promise<string>;
90
+ publish(session: FtpSession, id: string, backendData: BackendData, files: File[]): Promise<JobData>;
91
+ }
92
+ export {};