@saltcorn/server 0.7.2-beta.5 → 0.7.2-beta.8

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/app.js CHANGED
@@ -51,8 +51,12 @@ const i18n = new I18n({
51
51
  });
52
52
  // jwt config
53
53
  const jwt_secret = db.connectObj.jwt_secret;
54
+ const jwt_extractor = ExtractJwt.fromExtractors([
55
+ ExtractJwt.fromAuthHeaderWithScheme("jwt"),
56
+ ExtractJwt.fromUrlQueryParameter("jwt"),
57
+ ]);
54
58
  const jwtOpts = {
55
- jwtFromRequest: ExtractJwt.fromAuthHeaderWithScheme("jwt"),
59
+ jwtFromRequest: jwt_extractor,
56
60
  secretOrKey: jwt_secret,
57
61
  issuer: "saltcorn@saltcorn",
58
62
  audience: "saltcorn-mobile-app",
@@ -114,11 +118,7 @@ const getApp = async (opts = {}) => {
114
118
  app.use(passport.initialize());
115
119
  app.use(passport.authenticate(["jwt", "session"]));
116
120
  app.use((req, res, next) => {
117
- if (
118
- ExtractJwt.fromAuthHeaderWithScheme("jwt")(req) &&
119
- req.cookies &&
120
- req.cookies["connect.sid"]
121
- )
121
+ if (jwt_extractor(req) && req.cookies && req.cookies["connect.sid"])
122
122
  throw new Error(
123
123
  "Don't set a session cookie and JSON Web Token at the same time."
124
124
  );
@@ -267,7 +267,7 @@ const getApp = async (opts = {}) => {
267
267
  if (
268
268
  req.url.startsWith("/api/") ||
269
269
  req.url === "/auth/login-with/jwt" ||
270
- ExtractJwt.fromAuthHeaderWithScheme("jwt")(req)
270
+ jwt_extractor(req)
271
271
  )
272
272
  return disabledCsurf(req, res, next);
273
273
  csurf(req, res, next);
package/load_plugins.js CHANGED
@@ -77,9 +77,8 @@ const loadPlugin = async (plugin, force) => {
77
77
  };
78
78
 
79
79
  /**
80
- *
80
+ * Git pull or clone
81
81
  * @param plugin
82
- * @param force
83
82
  */
84
83
  const gitPullOrClone = async (plugin) => {
85
84
  await fs.promises.mkdir("git_plugins", { recursive: true });
@@ -106,9 +105,16 @@ const gitPullOrClone = async (plugin) => {
106
105
  if (plugin.deploy_private_key) await fs.promises.unlink(keyfnm);
107
106
  return dir;
108
107
  };
109
-
108
+ /**
109
+ * Install plugin
110
+ * @param plugin - plugin name
111
+ * @param force - force flag
112
+ * @param manager - plugin manager
113
+ * @returns {Promise<{plugin_module: *}|{plugin_module: any}>}
114
+ */
110
115
  const requirePlugin = async (plugin, force, manager = defaultManager) => {
111
116
  const installed_plugins = (await manager.list()).map((p) => p.name);
117
+ // todo as idea is to make list of mandatory plugins configurable
112
118
  if (
113
119
  ["@saltcorn/base-plugin", "@saltcorn/sbadmin2"].includes(plugin.location)
114
120
  ) {
@@ -164,6 +170,7 @@ const loadAllPlugins = async () => {
164
170
  * Load Plugin and its dependencies and save into local installation
165
171
  * @param plugin
166
172
  * @param force
173
+ * @param noSignalOrDB
167
174
  * @returns {Promise<void>}
168
175
  */
169
176
  const loadAndSaveNewPlugin = async (plugin, force, noSignalOrDB) => {
package/locales/en.json CHANGED
@@ -892,5 +892,16 @@
892
892
  "Strings": "Strings",
893
893
  "In default language": "In default language",
894
894
  "In %s": "In %s",
895
- "Enable TWA": "Enable TWA"
896
- }
895
+ "Enable TWA": "Enable TWA",
896
+ "Or enter this code:": "Or enter this code:",
897
+ "Disable TWA": "Disable TWA",
898
+ "Cascade delete to file": "Cascade delete to file",
899
+ "Deleting a row will also delete the file referenced by this field": "Deleting a row will also delete the file referenced by this field",
900
+ "Has channels?": "Has channels?",
901
+ "Channels to create events for. Separate by comma; leave blank for all": "Channels to create events for. Separate by comma; leave blank for all",
902
+ "Event Name": "Event Name",
903
+ "Plugins (Extensions) Store endpoint": "Plugins (Extensions) Store endpoint",
904
+ "Packs Store endpoint": "Packs Store endpoint",
905
+ "The endpoint of plugins store.": "The endpoint of plugins store.",
906
+ "The endpoint of packs store.": "The endpoint of packs store."
907
+ }
package/locales/it.json CHANGED
@@ -477,5 +477,6 @@
477
477
  "SSL": "SSL",
478
478
  "Generate": "Generate",
479
479
  "Two-factor authentication": "Two-factor authentication",
480
- "Two-factor authentication is disabled": "Two-factor authentication is disabled"
480
+ "Two-factor authentication is disabled": "Two-factor authentication is disabled",
481
+ "Enable TWA": "Enable TWA"
481
482
  }
package/locales/ru.json CHANGED
@@ -125,7 +125,7 @@
125
125
  "Install pack": "Установить пакет",
126
126
  "Instead of building, get up and running in no time with packs": "Вместо создания приложения с нуля руками, просто выберите подходящие пакеты, установите их и пользуйтесь созданным приложением.",
127
127
  "Packs are collections of tables, views and plugins that give you a full application which you can then edit to suit your needs.": "Пакеты - это коллекции таблиц, представлений и плагинов, поставляемые в виде готового приложения, которое вы затем можете редактировать в соответствии со своими потребностями.",
128
- "Name": "Название",
128
+ "Name": "Наименование",
129
129
  "Description": "Описание",
130
130
  "Go to pack store »": "Перейти в менеджер пакетов »",
131
131
  "Learn": "Изучайте",
@@ -456,7 +456,7 @@
456
456
  "Show on page": "Показать на странице",
457
457
  "Requests to render this view directly will instead show the chosen page, if any. The chosewn page should embed this view. Use this to decorate the view with additional elements.": "Запросы на рендеринг этого представления напрямую будут отображать выбранную страницу, если таковая имеется. Выбранная страница должна включать это представление. Используйте это, чтобы декорировать представление дополнительными элементами.",
458
458
  "Variable name": "Имя переменной",
459
- "Constraints": "Констрейнты",
459
+ "Constraints": "Ограничения",
460
460
  "Recalculate stored fields": "Перевычислить хранимые поля",
461
461
  "Delete all rows": "Удалить все строки",
462
462
  "Access Read/Write": "Доступ на Чтение/Запись",
@@ -651,10 +651,10 @@
651
651
  "Email sent to %s with no errors": "Email отправлен %s без ошибок",
652
652
  "Action %s run successfully with no console output": "Действие (триггер) %s выполнено успешно без вывода результатов в консоль",
653
653
  "Edit trigger %s": "Изменить триггер %s",
654
- "%s constraints": "%s констрейнт(ов)",
655
- "Add constraint": "Добавить констрейнт",
654
+ "%s constraints": "Ограничения для таблицы %s",
655
+ "Add constraint": "Добавить ограничение",
656
656
  "Tick the boxes for the fields that should be jointly unique": "Установите флажки для полей, которые должны быть совместно уникальными",
657
- "Add constraint to %s": "Добавить констрейнт к %s",
657
+ "Add constraint to %s": "Добавить ограничение к %s",
658
658
  "New table name": "Новое имя таблицы",
659
659
  "Rename table %s": "Переименовать таблицу %s",
660
660
  "Started recalculating stored fields": "Начался перерасчет вычисляемых полей",
@@ -684,12 +684,12 @@
684
684
  "Cookie duration (hours) when remember ticked": "Срок действия Cookie (в часах), когда установлен флажок \"Запомнить\"",
685
685
  "Order field": "Order (поле)",
686
686
  "Section field": "Section (поле))",
687
- "Optional. String type with options, each of which will become a menu section": "Указывать необязательно. Строковый тип с набором значений, каждая из которых станет секцией меню",
687
+ "Optional. String type with options, each of which will become a menu section": "Указывать необязательно. Строковый тип с набором значений, каждое из которых станет секцией меню",
688
688
  "Label formula": "Label (формула)",
689
689
  "URL formula": "URL (формула)",
690
690
  "Include formula": "Include (формула)",
691
- "If specified, only include in menu rows that evaluate to true": "Если указано, то в меню отображаются только секции (строки), для которых формула вычислилась со значением true",
692
- "Not all themes support all locations": "Некоторые темы могут не поддерживать все языки",
691
+ "If specified, only include in menu rows that evaluate to true": "Если флаг установлен, то в меню отображаются только те пункты меню (секции), для которых формула вычислилась со значением true",
692
+ "Not all themes support all locations": "Некоторые темы могут не поддерживать все варианты размещения виджета",
693
693
  "Library": "Библиотека",
694
694
  "Languages": "Языки",
695
695
  "Library: component assemblies that can be used in the builder": "Библиотека: компоненты для использования построителем интерфейсов",
@@ -700,7 +700,7 @@
700
700
  "Storage": "Хранилище",
701
701
  "Table or Channel": "Таблица или Канал",
702
702
  "Event types": "Типы событий",
703
- "Custom": "Custom",
703
+ "Custom": "Пользовательские события",
704
704
  "Log settings": "Настройки логов",
705
705
  "Event log": "Лог событий",
706
706
  "Custom Events": "Пользовательские События (Events)",
@@ -732,7 +732,7 @@
732
732
  "Ownership formula": "Owner (формула)",
733
733
  "User is treated as owner if true. In scope: ": "Ownership formula. Пользователь воспринимается как владелец, если значение формулы true. В рамках: ",
734
734
  "This is a translation of a different field in a different language": "Это трансляция перевода полей на разные языки",
735
- "Language locale of translation": "Language locale of translation",
735
+ "Language locale of translation": "Языковая локализация (locale) для перевода",
736
736
  "Slug": "Slug",
737
737
  "Field that can be used for a prettier URL structure": "Поле, которе используется для настройки структуры URL",
738
738
  "Column width": "Ширина столбца",
@@ -763,16 +763,16 @@
763
763
  "No errors detected during configuration check": "Не обнаружено ошибок при проверке конфигурации",
764
764
  "Extra state Formula": "Extra state Formula",
765
765
  "Place in dropdown": "Поместить в dropdown",
766
- "Hide null columns": "Скрыть стоблцы без значения (null)",
766
+ "Hide null columns": "Скрыть столбцы со значением null",
767
767
  "Do not display a column if it contains entirely missing values": "Скрыть (не отображать) стоблцы, имеющие значение null",
768
768
  "Finish": "Завершить",
769
769
  "Versions refreshed": "Версии обновлены",
770
770
  "Plugin name": "Имя плагина",
771
- "Source of plugin for install. Few options:npm - download from npm repository,local - get from local file system,github - download from github,git - get from git": "Source of plugin for install. Few options:npm - download from npm repository,local - get from local file system,github - download from github,git - get from git",
772
- "For npm - name of npm package, e.g. @saltcorn/html or saltcorn-gantt, check at npmjs.com, for local - absolute path to plugin folder in file system, e.g.C:\\gitsrc\\any-bootstrap-theme\\, for github - name of github project.": "For npm - name of npm package, e.g. @saltcorn/html or saltcorn-gantt, check at npmjs.com, for local - absolute path to plugin folder in file system, e.g.C:\\gitsrc\\any-bootstrap-theme\\, for github - name of github project.",
771
+ "Source of plugin for install. Few options:npm - download from npm repository,local - get from local file system,github - download from github,git - get from git": "Источник плагина:npm - загрузка из репозитория npm,local - из файловой системы сервера,github - загрузка github,git - загрузка из git",
772
+ "For npm - name of npm package, e.g. @saltcorn/html or saltcorn-gantt, check at npmjs.com, for local - absolute path to plugin folder in file system, e.g.C:\\gitsrc\\any-bootstrap-theme\\, for github - name of github project.": "Для npm пакета - наименование npm пакета, например, @saltcorn/html или saltcorn-gantt, точное название уточните на npmjs.com, при установки из локальной файловой системы сервера (local) - абсолютный путь к папке плагина в файловой системе, например, C:\\gitsrc\\any-bootstrap-theme\\, в случае github - название (name) проекта github.",
773
773
  "Version of plugin, latest is default value": "Версия плагина, значение по-умолчанию - latest",
774
774
  "Private SSH key": "Приватный ключ SSH",
775
- "Setup two-factor authentication": "Настройть двухфакторную аутентификацию",
775
+ "Setup two-factr authentication": "Настройть двухфакторную аутентификацию",
776
776
  "Setup two-factor authentication with Time-based One-Time Password (TOTP)": "Настроить двухфакторную аутентфикацию с применением Time-based One-Time Password (TOTP)",
777
777
  "1. Scan this QR code in your Authenticator app": "1. Отсканируйте данный QR код в удобном Вам приложении Аутентфикатор (Authenticator)",
778
778
  "2. Enter the six-digit code generated in your Authenticator app": "2. Введите 6-ти значный секретный код, сгенерированный в приложении Аутентификатор (Authenticator)",
@@ -782,5 +782,16 @@
782
782
  "Two-factor authentication is enabled": "Двухфакторная аутентификация включена",
783
783
  "Disable TWA": "Отключить TWA",
784
784
  "Enable TWA": "Включить TWA",
785
- "Deleted all rows": "Удалены все строки"
785
+ "Deleted all rows": "Удалены все строки",
786
+ "Use this link: <a href=\"%s\">%s</a> to revisit your application at any time.": "В дальнешем используйте ссылку: <a href=\"%s\">%s</a> для входа в созданное приложение.",
787
+ "To login to a previously created application, go to: ": "Чтобы авторизоваться в ранее созданном приложении, перейдите по ссылке: ",
788
+ "Has channels?": "Связано с каналом?",
789
+ "Menu, search, languages and tenants": "Меню, поиск, языки и подсайты(тенанты)",
790
+ "Images and other files for download": "Изображения и другие файлы для загрузки",
791
+ "Channels to create events for. Separate by comma; leave blank for all": "Каналы, для которых создаются собятия. Разделяются ; Не заполняйте, чтобы использовать события для всех каналов",
792
+ "Event Name": "Имя события",
793
+ "Plugins (Extensions) Store endpoint": "Plugins (Extensions) Store endpoint",
794
+ "Packs Store endpoint": "Packs Store endpoint",
795
+ "The endpoint of plugins store.": "The endpoint of plugins store.",
796
+ "The endpoint of packs store.": "The endpoint of packs store."
786
797
  }
package/markup/admin.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * Admin Menu (Settings...)
2
3
  * @category server
3
4
  * @module markup/admin
4
5
  * @subcategory markup
@@ -6,7 +7,7 @@
6
7
 
7
8
  const {
8
9
  div,
9
- hr,
10
+ //hr,
10
11
  form,
11
12
  input,
12
13
  label,
@@ -18,10 +19,10 @@ const {
18
19
  } = require("@saltcorn/markup/tags");
19
20
  const db = require("@saltcorn/data/db");
20
21
  const {
21
- getConfig,
22
- setConfig,
23
- getAllConfigOrDefaults,
24
- deleteConfig,
22
+ //getConfig,
23
+ //setConfig,
24
+ //getAllConfigOrDefaults,
25
+ //deleteConfig,
25
26
  configTypes,
26
27
  isFixedConfig,
27
28
  } = require("@saltcorn/data/models/config");
@@ -33,6 +34,7 @@ const View = require("@saltcorn/data/models/view");
33
34
  const User = require("@saltcorn/data/models/user");
34
35
 
35
36
  /**
37
+ * Restore Backup
36
38
  * @param {*} csrf
37
39
  * @param {*} inner
38
40
  * @param {string} action
@@ -65,6 +67,7 @@ const restore_backup = (csrf, inner, action = `/admin/restore`) =>
65
67
  );
66
68
 
67
69
  /**
70
+ * Add Edit Bar
68
71
  * @param {object} opts
69
72
  * @param {*} opts.role
70
73
  * @param {*} opts.title
@@ -91,6 +94,7 @@ const add_edit_bar = ({ role, title, contents, what, url, req }) => {
91
94
  };
92
95
 
93
96
  /**
97
+ * Send Settings Page
94
98
  * @param {object} opts
95
99
  * @param {*} opts.req,
96
100
  * @param {*} opts.res,
@@ -140,6 +144,7 @@ const send_settings_page = ({
140
144
  ),
141
145
  },
142
146
  ];
147
+ // headers
143
148
  const title = headers
144
149
  ? {
145
150
  title: req.__(active_sub),
@@ -175,6 +180,7 @@ const send_settings_page = ({
175
180
  };
176
181
 
177
182
  /**
183
+ * Send InfoArch Page
178
184
  * @param {object} args
179
185
  * @returns {void}
180
186
  */
@@ -202,6 +208,7 @@ const send_infoarch_page = (args) => {
202
208
  };
203
209
 
204
210
  /**
211
+ * Send Users Page
205
212
  * @param {object} args
206
213
  * @returns {void}
207
214
  */
@@ -221,6 +228,7 @@ const send_users_page = (args) => {
221
228
  };
222
229
 
223
230
  /**
231
+ * Send Files Page
224
232
  * @param {object} args
225
233
  * @returns {void}
226
234
  */
@@ -237,6 +245,7 @@ const send_files_page = (args) => {
237
245
  };
238
246
 
239
247
  /**
248
+ * Send Events Page
240
249
  * @param {object} args
241
250
  * @returns {void}
242
251
  */
@@ -257,11 +266,12 @@ const send_events_page = (args) => {
257
266
  };
258
267
 
259
268
  /**
269
+ * Send Admin page
260
270
  * @param {object} args
261
271
  * @returns {void}
262
272
  */
263
273
  const send_admin_page = (args) => {
264
- const isRoot = db.getTenantSchema() === db.connectObj.default_schema;
274
+ //const isRoot = db.getTenantSchema() === db.connectObj.default_schema;
265
275
  return send_settings_page({
266
276
  main_section: "About application",
267
277
  main_section_href: "/admin",
@@ -276,6 +286,7 @@ const send_admin_page = (args) => {
276
286
  };
277
287
 
278
288
  /**
289
+ * View Attributes
279
290
  * @param {object} key
280
291
  * @returns {Promise<object>}
281
292
  */
@@ -292,6 +303,7 @@ const viewAttributes = async (key) => {
292
303
  };
293
304
 
294
305
  /**
306
+ * Flash start if required
295
307
  * @param {*} cfgForm
296
308
  * @param {*} req
297
309
  * @returns {void}
@@ -308,6 +320,7 @@ const flash_restart_if_required = (cfgForm, req) => {
308
320
  };
309
321
 
310
322
  /**
323
+ * Flash restart
311
324
  * @param {object} req
312
325
  * @returns {void}
313
326
  */
@@ -321,6 +334,7 @@ const flash_restart = (req) => {
321
334
  };
322
335
 
323
336
  /**
337
+ * Config fields form
324
338
  * @param {object} opts
325
339
  * @param {string[]} opts.field_names
326
340
  * @param {object} opts.req
@@ -335,6 +349,7 @@ const config_fields_form = async ({ field_names, req, ...formArgs }) => {
335
349
 
336
350
  for (const name of field_names) {
337
351
  values[name] = state.getConfig(name);
352
+ //console.log(`config field name: %s`,name);
338
353
  if (configTypes[name].root_only && tenant !== db.connectObj.default_schema)
339
354
  continue;
340
355
  const isView = (configTypes[name].type || "").startsWith("View ");
@@ -386,6 +401,7 @@ const config_fields_form = async ({ field_names, req, ...formArgs }) => {
386
401
  };
387
402
 
388
403
  /**
404
+ * Save config fields from page
389
405
  * @param {*} form
390
406
  * @returns {Promise<void>}
391
407
  */
@@ -400,17 +416,17 @@ const save_config_from_form = async (form) => {
400
416
  };
401
417
 
402
418
  /**
403
- * @returns {string}
419
+ * Get Base Domain
420
+ * @returns {string} base domain
404
421
  */
405
422
  const getBaseDomain = () => {
406
423
  const base_url = getState().getConfig("base_url");
407
424
  if (!base_url) return null;
408
- const domain = base_url
425
+ return base_url
409
426
  .toLowerCase()
410
427
  .replace("https://", "")
411
428
  .replace("http://", "")
412
429
  .replace(/\//g, "");
413
- return domain;
414
430
  };
415
431
 
416
432
  /**
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.7.2-beta.5",
3
+ "version": "0.7.2-beta.8",
4
4
  "description": "Server app for Saltcorn, open-source no-code platform",
5
5
  "homepage": "https://saltcorn.com",
6
6
  "main": "index.js",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@saltcorn/base-plugin": "0.7.2-beta.5",
10
- "@saltcorn/builder": "0.7.2-beta.5",
11
- "@saltcorn/data": "0.7.2-beta.5",
12
- "@saltcorn/admin-models": "0.7.2-beta.5",
13
- "@saltcorn/markup": "0.7.2-beta.5",
14
- "@saltcorn/sbadmin2": "0.7.2-beta.5",
9
+ "@saltcorn/base-plugin": "0.7.2-beta.8",
10
+ "@saltcorn/builder": "0.7.2-beta.8",
11
+ "@saltcorn/data": "0.7.2-beta.8",
12
+ "@saltcorn/admin-models": "0.7.2-beta.8",
13
+ "@saltcorn/markup": "0.7.2-beta.8",
14
+ "@saltcorn/sbadmin2": "0.7.2-beta.8",
15
15
  "@socket.io/cluster-adapter": "^0.1.0",
16
16
  "@socket.io/sticky": "^1.0.1",
17
17
  "aws-sdk": "^2.1037.0",
@@ -48,7 +48,7 @@
48
48
  "pg": "^8.2.1",
49
49
  "pluralize": "^8.0.0",
50
50
  "qrcode": "1.5.0",
51
- "sharp": "0.30.3",
51
+ "resize-with-sharp-or-jimp": "0.1.0",
52
52
  "socket.io": "4.2.0",
53
53
  "thirty-two": "1.0.2",
54
54
  "tmp-promise": "^3.0.2",