@live-change/user-frontend 0.9.201 → 0.9.204

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.
@@ -0,0 +1,177 @@
1
+ export default app.config;
2
+ declare namespace config {
3
+ namespace clientConfig {
4
+ export { version };
5
+ export { name };
6
+ export { brandName };
7
+ export { brandDomain };
8
+ export { homepage };
9
+ export { baseHref };
10
+ }
11
+ let services: ({
12
+ name: string;
13
+ path: string;
14
+ createSessionOnUpdate?: undefined;
15
+ remoteAccountTypes?: undefined;
16
+ contactTypes?: undefined;
17
+ signUp?: undefined;
18
+ signIn?: undefined;
19
+ connect?: undefined;
20
+ signInWithoutPassword?: undefined;
21
+ notificationTypes?: undefined;
22
+ geoIpCountryPath?: undefined;
23
+ geoIpDefaultCountry?: undefined;
24
+ } | {
25
+ name: string;
26
+ path: string;
27
+ createSessionOnUpdate: boolean;
28
+ remoteAccountTypes?: undefined;
29
+ contactTypes?: undefined;
30
+ signUp?: undefined;
31
+ signIn?: undefined;
32
+ connect?: undefined;
33
+ signInWithoutPassword?: undefined;
34
+ notificationTypes?: undefined;
35
+ geoIpCountryPath?: undefined;
36
+ geoIpDefaultCountry?: undefined;
37
+ } | {
38
+ name: string;
39
+ path: string;
40
+ remoteAccountTypes: string[];
41
+ createSessionOnUpdate?: undefined;
42
+ contactTypes?: undefined;
43
+ signUp?: undefined;
44
+ signIn?: undefined;
45
+ connect?: undefined;
46
+ signInWithoutPassword?: undefined;
47
+ notificationTypes?: undefined;
48
+ geoIpCountryPath?: undefined;
49
+ geoIpDefaultCountry?: undefined;
50
+ } | {
51
+ name: string;
52
+ path: string;
53
+ contactTypes: string[];
54
+ signUp: boolean;
55
+ signIn: boolean;
56
+ connect: boolean;
57
+ createSessionOnUpdate?: undefined;
58
+ remoteAccountTypes?: undefined;
59
+ signInWithoutPassword?: undefined;
60
+ notificationTypes?: undefined;
61
+ geoIpCountryPath?: undefined;
62
+ geoIpDefaultCountry?: undefined;
63
+ } | {
64
+ name: string;
65
+ path: string;
66
+ contactTypes: string[];
67
+ signInWithoutPassword: boolean;
68
+ createSessionOnUpdate?: undefined;
69
+ remoteAccountTypes?: undefined;
70
+ signUp?: undefined;
71
+ signIn?: undefined;
72
+ connect?: undefined;
73
+ notificationTypes?: undefined;
74
+ geoIpCountryPath?: undefined;
75
+ geoIpDefaultCountry?: undefined;
76
+ } | {
77
+ name: string;
78
+ path?: undefined;
79
+ createSessionOnUpdate?: undefined;
80
+ remoteAccountTypes?: undefined;
81
+ contactTypes?: undefined;
82
+ signUp?: undefined;
83
+ signIn?: undefined;
84
+ connect?: undefined;
85
+ signInWithoutPassword?: undefined;
86
+ notificationTypes?: undefined;
87
+ geoIpCountryPath?: undefined;
88
+ geoIpDefaultCountry?: undefined;
89
+ } | {
90
+ clientKeys: (client: any) => {
91
+ key: string;
92
+ value: any;
93
+ }[];
94
+ patterns: {
95
+ elements: {};
96
+ relations: {};
97
+ };
98
+ counters: ({
99
+ id: string;
100
+ match: string[];
101
+ keys: string[];
102
+ max: number;
103
+ duration: string;
104
+ actions: {
105
+ type: string;
106
+ keys: string[];
107
+ ban: {
108
+ type: string;
109
+ actions: string[];
110
+ expire: string;
111
+ };
112
+ }[];
113
+ visible?: undefined;
114
+ } | {
115
+ id: string;
116
+ visible: boolean;
117
+ match: string[];
118
+ keys: string[];
119
+ max: number;
120
+ duration: string;
121
+ actions: {
122
+ type: string;
123
+ keys: string[];
124
+ ban: {
125
+ type: string;
126
+ actions: string[];
127
+ expire: string;
128
+ };
129
+ }[];
130
+ })[];
131
+ name: string;
132
+ path: string;
133
+ createSessionOnUpdate?: undefined;
134
+ remoteAccountTypes?: undefined;
135
+ contactTypes?: undefined;
136
+ signUp?: undefined;
137
+ signIn?: undefined;
138
+ connect?: undefined;
139
+ signInWithoutPassword?: undefined;
140
+ notificationTypes?: undefined;
141
+ geoIpCountryPath?: undefined;
142
+ geoIpDefaultCountry?: undefined;
143
+ } | {
144
+ name: string;
145
+ path: string;
146
+ contactTypes: string[];
147
+ notificationTypes: string[];
148
+ createSessionOnUpdate?: undefined;
149
+ remoteAccountTypes?: undefined;
150
+ signUp?: undefined;
151
+ signIn?: undefined;
152
+ connect?: undefined;
153
+ signInWithoutPassword?: undefined;
154
+ geoIpCountryPath?: undefined;
155
+ geoIpDefaultCountry?: undefined;
156
+ } | {
157
+ name: string;
158
+ geoIpCountryPath: string;
159
+ geoIpDefaultCountry: string;
160
+ path?: undefined;
161
+ createSessionOnUpdate?: undefined;
162
+ remoteAccountTypes?: undefined;
163
+ contactTypes?: undefined;
164
+ signUp?: undefined;
165
+ signIn?: undefined;
166
+ connect?: undefined;
167
+ signInWithoutPassword?: undefined;
168
+ notificationTypes?: undefined;
169
+ })[];
170
+ }
171
+ declare const app: any;
172
+ declare const version: any;
173
+ declare const name: any;
174
+ declare const brandName: any;
175
+ declare const brandDomain: any;
176
+ declare const homepage: any;
177
+ declare const baseHref: any;
@@ -0,0 +1,135 @@
1
+ import dotenv from 'dotenv';
2
+ dotenv.config();
3
+ import App from "@live-change/framework";
4
+ const app = App.app();
5
+ import { fileURLToPath } from 'url';
6
+ import { dirname, join } from 'path';
7
+ import { accessSync, readFileSync } from 'fs';
8
+ const packageJsonPath = dirname(fileURLToPath(import.meta.url))
9
+ .split('/').map((part, i, arr) => join(arr.slice(0, arr.length - i).join('/'), 'package.json')).find(p => { try {
10
+ accessSync(p);
11
+ return true;
12
+ }
13
+ catch (e) {
14
+ return false;
15
+ } });
16
+ const packageJson = packageJsonPath ? JSON.parse(readFileSync(packageJsonPath, 'utf-8')) : {};
17
+ const name = packageJson.name ?? "Example";
18
+ const brandName = process.env.BRAND_NAME || (name[0].toUpperCase() + name.slice(1));
19
+ const homepage = process.env.BASE_HREF ?? packageJson.homepage;
20
+ const brandDomain = process.env.BRAND_DOMAIN ||
21
+ (homepage && homepage.match(/https\:\/\/([^\/]+)/)?.[1]) || 'example.com';
22
+ const baseHref = process.env.BASE_HREF || homepage || 'http://localhost:8001';
23
+ const version = process.env.VERSION || packageJson.version;
24
+ const clientConfig = {
25
+ version,
26
+ name, brandName, brandDomain, homepage, baseHref
27
+ };
28
+ const baseAppConfig = {
29
+ ...clientConfig,
30
+ clientConfig: { ...clientConfig },
31
+ };
32
+ const contactTypes = ['email', 'phone'];
33
+ const remoteAccountTypes = ['google', 'linkedin'];
34
+ import securityConfig from './security.config.js';
35
+ app.config = {
36
+ ...baseAppConfig,
37
+ clientConfig: {
38
+ ...baseAppConfig.clientConfig,
39
+ },
40
+ services: [
41
+ {
42
+ name: 'timer',
43
+ path: '@live-change/timer-service'
44
+ },
45
+ {
46
+ name: 'session',
47
+ path: '@live-change/session-service',
48
+ createSessionOnUpdate: true
49
+ },
50
+ {
51
+ name: 'user',
52
+ path: '@live-change/user-service',
53
+ remoteAccountTypes
54
+ },
55
+ {
56
+ name: 'email',
57
+ path: '@live-change/email-service'
58
+ },
59
+ {
60
+ name: 'phone',
61
+ path: '@live-change/phone-service'
62
+ },
63
+ {
64
+ name: 'secretLink',
65
+ path: '@live-change/secret-link-service'
66
+ },
67
+ {
68
+ name: 'secretCode',
69
+ path: '@live-change/secret-code-service'
70
+ },
71
+ {
72
+ name: 'messageAuthentication',
73
+ path: '@live-change/message-authentication-service',
74
+ contactTypes,
75
+ signUp: true,
76
+ signIn: true,
77
+ connect: true
78
+ },
79
+ {
80
+ name: 'passwordAuthentication',
81
+ path: '@live-change/password-authentication-service',
82
+ contactTypes,
83
+ signInWithoutPassword: true
84
+ },
85
+ {
86
+ name: 'googleAuthentication',
87
+ path: '@live-change/google-authentication-service',
88
+ },
89
+ {
90
+ name: 'linkedinAuthentication',
91
+ },
92
+ {
93
+ name: 'security',
94
+ path: '@live-change/security-service',
95
+ ...securityConfig
96
+ },
97
+ {
98
+ name: 'userIdentification',
99
+ path: '@live-change/user-identification-service'
100
+ },
101
+ {
102
+ name: 'identicon',
103
+ path: '@live-change/identicon-service'
104
+ },
105
+ {
106
+ name: 'localeSettings'
107
+ },
108
+ {
109
+ name: 'notification',
110
+ path: '@live-change/notification-service',
111
+ contactTypes,
112
+ notificationTypes: ['example_TestNotification']
113
+ },
114
+ {
115
+ name: 'upload',
116
+ path: '@live-change/upload-service'
117
+ },
118
+ {
119
+ name: 'geoIp',
120
+ geoIpCountryPath: 'geoip/GeoLite2-Country.mmdb',
121
+ geoIpDefaultCountry: 'PL'
122
+ },
123
+ {
124
+ name: 'image',
125
+ path: '@live-change/image-service'
126
+ },
127
+ /* {
128
+ name: 'backup',
129
+ path: '@live-change/backup-service',
130
+ clearEvents: true
131
+ }*/
132
+ // { path: '@live-change/google-account-service' },
133
+ ]
134
+ };
135
+ export default app.config;
@@ -0,0 +1,6 @@
1
+ export function createUser(services: any, name: any, email: any, password: any, user?: any, roles?: any[]): Promise<{
2
+ id: any;
3
+ name: any;
4
+ email: any;
5
+ password: any;
6
+ }>;
@@ -0,0 +1,20 @@
1
+ import App from '@live-change/framework';
2
+ const app = App.app();
3
+ async function createUser(services, name, email, password, user = app.generateUid(), roles = []) {
4
+ const { PasswordAuthentication } = services.passwordAuthentication.models;
5
+ const passwordHash = PasswordAuthentication.definition.properties.passwordHash.preFilter(password);
6
+ await services.user.models.User.create({ id: user, roles });
7
+ await PasswordAuthentication.create({ id: user, user, passwordHash });
8
+ await services.email.models.Email.create({ id: email, email, user });
9
+ await services.userIdentification.models.Identification.create({
10
+ id: App.encodeIdentifier(['user_User', user]), sessionOrUserType: 'user_User', sessionOrUser: user,
11
+ name
12
+ });
13
+ return {
14
+ id: user,
15
+ name,
16
+ email,
17
+ password
18
+ };
19
+ }
20
+ export { createUser };
@@ -0,0 +1 @@
1
+ export default function _default(services: any): Promise<void>;
@@ -0,0 +1,46 @@
1
+ import App from '@live-change/framework';
2
+ const app = App.app();
3
+ export default async function (services) {
4
+ const user = '[testUser]';
5
+ const email = 'tester@test.com';
6
+ const email2 = 'tester2@test.com';
7
+ const password = 'Testy123';
8
+ const session = 'GOzz0WylRDklhLCSppS6bwRYUeIQJqzt';
9
+ //console.log("MDL", services.passwordAuthentication.models.PasswordAuthentication)
10
+ const passwordHash = services.passwordAuthentication.models.PasswordAuthentication
11
+ .definition.properties.passwordHash.preFilter(password);
12
+ await services.user.models.User.create({ id: user, roles: [] });
13
+ await services.passwordAuthentication.models.PasswordAuthentication.create({ id: user, user, passwordHash });
14
+ await services.email.models.Email.create({ id: email, email, user });
15
+ await services.email.models.Email.create({ id: email2, email: email2, user });
16
+ await services.user.models.AuthenticatedUser.create({ id: session, session, user });
17
+ await services.notification.models.NotificationSetting.create({
18
+ id: App.encodeIdentifier(['email_Email', email, 'example_TestNotification', 'example_TestNotification']),
19
+ contactType: 'email_Email',
20
+ contact: email,
21
+ notificationType: 'example_TestNotification',
22
+ notification: 'example_TestNotification',
23
+ active: true,
24
+ lastChanged: new Date()
25
+ });
26
+ await services.notification.models.Notification.create({
27
+ id: app.generateUid(),
28
+ sessionOrUserType: 'user_User',
29
+ sessionOrUser: user,
30
+ time: new Date(),
31
+ state: 'new',
32
+ readState: 'new',
33
+ notificationType: 'example_TestNotification'
34
+ });
35
+ for (let i = 1; i <= 12; i++) {
36
+ await services.notification.models.Notification.create({
37
+ id: app.generateUid(),
38
+ sessionOrUserType: 'user_User',
39
+ sessionOrUser: user,
40
+ time: new Date(Date.now() - i * 60 * 1000),
41
+ state: 'new',
42
+ readState: 'new',
43
+ notificationType: 'example_RandomNotification'
44
+ });
45
+ } //*/
46
+ }
@@ -0,0 +1,47 @@
1
+ declare namespace _default {
2
+ export { clientKeys };
3
+ export { patterns };
4
+ export { counters };
5
+ }
6
+ export default _default;
7
+ declare function clientKeys(client: any): {
8
+ key: string;
9
+ value: any;
10
+ }[];
11
+ declare const patterns: {
12
+ elements: {};
13
+ relations: {};
14
+ };
15
+ declare const counters: ({
16
+ id: string;
17
+ match: string[];
18
+ keys: string[];
19
+ max: number;
20
+ duration: string;
21
+ actions: {
22
+ type: string;
23
+ keys: string[];
24
+ ban: {
25
+ type: string;
26
+ actions: string[];
27
+ expire: string;
28
+ };
29
+ }[];
30
+ visible?: undefined;
31
+ } | {
32
+ id: string;
33
+ visible: boolean;
34
+ match: string[];
35
+ keys: string[];
36
+ max: number;
37
+ duration: string;
38
+ actions: {
39
+ type: string;
40
+ keys: string[];
41
+ ban: {
42
+ type: string;
43
+ actions: string[];
44
+ expire: string;
45
+ };
46
+ }[];
47
+ })[];
@@ -0,0 +1,48 @@
1
+ import lcp from "@live-change/pattern";
2
+ const clientKeys = (client) => [
3
+ { key: 'user', value: client.user },
4
+ { key: 'session', value: client.session },
5
+ { key: 'ip', value: client.ip }
6
+ ];
7
+ const failedAuthCodes = lcp.chain([
8
+ { type: "wrong-secret-code", id: "1st-failed-secret-code" },
9
+ { eq: "ip", expire: "10m" },
10
+ { type: "wrong-secret-code", id: "2nd-failed-secret-code" },
11
+ { eq: "ip", expire: "10m" },
12
+ { type: "wrong-secret-code", id: "3rd-failed-secret-code",
13
+ actions: [
14
+ { type: 'ban', keys: ['ip'], ban: { type: 'captcha', actions: ['checkSecretCode'], expire: "30m" } }
15
+ ]
16
+ }
17
+ ]).model;
18
+ const patterns = lcp.mergeModels(
19
+ //failedAuthCodes
20
+ );
21
+ const counters = [
22
+ {
23
+ id: 'wrong-codes-captcha',
24
+ match: ['wrong-secret-code'],
25
+ keys: ['ip'],
26
+ max: 2,
27
+ duration: '1m',
28
+ actions: [
29
+ { type: 'ban', keys: ['ip'], ban: { type: 'captcha', actions: ['checkSecretCode'], expire: "30m" } }
30
+ ]
31
+ },
32
+ {
33
+ id: 'wrong-codes-ban',
34
+ visible: true,
35
+ match: ['wrong-secret-code'],
36
+ keys: ['ip'],
37
+ max: 5,
38
+ duration: '10m',
39
+ actions: [
40
+ { type: 'ban', keys: ['ip'], ban: { type: 'block', actions: ['checkSecretCode'], expire: "2m" } }
41
+ ]
42
+ }
43
+ ];
44
+ export default {
45
+ clientKeys,
46
+ patterns,
47
+ counters
48
+ };
@@ -0,0 +1,21 @@
1
+ import timer from '@live-change/timer-service';
2
+ import session from '@live-change/session-service';
3
+ import user from '@live-change/user-service';
4
+ import email from '@live-change/email-service';
5
+ import phone from '@live-change/phone-service';
6
+ import passwordAuthentication from '@live-change/password-authentication-service';
7
+ import userIdentification from '@live-change/user-identification-service';
8
+ import identicon from '@live-change/identicon-service';
9
+ import security from '@live-change/security-service';
10
+ import notification from '@live-change/notification-service';
11
+ import upload from '@live-change/upload-service';
12
+ import image from '@live-change/image-service';
13
+ import secretCode from '@live-change/secret-code-service';
14
+ import secretLink from '@live-change/secret-link-service';
15
+ import messageAuthentication from '@live-change/message-authentication-service';
16
+ import googleAuthentication from '@live-change/google-authentication-service';
17
+ import linkedinAuthentication from '@live-change/linkedin-authentication-service';
18
+ import localeSettings from '@live-change/locale-settings-service';
19
+ import geoIp from '@live-change/geoip-service';
20
+ import init from './init.js';
21
+ export { timer, session, user, email, phone, passwordAuthentication, userIdentification, identicon, security, notification, upload, image, secretCode, secretLink, messageAuthentication, googleAuthentication, linkedinAuthentication, localeSettings, geoIp, init };
@@ -0,0 +1,24 @@
1
+ import timer from '@live-change/timer-service';
2
+ import session from '@live-change/session-service';
3
+ import user from '@live-change/user-service';
4
+ import email from '@live-change/email-service';
5
+ import phone from '@live-change/phone-service';
6
+ import passwordAuthentication from '@live-change/password-authentication-service';
7
+ import userIdentification from '@live-change/user-identification-service';
8
+ import identicon from '@live-change/identicon-service';
9
+ import localeSettings from '@live-change/locale-settings-service';
10
+ import geoIp from '@live-change/geoip-service';
11
+ import security from '@live-change/security-service';
12
+ import notification from '@live-change/notification-service';
13
+ import upload from '@live-change/upload-service';
14
+ import image from '@live-change/image-service';
15
+ import secretCode from '@live-change/secret-code-service';
16
+ import secretLink from '@live-change/secret-link-service';
17
+ import messageAuthentication from '@live-change/message-authentication-service';
18
+ import googleAuthentication from '@live-change/google-authentication-service';
19
+ import linkedinAuthentication from '@live-change/linkedin-authentication-service';
20
+ //import backup from '@live-change/backup-service'
21
+ import init from './init.js';
22
+ export { timer, session, user, email, phone, passwordAuthentication, userIdentification, identicon, security, notification, upload, image, secretCode, secretLink, messageAuthentication, googleAuthentication, linkedinAuthentication, localeSettings, geoIp,
23
+ // backup,
24
+ init };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import appConfig from './app.config.js';
2
+ import * as services from './services.list.js';
3
+ for (const serviceConfig of appConfig.services) {
4
+ serviceConfig.module = services[serviceConfig.name];
5
+ }
6
+ appConfig.init = services['init'];
7
+ import { starter } from '@live-change/cli';
8
+ starter(appConfig);
9
+ /*
10
+ import os from 'os'
11
+ const formatMemoryUsage = (data) => `${Math.round(data / 1024 / 1024 * 100) / 100} MB`;
12
+ const formatUptime = (data) => // dd:hh:mm:ss
13
+ `${Math.floor(data / 86400)}:`
14
+ +`${Math.floor(data % 86400 / 3600)}:${Math.floor(data % 3600 / 60)}:${Math.floor(data % 60)}`
15
+ setInterval(() => {
16
+ const memoryData = process.memoryUsage()
17
+ if(typeof gc != 'undefined') {
18
+ console.log("Running GC!")
19
+ gc()
20
+ }
21
+ console.log(`Memory usage:`)
22
+ console.log(` rss: ${formatMemoryUsage(memoryData.rss)}`)
23
+ console.log(` heapTotal: ${formatMemoryUsage(memoryData.heapTotal)}`)
24
+ console.log(` heapUsed: ${formatMemoryUsage(memoryData.heapUsed)}`)
25
+ console.log(` external: ${formatMemoryUsage(memoryData.external)}`)
26
+ console.log(` arrayBuffers: ${formatMemoryUsage(memoryData.arrayBuffers)}`)
27
+ console.log(` os total: ${formatMemoryUsage(os.totalmem())}`)
28
+ console.log(` os free: ${formatMemoryUsage(os.freemem())}`)
29
+ console.log(` os uptime: ${formatUptime(os.uptime())}`)
30
+ console.log(`---------------------------------`)
31
+ }, 5000)
32
+ //*/