underpost 3.2.4 → 3.2.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/.github/workflows/release.cd.yml +1 -2
- package/CHANGELOG.md +268 -1
- package/CLI-HELP.md +26 -13
- package/Dockerfile +0 -4
- package/README.md +3 -3
- package/bin/build.js +13 -3
- package/bin/deploy.js +570 -1
- package/bin/file.js +5 -0
- package/conf.js +11 -2
- package/jsconfig.json +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -3
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +2 -3
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -6
- package/manifests/deployment/dd-test-development/deployment.yaml +136 -66
- package/manifests/deployment/dd-test-development/proxy.yaml +41 -5
- package/package.json +20 -11
- package/src/api/core/core.controller.js +10 -10
- package/src/api/core/core.service.js +10 -10
- package/src/api/default/default.controller.js +10 -10
- package/src/api/default/default.service.js +10 -10
- package/src/api/document/document.controller.js +12 -12
- package/src/api/document/document.model.js +10 -16
- package/src/api/file/file.controller.js +8 -8
- package/src/api/file/file.model.js +10 -10
- package/src/api/file/file.service.js +36 -36
- package/src/api/test/test.controller.js +8 -8
- package/src/api/test/test.service.js +8 -8
- package/src/api/user/guest.service.js +99 -0
- package/src/api/user/user.controller.js +6 -6
- package/src/api/user/user.model.js +8 -13
- package/src/api/user/user.service.js +3 -20
- package/src/cli/deploy.js +33 -30
- package/src/cli/fs.js +62 -5
- package/src/cli/image.js +43 -1
- package/src/cli/index.js +5 -1
- package/src/cli/release.js +58 -2
- package/src/cli/repository.js +35 -3
- package/src/cli/run.js +304 -38
- package/src/cli/ssh.js +1 -1
- package/src/cli/static.js +43 -115
- package/src/client/Default.index.js +21 -33
- package/src/client/components/core/404.js +4 -4
- package/src/client/components/core/500.js +4 -4
- package/src/client/components/core/Account.js +73 -60
- package/src/client/components/core/AgGrid.js +23 -33
- package/src/client/components/core/Alert.js +12 -13
- package/src/client/components/core/AppStore.js +1 -1
- package/src/client/components/core/Auth.js +20 -32
- package/src/client/components/core/Badge.js +7 -13
- package/src/client/components/core/BtnIcon.js +15 -17
- package/src/client/components/core/CalendarCore.js +42 -63
- package/src/client/components/core/Chat.js +13 -15
- package/src/client/components/core/ClientEvents.js +87 -0
- package/src/client/components/core/ColorPaletteElement.js +309 -0
- package/src/client/components/core/Content.js +17 -14
- package/src/client/components/core/Css.js +15 -71
- package/src/client/components/core/CssCore.js +12 -16
- package/src/client/components/core/D3Chart.js +4 -4
- package/src/client/components/core/Docs.js +60 -59
- package/src/client/components/core/DropDown.js +69 -91
- package/src/client/components/core/EventBus.js +92 -0
- package/src/client/components/core/EventsUI.js +14 -17
- package/src/client/components/core/FileExplorer.js +102 -234
- package/src/client/components/core/FullScreen.js +47 -75
- package/src/client/components/core/Input.js +24 -69
- package/src/client/components/core/Keyboard.js +25 -18
- package/src/client/components/core/KeyboardAvoidance.js +145 -0
- package/src/client/components/core/LoadingAnimation.js +25 -31
- package/src/client/components/core/LogIn.js +41 -41
- package/src/client/components/core/LogOut.js +23 -14
- package/src/client/components/core/Modal.js +397 -176
- package/src/client/components/core/NotificationManager.js +14 -18
- package/src/client/components/core/Panel.js +54 -50
- package/src/client/components/core/PanelForm.js +25 -125
- package/src/client/components/core/Polyhedron.js +110 -214
- package/src/client/components/core/PublicProfile.js +39 -32
- package/src/client/components/core/Recover.js +52 -48
- package/src/client/components/core/Responsive.js +88 -32
- package/src/client/components/core/RichText.js +9 -18
- package/src/client/components/core/Router.js +24 -3
- package/src/client/components/core/SearchBox.js +37 -37
- package/src/client/components/core/SignUp.js +39 -30
- package/src/client/components/core/SocketIo.js +31 -2
- package/src/client/components/core/SocketIoHandler.js +6 -6
- package/src/client/components/core/ToggleSwitch.js +8 -20
- package/src/client/components/core/ToolTip.js +5 -17
- package/src/client/components/core/Translate.js +56 -59
- package/src/client/components/core/Validator.js +26 -16
- package/src/client/components/core/Wallet.js +15 -26
- package/src/client/components/core/Worker.js +140 -25
- package/src/client/components/core/windowGetDimensions.js +7 -7
- package/src/client/components/default/{MenuDefault.js → AppShellDefault.js} +87 -87
- package/src/client/components/default/CssDefault.js +12 -12
- package/src/client/components/default/LogInDefault.js +6 -4
- package/src/client/components/default/LogOutDefault.js +6 -4
- package/src/client/components/default/RouterDefault.js +47 -0
- package/src/client/components/default/SettingsDefault.js +4 -4
- package/src/client/components/default/SignUpDefault.js +6 -4
- package/src/client/components/default/TranslateDefault.js +3 -3
- package/src/client/services/core/core.service.js +17 -49
- package/src/client/services/default/default.management.js +139 -242
- package/src/client/services/default/default.service.js +10 -16
- package/src/client/services/document/document.service.js +14 -19
- package/src/client/services/file/file.service.js +8 -13
- package/src/client/services/test/test.service.js +8 -13
- package/src/client/services/user/guest.service.js +79 -0
- package/src/client/services/user/user.management.js +5 -5
- package/src/client/services/user/user.service.js +14 -20
- package/src/client/ssr/body/404.js +3 -3
- package/src/client/ssr/body/500.js +3 -3
- package/src/client/ssr/body/CacheControl.js +5 -2
- package/src/client/ssr/body/DefaultSplashScreen.js +19 -12
- package/src/client/ssr/mailer/DefaultRecoverEmail.js +19 -20
- package/src/client/ssr/mailer/DefaultVerifyEmail.js +15 -16
- package/src/client/ssr/offline/Maintenance.js +12 -11
- package/src/client/ssr/offline/NoNetworkConnection.js +3 -3
- package/src/client/ssr/pages/Test.js +2 -2
- package/src/client/sw/core.sw.js +212 -0
- package/src/index.js +1 -1
- package/src/runtime/express/Dockerfile +4 -4
- package/src/runtime/lampp/Dockerfile +8 -7
- package/src/runtime/wp/Dockerfile +11 -17
- package/src/server/backup.js +1 -2
- package/src/server/client-build-docs.js +45 -46
- package/src/server/client-build.js +334 -60
- package/src/server/client-formatted.js +47 -16
- package/src/server/conf.js +29 -13
- package/src/server/cron.js +6 -8
- package/src/server/dns.js +2 -1
- package/src/server/ipfs-client.js +232 -91
- package/src/server/process.js +13 -27
- package/src/server/start.js +6 -3
- package/src/server/valkey.js +134 -235
- package/tsconfig.docs.json +15 -0
- package/typedoc.json +20 -0
- package/jsdoc.json +0 -52
- package/src/client/components/core/ColorPalette.js +0 -5267
- package/src/client/components/core/JoyStick.js +0 -80
- package/src/client/components/default/RoutesDefault.js +0 -49
- package/src/client/sw/default.sw.js +0 -127
- package/src/client/sw/template.sw.js +0 -84
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import { getId } from './CommonJs.js';
|
|
2
2
|
import { loggerFactory } from './Logger.js';
|
|
3
3
|
import { htmls, s } from './VanillaJs.js';
|
|
4
|
-
|
|
5
4
|
const logger = loggerFactory(import.meta);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.Tokens[id] = {};
|
|
12
|
-
|
|
5
|
+
class ToggleSwitch {
|
|
6
|
+
static Tokens = {};
|
|
7
|
+
static async instance(options) {
|
|
8
|
+
const id = options?.id ? options.id : getId(ToggleSwitch.Tokens, 'toggle-switch-');
|
|
9
|
+
ToggleSwitch.Tokens[id] = {};
|
|
13
10
|
const widthContent = 60;
|
|
14
11
|
const widthCircle = 20;
|
|
15
|
-
|
|
16
12
|
setTimeout(() => {
|
|
17
13
|
switch (options.displayMode) {
|
|
18
14
|
case 'checkbox':
|
|
19
15
|
break;
|
|
20
|
-
|
|
21
16
|
default:
|
|
22
17
|
s(`.${id}-circle`).style.left = `0px`;
|
|
23
18
|
break;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
const onToggle = () => {
|
|
27
21
|
switch (options.displayMode) {
|
|
28
22
|
case 'checkbox':
|
|
@@ -49,22 +43,17 @@ const ToggleSwitch = {
|
|
|
49
43
|
s(`.${id}-checkbox`).checked = false;
|
|
50
44
|
options?.on?.unchecked ? options.on.unchecked() : null;
|
|
51
45
|
};
|
|
52
|
-
|
|
53
46
|
const onClickEvent = () => {
|
|
54
47
|
s(`.${id}-checkbox`).checked ? offToggle() : onToggle();
|
|
55
48
|
logger.info(id, s(`.${id}-checkbox`).checked);
|
|
56
49
|
};
|
|
57
|
-
|
|
58
|
-
this.Tokens[id].click = onClickEvent;
|
|
59
|
-
|
|
50
|
+
ToggleSwitch.Tokens[id].click = onClickEvent;
|
|
60
51
|
if (!options.disabledOnClick) s(`.${id}`).onclick = onClickEvent;
|
|
61
|
-
|
|
62
52
|
setTimeout(() => {
|
|
63
53
|
options?.checked ? onToggle() : null;
|
|
64
54
|
logger.info(id, s(`.${id}-checkbox`).checked);
|
|
65
55
|
});
|
|
66
56
|
});
|
|
67
|
-
|
|
68
57
|
if (options.type === 'checkbox') {
|
|
69
58
|
}
|
|
70
59
|
const htmlRender = html`
|
|
@@ -95,7 +84,6 @@ const ToggleSwitch = {
|
|
|
95
84
|
`;
|
|
96
85
|
}
|
|
97
86
|
return htmlRender;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
87
|
+
}
|
|
88
|
+
}
|
|
101
89
|
export { ToggleSwitch };
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { renderCssAttr } from './Css.js';
|
|
2
2
|
import { append, s } from './VanillaJs.js';
|
|
3
3
|
import { Modal } from './Modal.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Render: async function (
|
|
4
|
+
class ToolTip {
|
|
5
|
+
static Tokens = {};
|
|
6
|
+
static async instance(
|
|
8
7
|
options = { container: '', htmlRender: '', id: '', classList: '', useVisibilityHover: false, useMenuBtn: false },
|
|
9
8
|
) {
|
|
10
9
|
const { container, htmlRender, id, useVisibilityHover } = options;
|
|
11
|
-
|
|
12
10
|
if (useVisibilityHover) {
|
|
13
11
|
const tooltipId = 'tooltip-' + id;
|
|
14
12
|
append(
|
|
@@ -27,10 +25,8 @@ const ToolTip = {
|
|
|
27
25
|
);
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
const containerEl = s(container);
|
|
32
29
|
if (!containerEl) return;
|
|
33
|
-
|
|
34
30
|
const tooltipId = `tooltip-${id}`;
|
|
35
31
|
const tooltip = html`
|
|
36
32
|
<div
|
|
@@ -49,9 +45,7 @@ const ToolTip = {
|
|
|
49
45
|
</div>
|
|
50
46
|
`;
|
|
51
47
|
append('body', tooltip);
|
|
52
|
-
|
|
53
48
|
const tooltipEl = s(`.${tooltipId}`);
|
|
54
|
-
|
|
55
49
|
containerEl.addEventListener('mouseenter', () => {
|
|
56
50
|
if (
|
|
57
51
|
options.useMenuBtn &&
|
|
@@ -60,13 +54,10 @@ const ToolTip = {
|
|
|
60
54
|
).classList.contains('hide')
|
|
61
55
|
)
|
|
62
56
|
return;
|
|
63
|
-
|
|
64
57
|
const containerRect = containerEl.getBoundingClientRect();
|
|
65
58
|
const tooltipRect = tooltipEl.getBoundingClientRect();
|
|
66
|
-
|
|
67
59
|
let top = containerRect.bottom + window.scrollY + 5;
|
|
68
60
|
let left = containerRect.left + window.scrollX + containerRect.width / 2 - tooltipRect.width / 2;
|
|
69
|
-
|
|
70
61
|
// Adjust if it goes off-screen
|
|
71
62
|
if (left < 0) left = 5;
|
|
72
63
|
if (left + tooltipRect.width > window.innerWidth) {
|
|
@@ -75,16 +66,13 @@ const ToolTip = {
|
|
|
75
66
|
if (top + tooltipRect.height > window.innerHeight) {
|
|
76
67
|
top = containerRect.top + window.scrollY - tooltipRect.height - 5;
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
tooltipEl.style.top = `${top}px`;
|
|
80
70
|
tooltipEl.style.left = `${left}px`;
|
|
81
71
|
tooltipEl.style.opacity = '1';
|
|
82
72
|
});
|
|
83
|
-
|
|
84
73
|
containerEl.addEventListener('mouseleave', () => {
|
|
85
74
|
tooltipEl.style.opacity = '0';
|
|
86
75
|
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
76
|
+
}
|
|
77
|
+
}
|
|
90
78
|
export { ToolTip };
|
|
@@ -1,47 +1,61 @@
|
|
|
1
1
|
import { newInstance, getId, cap, capFirst } from './CommonJs.js';
|
|
2
|
+
import { TranslateEventType, translateEvents } from './ClientEvents.js';
|
|
2
3
|
import { DropDown } from './DropDown.js';
|
|
3
4
|
import { loggerFactory } from './Logger.js';
|
|
4
5
|
import { s, htmls, getLang } from './VanillaJs.js';
|
|
5
|
-
|
|
6
6
|
const logger = loggerFactory(import.meta);
|
|
7
|
-
|
|
8
7
|
const textFormatted = (str = '    . . .') => capFirst(str.toLowerCase());
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Parse: function (lang) {
|
|
8
|
+
class Translate {
|
|
9
|
+
static Data = {};
|
|
10
|
+
static Token = {};
|
|
11
|
+
static Event = {};
|
|
12
|
+
static Options = {};
|
|
13
|
+
static Parse(lang) {
|
|
16
14
|
s('html').lang = lang;
|
|
17
|
-
Object.keys(
|
|
18
|
-
if (translateHash in
|
|
19
|
-
if (!('placeholder' in
|
|
15
|
+
Object.keys(Translate.Token).map((translateHash) => {
|
|
16
|
+
if (translateHash in Translate.Token && lang in Translate.Token[translateHash]) {
|
|
17
|
+
if (!('placeholder' in Translate.Options[translateHash]) && s(`.${translateHash}`))
|
|
20
18
|
htmls(
|
|
21
19
|
`.${translateHash}`,
|
|
22
|
-
|
|
23
|
-
?
|
|
24
|
-
: textFormatted(
|
|
20
|
+
Translate.Options[translateHash]?.disableTextFormat
|
|
21
|
+
? Translate.Token[translateHash][lang]
|
|
22
|
+
: textFormatted(Translate.Token[translateHash][lang]),
|
|
25
23
|
);
|
|
26
|
-
else if ('placeholder' in
|
|
27
|
-
s(
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
else if ('placeholder' in Translate.Token[translateHash] && s(Translate.Token[translateHash].placeholder))
|
|
25
|
+
s(Translate.Token[translateHash].placeholder).placeholder = Translate.Options[translateHash]
|
|
26
|
+
?.disableTextFormat
|
|
27
|
+
? Translate.Token[translateHash][lang]
|
|
28
|
+
: textFormatted(Translate.Token[translateHash][lang]);
|
|
30
29
|
}
|
|
31
30
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
Translate.emitChanged({ lang });
|
|
32
|
+
for (const keyEvent of Object.keys(Translate.Event)) Translate.Event[keyEvent]();
|
|
33
|
+
}
|
|
34
|
+
static onChanged(listener, options = {}) {
|
|
35
|
+
if (options.key) Translate.Event[options.key] = listener;
|
|
36
|
+
return translateEvents.on(TranslateEventType.changed, listener, options);
|
|
37
|
+
}
|
|
38
|
+
static offChanged(key) {
|
|
39
|
+
delete Translate.Event[key];
|
|
40
|
+
return translateEvents.off(key);
|
|
41
|
+
}
|
|
42
|
+
static hasChangedListener(key) {
|
|
43
|
+
return translateEvents.has(key);
|
|
44
|
+
}
|
|
45
|
+
static async emitChanged(detail) {
|
|
46
|
+
await translateEvents.emit(TranslateEventType.changed, detail);
|
|
47
|
+
}
|
|
48
|
+
static instance(keyLang, placeholder, options = { disableTextFormat: false }) {
|
|
49
|
+
if (!(keyLang in Translate.Data)) {
|
|
36
50
|
// TODO: add translate package or library for this case
|
|
37
51
|
// logger.warn('translate key lang does not exist: ', keyLang);
|
|
38
52
|
return options.disableTextFormat ? keyLang : textFormatted(keyLang);
|
|
39
53
|
}
|
|
40
|
-
if (placeholder)
|
|
41
|
-
keyLang =
|
|
42
|
-
const translateHash = getId(
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
if (placeholder) Translate.Data[keyLang].placeholder = placeholder;
|
|
55
|
+
keyLang = Translate.Data[keyLang];
|
|
56
|
+
const translateHash = getId(Translate.Token, 'trans');
|
|
57
|
+
Translate.Options[translateHash] = options;
|
|
58
|
+
Translate.Token[translateHash] = newInstance(keyLang);
|
|
45
59
|
if ('placeholder' in keyLang) {
|
|
46
60
|
if (s('html').lang in keyLang)
|
|
47
61
|
return options.disableTextFormat ? keyLang[s('html').lang] : textFormatted(keyLang[s('html').lang]);
|
|
@@ -54,32 +68,31 @@ const Translate = {
|
|
|
54
68
|
return html`<span class="${translateHash}"
|
|
55
69
|
>${options.disableTextFormat ? keyLang['en'] : textFormatted(keyLang['en'])}</span
|
|
56
70
|
>`;
|
|
57
|
-
}
|
|
58
|
-
renderLang
|
|
71
|
+
}
|
|
72
|
+
static renderLang(language) {
|
|
59
73
|
localStorage.setItem('lang', language);
|
|
60
|
-
|
|
74
|
+
Translate.Parse(language);
|
|
61
75
|
if (s(`.action-btn-lang-render`)) htmls(`.action-btn-lang-render`, s('html').lang);
|
|
62
|
-
}
|
|
63
|
-
|
|
76
|
+
}
|
|
77
|
+
static async RenderSetting(id) {
|
|
64
78
|
return html` <div class="in section-mp">
|
|
65
|
-
${await DropDown.
|
|
79
|
+
${await DropDown.instance({
|
|
66
80
|
id: id ?? 'settings-lang',
|
|
67
81
|
value: s('html').lang ? s('html').lang : 'en',
|
|
68
|
-
label: html`${Translate.
|
|
82
|
+
label: html`${Translate.instance('lang')}`,
|
|
69
83
|
data: ['en', 'es'].map((language) => {
|
|
70
84
|
return {
|
|
71
|
-
display: html`<i class="fa-solid fa-language"></i> ${Translate.
|
|
85
|
+
display: html`<i class="fa-solid fa-language"></i> ${Translate.instance(language)}`,
|
|
72
86
|
value: language,
|
|
73
87
|
onClick: () => Translate.renderLang(language),
|
|
74
88
|
};
|
|
75
89
|
}),
|
|
76
90
|
})}
|
|
77
91
|
</div>`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Init: async function () {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class TranslateCore {
|
|
95
|
+
static async instance() {
|
|
83
96
|
s('html').lang = getLang();
|
|
84
97
|
Translate.Data = {
|
|
85
98
|
...Translate.Data,
|
|
@@ -221,11 +234,9 @@ const TranslateCore = {
|
|
|
221
234
|
Translate.Data['confirm-logout'] = { en: 'Confirm Logout', es: 'Confirmar cierre de sesión' };
|
|
222
235
|
Translate.Data['success-logout'] = { en: 'Successful session logout', es: 'Cierre de sesión exitoso' };
|
|
223
236
|
Translate.Data['account'] = { en: 'Account', es: 'Cuenta' };
|
|
224
|
-
|
|
225
237
|
Translate.Data['update'] = { en: 'Update', es: 'Actualizar' };
|
|
226
238
|
Translate.Data['success-update-user'] = { en: 'user update successfully', es: 'usuario actualizado correctamente' };
|
|
227
239
|
Translate.Data['error-update-user'] = { en: 'error update user', es: 'error al actualizar el usuario' };
|
|
228
|
-
|
|
229
240
|
Translate.Data['edit'] = { en: 'Edit', es: 'Editar' };
|
|
230
241
|
Translate.Data['copy-share-link'] = { en: 'Copy share link', es: 'Copiar enlace compartido' };
|
|
231
242
|
Translate.Data['link-copied'] = { en: 'Link copied to clipboard', es: 'Enlace copiado al portapapeles' };
|
|
@@ -235,17 +246,12 @@ const TranslateCore = {
|
|
|
235
246
|
Translate.Data['confirm'] = { en: 'confirm', es: 'confirmar' };
|
|
236
247
|
Translate.Data['cancel'] = { en: 'cancel', es: 'cancelar' };
|
|
237
248
|
Translate.Data['verify-email'] = { en: 'Verify email', es: 'email de verificacion' };
|
|
238
|
-
|
|
239
249
|
Translate.Data[`email send`] = { en: 'email send', es: 'email enviado' };
|
|
240
|
-
|
|
241
250
|
Translate.Data['success-generate-keys'] = { en: 'Keys generated successfully.', es: 'Llaves generadas con éxito.' };
|
|
242
251
|
Translate.Data['error-generate-keys'] = { en: 'Error generating keys.', es: 'Error al generar las llaves.' };
|
|
243
|
-
|
|
244
252
|
Translate.Data['copy'] = { en: 'Copy', es: 'Copiar' };
|
|
245
253
|
Translate.Data['keys'] = { en: 'Keys', es: 'Llaves' };
|
|
246
|
-
|
|
247
254
|
Translate.Data['success-copy-data'] = { es: '¡Datos copiados con éxito!', en: 'Data copied successfully!' };
|
|
248
|
-
|
|
249
255
|
Translate.Data['character'] = { es: 'Personaje', en: 'Character' };
|
|
250
256
|
Translate.Data['file-path'] = { en: 'file path', es: 'ruta de archivo' };
|
|
251
257
|
Translate.Data['drop-file'] = { en: 'drop file', es: 'soltar archivo' };
|
|
@@ -258,7 +264,6 @@ const TranslateCore = {
|
|
|
258
264
|
Translate.Data['calendar'] = { es: 'Calendario', en: 'Calendar' };
|
|
259
265
|
Translate.Data['docs'] = { es: 'Documentacion', en: 'Documentation' };
|
|
260
266
|
Translate.Data['clean-cache'] = { es: 'Limpiar caché', en: 'Clean cache' };
|
|
261
|
-
|
|
262
267
|
Translate.Data['add'] = { es: 'Agregar', en: 'Add' };
|
|
263
268
|
Translate.Data['mode'] = { es: 'Modo', en: 'Mode' };
|
|
264
269
|
Translate.Data['result'] = { es: 'Resultado', en: 'Result' };
|
|
@@ -272,7 +277,6 @@ const TranslateCore = {
|
|
|
272
277
|
es: 'Vista previa no disponible',
|
|
273
278
|
};
|
|
274
279
|
Translate.Data['recent'] = { es: 'Reciente', en: 'recent' };
|
|
275
|
-
|
|
276
280
|
Translate.Data = {
|
|
277
281
|
...Translate.Data,
|
|
278
282
|
...{
|
|
@@ -338,7 +342,6 @@ const TranslateCore = {
|
|
|
338
342
|
es: 'No se pudo conectar al dispositivo de transmisión.',
|
|
339
343
|
en: 'Unable to connect to the stream device.',
|
|
340
344
|
};
|
|
341
|
-
|
|
342
345
|
Translate.Data['equip'] = {
|
|
343
346
|
es: 'Equipar',
|
|
344
347
|
en: 'Equip',
|
|
@@ -347,7 +350,6 @@ const TranslateCore = {
|
|
|
347
350
|
es: 'Desequipar',
|
|
348
351
|
en: 'Unequip',
|
|
349
352
|
};
|
|
350
|
-
|
|
351
353
|
Translate.Data['i-have-account'] = {
|
|
352
354
|
en: 'I have an account',
|
|
353
355
|
es: 'Tengo una cuenta',
|
|
@@ -398,7 +400,6 @@ const TranslateCore = {
|
|
|
398
400
|
};
|
|
399
401
|
Translate.Data['resend'] = { en: 'Resend', es: 'Reenviar' };
|
|
400
402
|
Translate.Data['delete-account'] = { en: 'Delete Account', es: 'Borrar cuenta' };
|
|
401
|
-
|
|
402
403
|
Translate.Data['doc-title'] = {
|
|
403
404
|
en: 'Doc Title',
|
|
404
405
|
es: 'Título del documento',
|
|
@@ -455,7 +456,6 @@ const TranslateCore = {
|
|
|
455
456
|
en: 'Error deleting account.',
|
|
456
457
|
es: 'Error al borrar la cuenta.',
|
|
457
458
|
};
|
|
458
|
-
|
|
459
459
|
Translate.Data['confirm-delete-account'] = {
|
|
460
460
|
en: 'Are you sure you want to delete your account?',
|
|
461
461
|
es: '¿Estás seguro de que deseas borrar tu cuenta?',
|
|
@@ -571,7 +571,6 @@ const TranslateCore = {
|
|
|
571
571
|
Translate.Data['next'] = { es: 'Siguiente', en: 'Next' };
|
|
572
572
|
Translate.Data['buy'] = { es: 'comprar', en: 'Buy' };
|
|
573
573
|
Translate.Data['sell'] = { es: 'Vender', en: 'sell' };
|
|
574
|
-
|
|
575
574
|
Translate.Data['monday'] = { es: 'Lunes', en: 'Monday' };
|
|
576
575
|
Translate.Data['tuesday'] = { es: 'Martes', en: 'Tuesday' };
|
|
577
576
|
Translate.Data['wednesday'] = { es: 'Miércoles', en: 'Wednesday' };
|
|
@@ -579,7 +578,6 @@ const TranslateCore = {
|
|
|
579
578
|
Translate.Data['friday'] = { es: 'Viernes', en: 'Friday' };
|
|
580
579
|
Translate.Data['saturday'] = { es: 'Sábado', en: 'Saturday' };
|
|
581
580
|
Translate.Data['sunday'] = { es: 'Domingo', en: 'Sunday' };
|
|
582
|
-
|
|
583
581
|
Translate.Data['description'] = { es: 'Descripción', en: 'Description' };
|
|
584
582
|
Translate.Data['daysOfWeek'] = { es: 'Días de la semana', en: 'Days of the week' };
|
|
585
583
|
Translate.Data['startTime'] = { es: 'Hora de inicio', en: 'Start time' };
|
|
@@ -691,7 +689,6 @@ const TranslateCore = {
|
|
|
691
689
|
en: 'Filter cleared successfully',
|
|
692
690
|
es: 'Filtro limpiado con éxito',
|
|
693
691
|
};
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
692
|
+
}
|
|
693
|
+
}
|
|
697
694
|
export { Translate, TranslateCore, textFormatted };
|
|
@@ -6,14 +6,14 @@ import { htmls, s } from './VanillaJs.js';
|
|
|
6
6
|
|
|
7
7
|
const logger = loggerFactory(import.meta);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
renderErrorMessage
|
|
9
|
+
class Validator {
|
|
10
|
+
static renderErrorMessage(rule, text) {
|
|
11
11
|
return html` <div class="in">
|
|
12
12
|
${renderStatus('error', { class: 'inl' })}  
|
|
13
|
-
<span style="color: red">${text ? textFormatted(text) : Translate.
|
|
13
|
+
<span style="color: red">${text ? textFormatted(text) : Translate.instance(rule.type)}</span>
|
|
14
14
|
</div>`;
|
|
15
|
-
}
|
|
16
|
-
instance
|
|
15
|
+
}
|
|
16
|
+
static instance(validators, callBack = (value) => {}) {
|
|
17
17
|
const validatorFunction = {};
|
|
18
18
|
if (!Array.isArray(validators)) validators = Object.values(validators);
|
|
19
19
|
for (const validatorData of validators) {
|
|
@@ -31,7 +31,7 @@ const Validator = {
|
|
|
31
31
|
if (errors.length > 0)
|
|
32
32
|
errorMessage += errors
|
|
33
33
|
.map((translateMessage) =>
|
|
34
|
-
|
|
34
|
+
Validator.renderErrorMessage(
|
|
35
35
|
undefined,
|
|
36
36
|
html`
|
|
37
37
|
${translateMessage[s('html').lang]
|
|
@@ -45,23 +45,27 @@ const Validator = {
|
|
|
45
45
|
break;
|
|
46
46
|
case 'isEmpty':
|
|
47
47
|
if (validator.isEmpty(s(`.${validatorData.id}`).value, { ignore_whitespace: true }))
|
|
48
|
-
errorMessage +=
|
|
48
|
+
errorMessage += Validator.renderErrorMessage(rule);
|
|
49
49
|
break;
|
|
50
50
|
case 'isEmail':
|
|
51
|
-
if (!validator.isEmail(s(`.${validatorData.id}`).value))
|
|
51
|
+
if (!validator.isEmail(s(`.${validatorData.id}`).value))
|
|
52
|
+
errorMessage += Validator.renderErrorMessage(rule);
|
|
52
53
|
break;
|
|
53
54
|
case 'passwordMismatch':
|
|
54
55
|
if (!validator.equals(s(`.${validatorData.id}`).value, s(`.${rule.options}`).value))
|
|
55
|
-
errorMessage +=
|
|
56
|
+
errorMessage += Validator.renderErrorMessage(rule);
|
|
56
57
|
break;
|
|
57
58
|
case 'isLength':
|
|
58
59
|
if (!validator.isLength(s(`.${validatorData.id}`).value, rule.options))
|
|
59
|
-
errorMessage +=
|
|
60
|
+
errorMessage += Validator.renderErrorMessage(rule);
|
|
60
61
|
break;
|
|
61
62
|
|
|
62
63
|
case 'isChileanIdentityDocument': {
|
|
63
64
|
if (!isChileanIdentityDocument(s(`.${validatorData.id}`).value)) {
|
|
64
|
-
errorMessage +=
|
|
65
|
+
errorMessage += Validator.renderErrorMessage(
|
|
66
|
+
undefined,
|
|
67
|
+
Translate.instance('invalid-identity-document'),
|
|
68
|
+
);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
break;
|
|
@@ -70,13 +74,19 @@ const Validator = {
|
|
|
70
74
|
const username = s(`.${validatorData.id}`).value;
|
|
71
75
|
// Check if username is empty or only whitespace
|
|
72
76
|
if (!username || username.trim() === '') {
|
|
73
|
-
errorMessage +=
|
|
77
|
+
errorMessage += Validator.renderErrorMessage(
|
|
78
|
+
undefined,
|
|
79
|
+
Translate.instance('invalid-username-format'),
|
|
80
|
+
);
|
|
74
81
|
break;
|
|
75
82
|
}
|
|
76
83
|
// Check if username contains only valid characters (no spaces or special chars)
|
|
77
84
|
const usernameRegex = /^[a-zA-Z0-9_-]+$/;
|
|
78
85
|
if (!usernameRegex.test(username)) {
|
|
79
|
-
errorMessage +=
|
|
86
|
+
errorMessage += Validator.renderErrorMessage(
|
|
87
|
+
undefined,
|
|
88
|
+
Translate.instance('invalid-username-format'),
|
|
89
|
+
);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
break;
|
|
@@ -86,7 +96,7 @@ const Validator = {
|
|
|
86
96
|
validator[rule.type] &&
|
|
87
97
|
!validator[rule.type](s(`.${validatorData.id}`).value, rule?.options ? rule.options : undefined)
|
|
88
98
|
)
|
|
89
|
-
errorMessage +=
|
|
99
|
+
errorMessage += Validator.renderErrorMessage(rule);
|
|
90
100
|
break;
|
|
91
101
|
}
|
|
92
102
|
}
|
|
@@ -124,7 +134,7 @@ const Validator = {
|
|
|
124
134
|
}
|
|
125
135
|
return { errorMessage, errorKeys, successKeys };
|
|
126
136
|
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
129
139
|
|
|
130
140
|
export { Validator };
|
|
@@ -8,42 +8,34 @@ import { EventsUI } from './EventsUI.js';
|
|
|
8
8
|
import { NotificationManager } from './NotificationManager.js';
|
|
9
9
|
import { Translate } from './Translate.js';
|
|
10
10
|
import { copyData, htmls, s } from './VanillaJs.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const id = getId(this.Data, 'wallet-');
|
|
11
|
+
class Wallet {
|
|
12
|
+
static Data = {};
|
|
13
|
+
static async instance(options) {
|
|
14
|
+
const id = getId(Wallet.Data, 'wallet-');
|
|
16
15
|
setTimeout(async () => {
|
|
17
16
|
EventsUI.onClick(`.btn-generate-keys-${id}`, async (e) => {
|
|
18
17
|
e.preventDefault();
|
|
19
|
-
|
|
20
18
|
const algorithm = {
|
|
21
19
|
name: 'ECDSA',
|
|
22
20
|
namedCurve: 'P-384',
|
|
23
21
|
hash: 'SHA-256',
|
|
24
22
|
};
|
|
25
23
|
const format = 'jwk';
|
|
26
|
-
|
|
27
24
|
(async () => {
|
|
28
25
|
return;
|
|
29
26
|
const { data: payload } = await UserService.get({ id: 'public-key-sign-token' });
|
|
30
|
-
|
|
31
27
|
const signature = await window.crypto.subtle.sign(
|
|
32
28
|
algorithm,
|
|
33
29
|
keyPair.privateKey,
|
|
34
|
-
new TextEncoder().encode(payload),
|
|
30
|
+
new TextEncoder().encode(payload),
|
|
35
31
|
);
|
|
36
|
-
|
|
37
32
|
const base64Signature = btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
38
33
|
})();
|
|
39
|
-
|
|
40
34
|
const keyPair = await window.crypto.subtle.generateKey(algorithm, true, ['sign', 'verify']);
|
|
41
35
|
const privateKey = await window.crypto.subtle.exportKey(format, keyPair.privateKey);
|
|
42
36
|
const publicKey = await window.crypto.subtle.exportKey(format, keyPair.publicKey);
|
|
43
|
-
|
|
44
37
|
const displayKeys = JSON.stringify({ privateKey, publicKey }, null, 4);
|
|
45
38
|
htmls('.keys-display', displayKeys);
|
|
46
|
-
|
|
47
39
|
if (Auth.getToken()) {
|
|
48
40
|
const result = await CryptoService.post({
|
|
49
41
|
body: {
|
|
@@ -53,19 +45,17 @@ const Wallet = {
|
|
|
53
45
|
},
|
|
54
46
|
});
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
NotificationManager.Push({
|
|
58
|
-
// html: Translate.
|
|
59
|
-
html: Translate.
|
|
49
|
+
// html: Translate.instance(`${result.status}-generate-keys`),
|
|
50
|
+
html: Translate.instance(`success-generate-keys`),
|
|
60
51
|
// status: result.status,
|
|
61
52
|
status: 'success',
|
|
62
53
|
});
|
|
63
|
-
|
|
64
54
|
EventsUI.onClick(`.btn-copy-keys-${id}`, async (e) => {
|
|
65
55
|
e.preventDefault();
|
|
66
56
|
await copyData(displayKeys);
|
|
67
57
|
NotificationManager.Push({
|
|
68
|
-
html: Translate.
|
|
58
|
+
html: Translate.instance('success-copy-data'),
|
|
69
59
|
status: 'success',
|
|
70
60
|
});
|
|
71
61
|
});
|
|
@@ -82,14 +72,14 @@ const Wallet = {
|
|
|
82
72
|
based on elliptic curve digital signature,
|
|
83
73
|
<a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto">more info</a>.
|
|
84
74
|
</div>
|
|
85
|
-
${await BtnIcon.
|
|
75
|
+
${await BtnIcon.instance({
|
|
86
76
|
class: `inl section-mp btn-custom btn-generate-keys-${id}`,
|
|
87
|
-
label: html`<i class="fa-solid fa-arrows-rotate"></i> ${Translate.
|
|
88
|
-
${Translate.
|
|
77
|
+
label: html`<i class="fa-solid fa-arrows-rotate"></i> ${Translate.instance('generate')}
|
|
78
|
+
${Translate.instance('keys')}`,
|
|
89
79
|
})}
|
|
90
|
-
${await BtnIcon.
|
|
80
|
+
${await BtnIcon.instance({
|
|
91
81
|
class: `inl section-mp btn-custom btn-copy-keys-${id}`,
|
|
92
|
-
label: html`<i class="fas fa-copy"></i> ${Translate.
|
|
82
|
+
label: html`<i class="fas fa-copy"></i> ${Translate.instance('copy')} ${Translate.instance('keys')}`,
|
|
93
83
|
})}
|
|
94
84
|
</div>
|
|
95
85
|
</div>
|
|
@@ -100,7 +90,6 @@ const Wallet = {
|
|
|
100
90
|
</div>
|
|
101
91
|
</div>
|
|
102
92
|
`;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
93
|
+
}
|
|
94
|
+
}
|
|
106
95
|
export { Wallet };
|