@opengis/fcore 0.0.1-beta.0 → 0.0.1-beta.10
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/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.d.ts +3 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.d.ts +4 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +5 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.d.ts.map +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.d.ts +3 -0
- package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
- package/dist/modules/auth/adduser-cli.js +2 -0
- package/dist/modules/auth/passwd-cli.d.ts +3 -0
- package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
- package/dist/modules/auth/passwd-cli.js +2 -0
- package/dist/modules/auth/permission-cli.d.ts +3 -0
- package/dist/modules/auth/permission-cli.d.ts.map +1 -0
- package/dist/modules/auth/permission-cli.js +2 -0
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.d.ts +10 -1
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.d.ts +9 -0
- package/dist/modules/auth/services/change-password.d.ts.map +1 -0
- package/dist/modules/auth/services/change-password.js +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.d.ts +14 -0
- package/dist/modules/auth/services/registration.d.ts.map +1 -0
- package/dist/modules/auth/services/registration.js +1 -0
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts +0 -3
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +3 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.d.ts.map +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.d.ts.map +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
- package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.d.ts.map +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts +2 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +22 -1
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +14 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts +9 -5
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +16 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.d.ts +1 -1
- package/dist/modules/utils/require-admin.d.ts.map +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.d.ts +2 -2
- package/dist/plugins/audit/audit.d.ts.map +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/index.js +1 -1
- package/dist/plugins/audit/services/write-audit.d.ts +2 -2
- package/dist/plugins/audit/services/write-audit.d.ts.map +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
- package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
- package/dist/plugins/auth/get-user-permissions.js +1 -0
- package/dist/plugins/auth/index.d.ts +4 -0
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.d.ts +9 -0
- package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
- package/dist/plugins/auth/verifyUser.js +1 -0
- package/dist/plugins/dictionary.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +4 -7
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.d.ts +9 -4
- package/dist/plugins/logger/index.d.ts.map +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.d.ts +3 -0
- package/dist/plugins/logger/transport.d.ts.map +1 -0
- package/dist/plugins/logger/transport.js +1 -0
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +62 -8
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- package/dist/plugins/resource/services/create.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- package/dist/plugins/resource/services/delete.d.ts +5 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +5 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +259 -0
- package/migrations/20260903130000_move_notes_files_to_admin.sql +18 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +19 -0
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +93 -87
- package/dist/modules/auth/index.d.ts +0 -9
- package/dist/modules/auth/index.d.ts.map +0 -1
- package/dist/modules/auth/index.js +0 -1
- package/dist/modules/auth/services/login.d.ts +0 -10
- package/dist/modules/auth/services/login.d.ts.map +0 -1
- package/dist/modules/auth/services/login.js +0 -1
- package/dist/modules/auth/services/logout.d.ts +0 -9
- package/dist/modules/auth/services/logout.d.ts.map +0 -1
- package/dist/modules/auth/services/logout.js +0 -1
- package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
- package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
- package/dist/modules/auth/services/verifyPassword.js +0 -1
- package/dist/modules/file/index.d.ts +0 -8
- package/dist/modules/file/index.d.ts.map +0 -1
- package/dist/modules/file/index.js +0 -1
- package/dist/modules/resource/index.d.ts +0 -20
- package/dist/modules/resource/index.d.ts.map +0 -1
- package/dist/modules/resource/index.js +0 -1
- package/dist/modules/resource/services/list-children.d.ts +0 -6
- package/dist/modules/resource/services/list-children.d.ts.map +0 -1
- package/dist/modules/resource/services/list-children.js +0 -1
- package/dist/modules/system/index.d.ts +0 -13
- package/dist/modules/system/index.d.ts.map +0 -1
- package/dist/modules/system/index.js +0 -1
- package/dist/modules/utils/get-user-permissions.d.ts +0 -3
- package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
- package/dist/modules/utils/get-user-permissions.js +0 -1
- package/dist/plugins/logger/checkUserAccess.d.ts +0 -11
- package/dist/plugins/logger/checkUserAccess.d.ts.map +0 -1
- package/dist/plugins/logger/checkUserAccess.js +0 -1
- package/dist/plugins/logger/createFileStream.d.ts +0 -3
- package/dist/plugins/logger/createFileStream.d.ts.map +0 -1
- package/dist/plugins/logger/createFileStream.js +0 -1
- package/dist/plugins/logger/createLogger.d.ts +0 -9
- package/dist/plugins/logger/createLogger.d.ts.map +0 -1
- package/dist/plugins/logger/createLogger.js +0 -1
- package/dist/plugins/logger/errorStatus.d.ts +0 -2
- package/dist/plugins/logger/errorStatus.d.ts.map +0 -1
- package/dist/plugins/logger/errorStatus.js +0 -1
- package/dist/plugins/logger/getHooks.d.ts +0 -5
- package/dist/plugins/logger/getHooks.d.ts.map +0 -1
- package/dist/plugins/logger/getHooks.js +0 -1
- package/dist/plugins/logger/getRootDir.d.ts +0 -3
- package/dist/plugins/logger/getRootDir.d.ts.map +0 -1
- package/dist/plugins/logger/getRootDir.js +0 -1
- package/dist/plugins/logger/labels.d.ts +0 -3
- package/dist/plugins/logger/labels.d.ts.map +0 -1
- package/dist/plugins/logger/labels.js +0 -1
- package/dist/plugins/logger/serializers.d.ts +0 -14
- package/dist/plugins/logger/serializers.d.ts.map +0 -1
- package/dist/plugins/logger/serializers.js +0 -1
- package/dist/plugins/logger/timestampWithTimeZone.d.ts +0 -2
- package/dist/plugins/logger/timestampWithTimeZone.d.ts.map +0 -1
- package/dist/plugins/logger/timestampWithTimeZone.js +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|
2
|
+
|
|
3
|
+
CREATE OR REPLACE FUNCTION next_id() RETURNS text
|
|
4
|
+
LANGUAGE sql
|
|
5
|
+
AS $$
|
|
6
|
+
SELECT encode(gen_random_bytes(6), 'hex')::text
|
|
7
|
+
$$;
|
|
8
|
+
|
|
9
|
+
DROP SCHEMA IF EXISTS admin CASCADE;
|
|
10
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
CREATE TABLE IF NOT EXISTS admin.users (
|
|
14
|
+
uid text PRIMARY KEY DEFAULT next_id(),
|
|
15
|
+
login text,
|
|
16
|
+
password_hash text,
|
|
17
|
+
first_name text,
|
|
18
|
+
middle_name text,
|
|
19
|
+
last_name text,
|
|
20
|
+
email text,
|
|
21
|
+
phone text,
|
|
22
|
+
avatar text,
|
|
23
|
+
twofa boolean NOT NULL DEFAULT false,
|
|
24
|
+
enabled boolean DEFAULT true,
|
|
25
|
+
user_personal_code text,
|
|
26
|
+
last_activity_date timestamptz,
|
|
27
|
+
user_type text NOT NULL DEFAULT 'regular',
|
|
28
|
+
created_by text,
|
|
29
|
+
updated_by text,
|
|
30
|
+
created_at timestamp NOT NULL DEFAULT now(),
|
|
31
|
+
updated_at timestamp NOT NULL DEFAULT now(),
|
|
32
|
+
UNIQUE (user_personal_code)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE IF NOT EXISTS admin.user_auth_providers (
|
|
36
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
37
|
+
|
|
38
|
+
uid text NOT NULL
|
|
39
|
+
REFERENCES admin.users(uid)
|
|
40
|
+
ON DELETE CASCADE,
|
|
41
|
+
|
|
42
|
+
provider text NOT NULL,
|
|
43
|
+
provider_user_id text NOT NULL,
|
|
44
|
+
user_code text,
|
|
45
|
+
|
|
46
|
+
email text,
|
|
47
|
+
username text,
|
|
48
|
+
|
|
49
|
+
data jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
50
|
+
|
|
51
|
+
enabled boolean NOT NULL DEFAULT true,
|
|
52
|
+
|
|
53
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
54
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
COMMENT ON TABLE admin.user_auth_providers IS
|
|
58
|
+
'External authentication providers linked to users';
|
|
59
|
+
|
|
60
|
+
COMMENT ON COLUMN admin.user_auth_providers.provider IS
|
|
61
|
+
'Authentication provider: google, microsoft, apple, facebook, telegram, oidc, etc.';
|
|
62
|
+
|
|
63
|
+
COMMENT ON COLUMN admin.user_auth_providers.provider_user_id IS
|
|
64
|
+
'Stable unique user identifier returned by the provider (e.g. OIDC sub)';
|
|
65
|
+
|
|
66
|
+
COMMENT ON COLUMN admin.user_auth_providers.user_code IS
|
|
67
|
+
'Optional external user code/login used by the provider or external system';
|
|
68
|
+
|
|
69
|
+
COMMENT ON COLUMN admin.user_auth_providers.data IS
|
|
70
|
+
'Additional provider-specific user metadata';
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
CREATE UNIQUE INDEX IF NOT EXISTS user_auth_providers_provider_user_uidx
|
|
74
|
+
ON admin.user_auth_providers (provider, provider_user_id);
|
|
75
|
+
|
|
76
|
+
CREATE UNIQUE INDEX IF NOT EXISTS user_auth_providers_uid_provider_uidx
|
|
77
|
+
ON admin.user_auth_providers (uid, provider);
|
|
78
|
+
|
|
79
|
+
CREATE INDEX IF NOT EXISTS user_auth_providers_uid_idx
|
|
80
|
+
ON admin.user_auth_providers (uid);
|
|
81
|
+
|
|
82
|
+
CREATE INDEX IF NOT EXISTS user_auth_providers_user_code_idx
|
|
83
|
+
ON admin.user_auth_providers (user_code);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
CREATE TABLE IF NOT EXISTS admin.roles (
|
|
87
|
+
role_id text PRIMARY KEY DEFAULT next_id(),
|
|
88
|
+
name text,
|
|
89
|
+
enabled boolean,
|
|
90
|
+
info text,
|
|
91
|
+
crea timestamptz DEFAULT date_trunc('seconds', now())
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
CREATE TABLE IF NOT EXISTS admin.user_roles (
|
|
95
|
+
ugr_id text PRIMARY KEY DEFAULT next_id(),
|
|
96
|
+
user_uid text NOT NULL REFERENCES admin.users(uid),
|
|
97
|
+
role_id text NOT NULL REFERENCES admin.roles(role_id),
|
|
98
|
+
expiration date,
|
|
99
|
+
actions text[],
|
|
100
|
+
|
|
101
|
+
created_by text,
|
|
102
|
+
updated_by text,
|
|
103
|
+
created_at timestamp NOT NULL DEFAULT now(),
|
|
104
|
+
updated_at timestamp NOT NULL DEFAULT now(),
|
|
105
|
+
UNIQUE (user_uid, role_id)
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
CREATE TABLE IF NOT EXISTS admin.role_access (
|
|
109
|
+
access_id text PRIMARY KEY DEFAULT next_id(),
|
|
110
|
+
|
|
111
|
+
role_id text REFERENCES admin.roles(role_id),
|
|
112
|
+
user_uid text REFERENCES admin.users(uid),
|
|
113
|
+
scope text,
|
|
114
|
+
actions text[],
|
|
115
|
+
resource text,
|
|
116
|
+
|
|
117
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
118
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
119
|
+
created_at timestamp NOT NULL DEFAULT now(),
|
|
120
|
+
updated_at timestamp NOT NULL DEFAULT now(),
|
|
121
|
+
UNIQUE (resource, user_uid),
|
|
122
|
+
UNIQUE (resource, role_id)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
CREATE TABLE IF NOT EXISTS admin.dictionaries (
|
|
127
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
128
|
+
code varchar(100) NOT NULL UNIQUE,
|
|
129
|
+
name varchar(255) NOT NULL,
|
|
130
|
+
module varchar(50),
|
|
131
|
+
description text,
|
|
132
|
+
source text NOT NULL DEFAULT 'git' CHECK (source IN ('git', 'custom')),
|
|
133
|
+
editable boolean NOT NULL DEFAULT false,
|
|
134
|
+
system boolean NOT NULL DEFAULT false,
|
|
135
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
136
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
137
|
+
created_at timestamp NOT NULL DEFAULT now(),
|
|
138
|
+
updated_at timestamp NOT NULL DEFAULT now()
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
CREATE TABLE IF NOT EXISTS admin.dictionary_items (
|
|
142
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
143
|
+
dictionary_id uuid NOT NULL REFERENCES admin.dictionaries(id) ON DELETE CASCADE,
|
|
144
|
+
code varchar(100) NOT NULL,
|
|
145
|
+
name varchar(255) NOT NULL,
|
|
146
|
+
description text,
|
|
147
|
+
color varchar(20),
|
|
148
|
+
icon varchar(50),
|
|
149
|
+
sort_order integer,
|
|
150
|
+
parent_id uuid REFERENCES admin.dictionary_items(id),
|
|
151
|
+
active boolean NOT NULL DEFAULT true,
|
|
152
|
+
system boolean NOT NULL DEFAULT false,
|
|
153
|
+
metadata jsonb,
|
|
154
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
155
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
156
|
+
created_at timestamp NOT NULL DEFAULT now(),
|
|
157
|
+
updated_at timestamp NOT NULL DEFAULT now(),
|
|
158
|
+
UNIQUE (dictionary_id, code)
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
CREATE TABLE IF NOT EXISTS admin.notes (
|
|
163
|
+
note_id text PRIMARY KEY DEFAULT next_id(),
|
|
164
|
+
resource text NOT NULL,
|
|
165
|
+
resource_id text NOT NULL,
|
|
166
|
+
body text NOT NULL,
|
|
167
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
168
|
+
created_at timestamptz DEFAULT now(),
|
|
169
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
170
|
+
updated_at timestamptz DEFAULT now()
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
CREATE INDEX IF NOT EXISTS admin_notes_resource_idx ON admin.notes(resource, resource_id);
|
|
174
|
+
CREATE INDEX IF NOT EXISTS admin_notes_uid_idx ON admin.notes(created_by);
|
|
175
|
+
|
|
176
|
+
CREATE TABLE IF NOT EXISTS admin.files (
|
|
177
|
+
file_id text PRIMARY KEY DEFAULT next_id(),
|
|
178
|
+
resource text,
|
|
179
|
+
resource_id text,
|
|
180
|
+
uploaded_name text,
|
|
181
|
+
file_type text,
|
|
182
|
+
file_status numeric,
|
|
183
|
+
file_name text,
|
|
184
|
+
size numeric,
|
|
185
|
+
ext text,
|
|
186
|
+
tags text[],
|
|
187
|
+
file_path text,
|
|
188
|
+
verified boolean DEFAULT false,
|
|
189
|
+
resized boolean,
|
|
190
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
191
|
+
created_at timestamptz DEFAULT now(),
|
|
192
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
193
|
+
updated_at timestamptz default now()
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
197
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
198
|
+
|
|
199
|
+
resource text NOT NULL DEFAULT 'system',
|
|
200
|
+
resource_id text,
|
|
201
|
+
|
|
202
|
+
key text NOT NULL,
|
|
203
|
+
value jsonb,
|
|
204
|
+
|
|
205
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
206
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
207
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
208
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
CREATE UNIQUE INDEX IF NOT EXISTS settings_resource_key_uidx
|
|
212
|
+
ON admin.settings (resource, resource_id, key)
|
|
213
|
+
NULLS NOT DISTINCT;
|
|
214
|
+
|
|
215
|
+
CREATE INDEX IF NOT EXISTS settings_resource_idx
|
|
216
|
+
ON admin.settings (resource, resource_id);
|
|
217
|
+
|
|
218
|
+
COMMENT ON TABLE admin.settings IS
|
|
219
|
+
'Application settings linked to a resource or system';
|
|
220
|
+
|
|
221
|
+
COMMENT ON COLUMN admin.settings.resource IS
|
|
222
|
+
'Resource type, e.g. system, user, organization';
|
|
223
|
+
|
|
224
|
+
COMMENT ON COLUMN admin.settings.resource_id IS
|
|
225
|
+
'Resource identifier; NULL for resource-level or system settings';
|
|
226
|
+
|
|
227
|
+
COMMENT ON COLUMN admin.settings.key IS
|
|
228
|
+
'Setting key using dot notation, e.g. map.position.x';
|
|
229
|
+
|
|
230
|
+
COMMENT ON COLUMN admin.settings.value IS
|
|
231
|
+
'Setting value stored as JSONB';
|
|
232
|
+
|
|
233
|
+
CREATE TABLE IF NOT EXISTS admin.audit_log (
|
|
234
|
+
id bigserial PRIMARY KEY,
|
|
235
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
236
|
+
workspace_id bigint,
|
|
237
|
+
user_id varchar(64),
|
|
238
|
+
module varchar(64) NOT NULL,
|
|
239
|
+
resource varchar(128) NOT NULL,
|
|
240
|
+
resource_id varchar(128),
|
|
241
|
+
fields varchar(64)[],
|
|
242
|
+
action varchar(64) NOT NULL,
|
|
243
|
+
request_id varchar(64),
|
|
244
|
+
ip_address inet,
|
|
245
|
+
user_agent text,
|
|
246
|
+
metadata jsonb
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
CREATE TABLE IF NOT EXISTS admin.audit_log_data (
|
|
250
|
+
id bigserial PRIMARY KEY,
|
|
251
|
+
audit_log_id bigint NOT NULL REFERENCES admin.audit_log(id) ON DELETE CASCADE,
|
|
252
|
+
field varchar(128) NOT NULL,
|
|
253
|
+
old_value jsonb,
|
|
254
|
+
new_value jsonb
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
CREATE INDEX IF NOT EXISTS admin_audit_log_created_at_idx ON admin.audit_log (created_at DESC);
|
|
258
|
+
CREATE INDEX IF NOT EXISTS admin_audit_log_resource_idx ON admin.audit_log (module, resource, resource_id, created_at DESC);
|
|
259
|
+
CREATE INDEX IF NOT EXISTS admin_audit_log_data_log_idx ON admin.audit_log_data (audit_log_id);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
+
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
+
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
+
END IF;
|
|
9
|
+
|
|
10
|
+
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
+
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
+
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
+
END IF;
|
|
14
|
+
END
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
18
|
+
ALTER INDEX IF EXISTS crm_notes_uid_idx RENAME TO admin_notes_uid_idx;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
4
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
5
|
+
resource text NOT NULL DEFAULT 'system',
|
|
6
|
+
resource_id text,
|
|
7
|
+
key text NOT NULL,
|
|
8
|
+
value jsonb,
|
|
9
|
+
updated_by text,
|
|
10
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
created_by text,
|
|
12
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
DROP INDEX IF EXISTS settings_resource_key_uidx;
|
|
16
|
+
|
|
17
|
+
CREATE UNIQUE INDEX settings_resource_key_uidx
|
|
18
|
+
ON admin.settings (resource, resource_id, key)
|
|
19
|
+
NULLS NOT DISTINCT;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ALTER TABLE admin.users
|
|
2
|
+
ADD CONSTRAINT users_created_by_fkey
|
|
3
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
4
|
+
ADD CONSTRAINT users_updated_by_fkey
|
|
5
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
6
|
+
|
|
7
|
+
ALTER TABLE admin.user_roles
|
|
8
|
+
ADD CONSTRAINT user_roles_created_by_fkey
|
|
9
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
10
|
+
ADD CONSTRAINT user_roles_updated_by_fkey
|
|
11
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
12
|
+
|
|
13
|
+
ALTER TABLE admin.role_access
|
|
14
|
+
ADD CONSTRAINT role_access_user_uid_fkey
|
|
15
|
+
FOREIGN KEY (user_uid) REFERENCES admin.users(uid) ON DELETE CASCADE,
|
|
16
|
+
ADD CONSTRAINT role_access_created_by_fkey
|
|
17
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
18
|
+
ADD CONSTRAINT role_access_updated_by_fkey
|
|
19
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
20
|
+
|
|
21
|
+
ALTER TABLE admin.dictionaries
|
|
22
|
+
ADD CONSTRAINT dictionaries_created_by_fkey
|
|
23
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
24
|
+
ADD CONSTRAINT dictionaries_updated_by_fkey
|
|
25
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
26
|
+
|
|
27
|
+
ALTER TABLE admin.notes
|
|
28
|
+
ADD CONSTRAINT notes_created_by_fkey
|
|
29
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
30
|
+
ADD CONSTRAINT notes_updated_by_fkey
|
|
31
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
32
|
+
|
|
33
|
+
ALTER TABLE admin.files
|
|
34
|
+
ADD CONSTRAINT files_created_by_fkey
|
|
35
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
36
|
+
ADD CONSTRAINT files_updated_by_fkey
|
|
37
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
38
|
+
|
|
39
|
+
ALTER TABLE admin.settings
|
|
40
|
+
ADD CONSTRAINT settings_created_by_fkey
|
|
41
|
+
FOREIGN KEY (created_by) REFERENCES admin.users(uid) ON DELETE SET NULL,
|
|
42
|
+
ADD CONSTRAINT settings_updated_by_fkey
|
|
43
|
+
FOREIGN KEY (updated_by) REFERENCES admin.users(uid) ON DELETE SET NULL;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
DO $$
|
|
2
|
+
declare
|
|
3
|
+
_password_column_exists boolean;
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('admin.users') IS NOT NULL then
|
|
6
|
+
|
|
7
|
+
select true from pg_attribute where attrelid::regclass::text='admin.users' and attname='password' into _password_column_exists;
|
|
8
|
+
|
|
9
|
+
IF _password_column_exists is true then
|
|
10
|
+
alter table admin.users add column if not exists password_hash text;
|
|
11
|
+
update admin.users set password_hash = password where password is not null and password_hash is null;
|
|
12
|
+
alter table admin.users drop column if exists password;
|
|
13
|
+
END IF;
|
|
14
|
+
|
|
15
|
+
alter table admin.users add column if not exists twofa boolean not null default false;
|
|
16
|
+
|
|
17
|
+
END IF;
|
|
18
|
+
|
|
19
|
+
END
|
|
20
|
+
$$;
|
|
21
|
+
|
|
22
|
+
CREATE OR REPLACE FUNCTION next_id()
|
|
23
|
+
RETURNS text AS
|
|
24
|
+
$BODY$
|
|
25
|
+
DECLARE
|
|
26
|
+
|
|
27
|
+
BEGIN
|
|
28
|
+
return encode(public.gen_random_bytes(6), 'hex');
|
|
29
|
+
END;
|
|
30
|
+
$BODY$
|
|
31
|
+
LANGUAGE plpgsql VOLATILE
|
|
32
|
+
COST 100;
|
package/package.json
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/fcore",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
4
|
-
"description": "Reusable backend foundation for OpenGIS Node.js applications",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"fastify
|
|
61
|
-
"fastify-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@opengis/fcore",
|
|
3
|
+
"version": "0.0.1-beta.10",
|
|
4
|
+
"description": "Reusable backend foundation for OpenGIS Node.js applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"migrations",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./fastify": {
|
|
20
|
+
"types": "./dist/fastify.d.ts",
|
|
21
|
+
"import": "./dist/fastify.js"
|
|
22
|
+
},
|
|
23
|
+
"./migrate": {
|
|
24
|
+
"types": "./dist/migrations/runner.d.ts",
|
|
25
|
+
"import": "./dist/migrations/runner.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"fcore-migrate": "./dist/migrations/cli.js",
|
|
30
|
+
"fcore-adduser": "./dist/modules/auth/adduser-cli.js",
|
|
31
|
+
"fcore-passwd": "./dist/modules/auth/passwd-cli.js",
|
|
32
|
+
"fcore-permission": "./dist/modules/auth/permission-cli.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "node --test --import tsx test/**/*.test.ts",
|
|
39
|
+
"test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
|
|
40
|
+
"dev": "bun ./server.ts",
|
|
41
|
+
"adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
|
|
42
|
+
"passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
|
|
43
|
+
"permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
|
|
44
|
+
"migrate": "node --import tsx src/migrations/cli.ts",
|
|
45
|
+
"migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
|
|
46
|
+
"prepublishOnly": "npm run build",
|
|
47
|
+
"prepublishOnly1": "npm run build && npm test",
|
|
48
|
+
"patch": "npm version patch && git push && npm publish",
|
|
49
|
+
"minor": "npm version minor && git push && npm publish",
|
|
50
|
+
"major": "npm version major && git push && npm publish"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@aws-sdk/client-s3": "3.1125.0",
|
|
57
|
+
"@aws-sdk/lib-storage": "3.1125.0",
|
|
58
|
+
"@fastify/cookie": "11.1.2",
|
|
59
|
+
"@fastify/multipart": "10.1.1",
|
|
60
|
+
"@fastify/passport": "4.0.2",
|
|
61
|
+
"@fastify/rate-limit": "11.2.0",
|
|
62
|
+
"@fastify/session": "11.1.2",
|
|
63
|
+
"@sinclair/typebox": "^0.34.52",
|
|
64
|
+
"apache-crypt": "1.2.6",
|
|
65
|
+
"dotenv": "17.4.2",
|
|
66
|
+
"fastify-session-redis-store": "7.1.2",
|
|
67
|
+
"file-type": "22.0.2",
|
|
68
|
+
"ioredis": "6.0.0",
|
|
69
|
+
"jose": "^6.2.12",
|
|
70
|
+
"otplib": "13.5.0",
|
|
71
|
+
"pg": "8.23.0",
|
|
72
|
+
"pino": "10.3.1",
|
|
73
|
+
"pino-abstract-transport": "3.0.0",
|
|
74
|
+
"qrcode": "1.5.4",
|
|
75
|
+
"sharp": "0.35.4"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"fastify": ">=5.12.1"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@types/node": "22.20.1",
|
|
82
|
+
"@types/passport": "1.0.17",
|
|
83
|
+
"@types/passport-local": "1.0.38",
|
|
84
|
+
"@types/pg": "8.23.1",
|
|
85
|
+
"@types/qrcode": "1.5.6",
|
|
86
|
+
"fastify": "5.12.1",
|
|
87
|
+
"javascript-obfuscator": "5.6.0",
|
|
88
|
+
"tsx": "4.23.13",
|
|
89
|
+
"typescript": "7.0.2",
|
|
90
|
+
"vitest": "4.1.11"
|
|
91
|
+
},
|
|
92
|
+
"license": "UNLICENSED"
|
|
93
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exports the public surface of this FCore module.
|
|
3
|
-
*/
|
|
4
|
-
export * from './route.js';
|
|
5
|
-
export * from './services/login.js';
|
|
6
|
-
export * from './services/logout.js';
|
|
7
|
-
export * from './services/get-current-user.js';
|
|
8
|
-
export * from './services/verify-two-factor.js';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(n,a){var G=b,E=n();while(!![]){try{var M=-parseInt(G(0xf0))/0x1+-parseInt(G(0xf1))/0x2*(-parseInt(G(0xef))/0x3)+parseInt(G(0xf3))/0x4+-parseInt(G(0xed))/0x5*(-parseInt(G(0xee))/0x6)+-parseInt(G(0xf2))/0x7+parseInt(G(0xf5))/0x8+parseInt(G(0xf4))/0x9;if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0xa042b));export*from'./route.js';export*from'./services/login.js';function b(n,a){n=n-0xed;var E=I();var M=E[n];return M;}export*from'./services/logout.js';export*from'./services/get-current-user.js';function I(){var j=['2yhSzzW','7955570TWisAe','2716588wocHai','10002798nEXsme','4887328dsamwf','1380lDMIAz','4878BLwrYU','895710ZYMxHe','1131506EtworE'];I=function(){return j;};return I();}export*from'./services/verify-two-factor.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ContextDependencies } from "../../../context.js";
|
|
2
|
-
export default function login({ ip, login, password }: {
|
|
3
|
-
ip: string;
|
|
4
|
-
login: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}, { config, pg, logger, redis, }: Pick<ContextDependencies, "config" | "pg" | "logger" | "redis">): Promise<{
|
|
7
|
-
user: any;
|
|
8
|
-
redirectUrl: string;
|
|
9
|
-
}>;
|
|
10
|
-
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/login.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,wBAA8B,KAAK,CACjC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EACxE,EACE,MAAM,EACN,EAAE,EACF,MAAM,EACN,KAAK,GACN,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;;;GAiCnE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function I(){const l=['wYmYw','base','26VViCVw','35147532liTDOg','twofa','366hmFyAW','IKjRH','11yedXQz','5728lYGmQw','empty\x20redis','login','auth','8057OwutIT','empty\x20pg','txIOR','vHUHX','101261ydaYld','12461670vuRlYb','48jztYAY','afterLogin','twoFactor','password','195840QfZyKU','LItWM','logger','10245xKcDwZ','metrics','17446320GEAkgg','LwjOv','user.login','empty\x20user','link'];I=function(){return l;};return I();}(function(n,a){const k=b,M=n();while(!![]){try{const X=-parseInt(k(0xdc))/0x1*(-parseInt(k(0xee))/0x2)+-parseInt(k(0xe2))/0x3*(parseInt(k(0xde))/0x4)+-parseInt(k(0xe5))/0x5*(parseInt(k(0xd1))/0x6)+-parseInt(k(0xd8))/0x7*(-parseInt(k(0xd4))/0x8)+-parseInt(k(0xe7))/0x9+-parseInt(k(0xdd))/0xa+-parseInt(k(0xd3))/0xb*(-parseInt(k(0xef))/0xc);if(X===a)break;else M['push'](M['shift']());}catch(G){M['push'](M['shift']());}}}(I,0xee65a));import E from'./verifyPassword.js';function b(n,a){n=n-0xd0;const E=I();let M=E[n];return M;}export default async function login({ip:M,login:X,password:G},{config:j,pg:u,logger:Y,redis:g}){const p=b,e={'LwjOv':function(B,A){return B(A);},'vHUHX':p(0xd5),'wYmYw':function(B,A,r){return B(A,r);},'LItWM':p(0xea),'txIOR':p(0xe9),'IKjRH':function(B,A){return B||A;}};if(!u)throw e[p(0xe8)](Error,p(0xd9));if(!g)throw Error(e[p(0xdb)]);const h={};h[p(0xd6)]=X,h[p(0xe1)]=G,h['ip']=M;const Z={};Z['pg']=u,Z[p(0xe4)]=Y;const {user:H}=await e[p(0xec)](E,h,Z);if(!H)throw new Error(e[p(0xe3)]);Y[p(0xe6)](e[p(0xda)]);const t=H[p(0xd0)]?j[p(0xd7)][p(0xeb)]?.[p(0xe0)]?.[p(0xd6)]:j[p(0xd7)][p(0xeb)]?.[p(0xed)][p(0xdf)];return{'user':H,'redirectUrl':e[p(0xd2)](t,'/')};}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements the logout application service for its module.
|
|
3
|
-
*/
|
|
4
|
-
import type { AppContext, User } from "../../../context.js";
|
|
5
|
-
export default function logout(params: {
|
|
6
|
-
sessionId?: string;
|
|
7
|
-
user?: User;
|
|
8
|
-
}, ctx: AppContext): Promise<void>;
|
|
9
|
-
//# sourceMappingURL=logout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/logout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,wBAA8B,MAAM,CAClC,MAAM,EAAE;IACN,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,IAAI,CAAC,CAQf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(n,a){var u=b,E=n();while(!![]){try{var M=parseInt(u(0xda))/0x1+-parseInt(u(0xea))/0x2+-parseInt(u(0xed))/0x3*(parseInt(u(0xd9))/0x4)+parseInt(u(0xee))/0x5+parseInt(u(0xe4))/0x6*(parseInt(u(0xdf))/0x7)+parseInt(u(0xe8))/0x8+-parseInt(u(0xe5))/0x9*(parseInt(u(0xe9))/0xa);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x2543f));function I(){var g=['414BZxpBd','action','sessionId','1080096FQsjlx','26930SSDcRD','282040ZVcYmA','audit','FUSCg','69186ReSVnv','401830yHknaU','logout','auth','36ohjxVf','178378yIjimf','module','resource','user','resourceId','9149BpkbRy','write','userId','DHBRN','session','1062opErUh'];I=function(){return g;};return I();}function b(n,a){n=n-0xd7;var E=I();var M=E[n];return M;}export default async function logout(E,M){var Y=b,X={};X[Y(0xec)]=Y(0xd8),X[Y(0xe2)]=Y(0xe3);var G=X,j={};j[Y(0xdb)]=G[Y(0xec)],j[Y(0xdc)]=G[Y(0xe2)],j[Y(0xde)]=E[Y(0xe7)],j[Y(0xe6)]=Y(0xd7),j[Y(0xe1)]=E[Y(0xdd)]?.['id'],await M[Y(0xeb)]?.[Y(0xe0)]?.(j);}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ContextDependencies } from "../../../context.js";
|
|
2
|
-
export declare function hashPassword(password: string): string;
|
|
3
|
-
export declare function verifyPasswordWithoutSalt(password: string, stored: string): boolean;
|
|
4
|
-
export default function verifyPassword({ login, password, ip, }: {
|
|
5
|
-
login: string;
|
|
6
|
-
password: string;
|
|
7
|
-
ip: string;
|
|
8
|
-
}, { pg, logger }: Pick<ContextDependencies, "pg" | "logger">): Promise<{
|
|
9
|
-
user: any;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=verifyPassword.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/verifyPassword.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAQ,MAAM,qBAAqB,CAAC;AAOhE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAST;AAED,wBAA8B,cAAc,CAC1C,EACE,KAAK,EACL,QAAQ,EACR,EAAE,GACH,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,EACD,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,QAAQ,CAAC;;GAmE3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(n,a){const O=b,E=n();while(!![]){try{const M=-parseInt(O(0x17c))/0x1*(-parseInt(O(0x189))/0x2)+parseInt(O(0x1aa))/0x3*(-parseInt(O(0x175))/0x4)+parseInt(O(0x1b1))/0x5+parseInt(O(0x1a7))/0x6+-parseInt(O(0x19d))/0x7+parseInt(O(0x1a0))/0x8+parseInt(O(0x199))/0x9*(-parseInt(O(0x18d))/0xa);if(M===a)break;else E['push'](E['shift']());}catch(X){E['push'](E['shift']());}}}(I,0x3afbd));import s from'apache-crypt';import N from'node:crypto';function b(n,a){n=n-0x168;const E=I();let M=E[n];return M;}import{BadRequestError}from'../../../errors.js';function md5(a){const q=b,E={};E[q(0x18a)]=q(0x184),E[q(0x17d)]=q(0x16b);const M=E;return N[q(0x18b)](M[q(0x18a)])[q(0x1a6)](a)[q(0x19f)](M[q(0x17d)]);}export function hashPassword(a){const K=b,E={};E[K(0x17e)]=K(0x16b);const M=E,X=N[K(0x17f)](0x10)[K(0x18c)](M[K(0x17e)]),G=N[K(0x194)](a,X,0x40)[K(0x18c)](K(0x16b));return K(0x185)+X+'$'+G;}export function verifyPasswordWithoutSalt(a,E){const d=b,M={};M[d(0x179)]=d(0x187);const X=M,[G,j,u]=E[d(0x191)]('$');if(G!==X[d(0x179)]||!j||!u)return![];const Y=N[d(0x194)](a,j,0x40),g=Buffer[d(0x1ab)](u,d(0x16b));return g[d(0x19a)]===Y[d(0x19a)]&&N[d(0x195)](g,Y);}export default async function verifyPassword({login:e,password:h,ip:Z},{pg:H,logger:t}){const Q=b,B={'bPYdX':Q(0x19b),'ZfXSv':Q(0x188),'hCoDy':Q(0x1af),'QsgRF':function(P,J){return P===J;},'iPwxE':function(P,J){return P!==J;},'lrhLF':Q(0x16d),'KpJOM':Q(0x182),'tAFAr':Q(0x180),'gezlq':Q(0x172),'UDbKd':function(P,J){return P===J;},'oAWAj':Q(0x18f),'BtnwV':Q(0x1a1),'JEEjY':function(P,J,m){return P(J,m);},'oYadY':Q(0x198),'Cinpu':Q(0x177),'rGede':function(P,J){return P===J;},'tbtiY':function(P,J){return P<J;},'umpxn':function(P,J){return P(J);},'pfOUP':function(P,J){return P+J;},'wVIAc':function(P,J){return P===J;}};if(!H)throw new Error(Q(0x19e));if(!e||B[Q(0x168)](e,''))throw new BadRequestError(Q(0x19b));if(!h||B[Q(0x168)](h,'')){if(B[Q(0x16e)](B[Q(0x190)],B[Q(0x192)]))throw new BadRequestError(B[Q(0x176)]);else throw new a(B[Q(0x17a)]);}const A=B[Q(0x178)],r=await H[Q(0x16a)](A,[e])[Q(0x170)](J=>J[Q(0x1a3)]?.[0x0]);if(!r){if(B[Q(0x1a4)](Q(0x1a2),Q(0x186))){const m={...M};m[Q(0x16c)]=X,m[Q(0x174)]=G;const T={};return T[Q(0x1a8)]=m,T;}else{const m=B[Q(0x183)],T={};T[Q(0x171)]=m,T[Q(0x19c)]=e,T['ip']=Z,t[Q(0x17b)](B[Q(0x1ac)],T);throw new BadRequestError(m);}}if(!r[Q(0x174)]){if(B[Q(0x16e)](B[Q(0x1ad)],Q(0x1a1))){const z=B[Q(0x1b0)],w={};w[Q(0x171)]=z,w[Q(0x19c)]=G,w['ip']=j,X[Q(0x17b)](B[Q(0x1ac)],w);throw new u(z);}else{const z=B[Q(0x1a9)](verifyPasswordWithoutSalt,h,r[Q(0x16c)]);if(!z){if(B[Q(0x1a4)](B[Q(0x169)],B[Q(0x16f)])){const o=Q(0x18f),C={};C[Q(0x171)]=o,C[Q(0x19c)]=G,C['ip']=j,X[Q(0x17b)](B[Q(0x1ac)],C);throw new u(o);}else{const o=B[Q(0x1b0)],C={};C[Q(0x171)]=o,C[Q(0x19c)]=e,C['ip']=Z,t[Q(0x17b)](B[Q(0x1ac)],C);throw new BadRequestError(o);}}const w={...r};w[Q(0x16c)]=undefined,w[Q(0x174)]=undefined;const R={};return R[Q(0x1a8)]=w,R;}}if(B[Q(0x1a5)](r[Q(0x18e)],!![])){const S=await H[Q(0x16a)](Q(0x1ae),[h,r[Q(0x174)]])[Q(0x170)](W=>W[Q(0x1a3)]?.[0x0]?.[Q(0x173)]);if(r[Q(0x16c)]===S){const W={...r};W[Q(0x16c)]=undefined,W[Q(0x174)]=undefined;const f={};return f[Q(0x1a8)]=W,f;}const c=B[Q(0x1b0)],U={};U[Q(0x171)]=c,U[Q(0x19c)]=e,U['ip']=Z,t[Q(0x17b)](Q(0x1af),U);throw new BadRequestError(c);}let k='';for(let x=0x0;B[Q(0x196)](x,0xa);x+=0x1){k=B[Q(0x197)](md5,B[Q(0x181)](B[Q(0x181)](h,k),r[Q(0x174)]));}k=s(k,r[Q(0x174)]);if(B[Q(0x193)](r[Q(0x16c)],k)){const D={...r};D[Q(0x16c)]=undefined,D[Q(0x174)]=undefined;const L={};return L[Q(0x1a8)]=D,L;}const p=B[Q(0x1b0)],l={};l[Q(0x171)]=p,l[Q(0x19c)]=e,l['ip']=Z,t[Q(0x17b)](Q(0x1af),l);throw new BadRequestError(p);}function I(){const v=['length','not\x20enough\x20params:\x20login','login','912429HlLZcr','empty\x20pg','digest','3259344GZXXct','LGMgd','VGeNQ','rows','UDbKd','rGede','update','2229576AwjyvR','user','JEEjY','721065FTdgVO','from','hCoDy','BtnwV','SELECT\x20public.crypt($1,\x20$2)','auth/warn','ZfXSv','671605XOYYZV','QsgRF','oYadY','query','hex','password','WHqzY','iPwxE','Cinpu','then','error','select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password,\x20salt\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201','crypt','salt','4TdujsY','tAFAr','DKXuX','gezlq','sGpFf','bPYdX','file','166hELQfz','oTOhV','WeCdv','randomBytes','not\x20enough\x20params:\x20password','pfOUP','Ljyph','oAWAj','md5','scrypt$','vuiur','scrypt','Wrong\x20password','5506PjFgYm','jQWus','createHash','toString','3790170EUPgMT','password_new_hash_algorithm','user\x20not\x20found','lrhLF','split','KpJOM','wVIAc','scryptSync','timingSafeEqual','tbtiY','umpxn','LNgfh','18OKQhlb'];I=function(){return v;};return I();}
|