@opengis/fcore 0.0.1-beta.2 → 0.0.1-beta.21
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 +2 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +2 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +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.js +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.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 +23 -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 +15 -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 +17 -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.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.js +1 -1
- package/dist/plugins/audit/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +1 -1
- package/dist/plugins/audit/index.js +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 +3 -6
- 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.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- 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 +73 -15
- 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 +9 -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 +9 -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 +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.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +14 -0
- package/dist/type.d.ts.map +1 -1
- package/migrations/20260903120000_core_schema.sql +27 -21
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +93 -88
- 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/LICENSE
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Copyright (c) OpenGIS. All rights reserved.
|
|
2
|
-
|
|
3
|
-
Proprietary and confidential.
|
|
1
|
+
Copyright (c) OpenGIS. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Proprietary and confidential.
|
package/README.md
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
# @opengis/fcore
|
|
2
|
-
|
|
3
|
-
Reusable backend foundation for OpenGIS Node.js applications: config, typed application context, PostgreSQL, Redis, S3 file storage, audit, trusted Resource CRUD, Core modules, Fastify integration and SQL migration runner.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @opengis/fcore
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Bootstrap
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { createFCore } from '@opengis/fcore';
|
|
15
|
-
import resources from './resources/index.js';
|
|
16
|
-
|
|
17
|
-
export const ctx = await createFCore({ resources });
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import Fastify from 'fastify';
|
|
22
|
-
import fcoreFastify from '@opengis/fcore/fastify';
|
|
23
|
-
import { ctx } from './app.js';
|
|
24
|
-
|
|
25
|
-
const app = Fastify();
|
|
26
|
-
await app.register(fcoreFastify, { ctx });
|
|
27
|
-
await app.listen({ port: ctx.config.port });
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Resource
|
|
31
|
-
|
|
32
|
-
All dynamic table/column identifiers come from registered `ResourceContract` metadata. Values are SQL parameters.
|
|
33
|
-
|
|
34
|
-
## Migrations
|
|
35
|
-
|
|
36
|
-
Project SQL files stay in `./migrations`. Build the package/application, then run `fcore-migrate` or import `runMigrations()`.
|
|
37
|
-
|
|
38
|
-
## Module service convention
|
|
39
|
-
|
|
40
|
-
Module services are plain async functions with the canonical `service(params, ctx)` signature. `ctx` is passed explicitly from `fastify.ts` to each module `route.ts`; there is no `service.ts` or `createService()` factory.
|
|
41
|
-
|
|
42
|
-
## Structure
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
@opengis/fcore
|
|
46
|
-
├── src/
|
|
47
|
-
│ ├── plugins/
|
|
48
|
-
│ │ ├── logger/
|
|
49
|
-
│ │ ├── redis/
|
|
50
|
-
│ │ ├── pg/
|
|
51
|
-
│ │ ├── file/
|
|
52
|
-
│ │ ├── audit/
|
|
53
|
-
│ │ └── resource/
|
|
54
|
-
│ ├── modules/
|
|
55
|
-
│ │ ├── auth/
|
|
56
|
-
│ │ ├── access/
|
|
57
|
-
│ │ ├── resource/
|
|
58
|
-
│ │ ├── file/
|
|
59
|
-
│ │ ├── template/
|
|
60
|
-
│ │ └── system/
|
|
61
|
-
│ ├── migrations/
|
|
62
|
-
│ ├── config.ts # loadConfig
|
|
63
|
-
│ ├── context.ts # createContext, set, get
|
|
64
|
-
│ ├── errors.ts # standard Errors
|
|
65
|
-
│ ├── fastify.ts # fastify Plugins
|
|
66
|
-
│ ├── fcore.ts # createFcore
|
|
67
|
-
│ └── index.ts # export type, methods, etc
|
|
68
|
-
├── test/
|
|
69
|
-
├── engineering/
|
|
70
|
-
├── package.json
|
|
71
|
-
└── tsconfig.json
|
|
1
|
+
# @opengis/fcore
|
|
2
|
+
|
|
3
|
+
Reusable backend foundation for OpenGIS Node.js applications: config, typed application context, PostgreSQL, Redis, S3 file storage, audit, trusted Resource CRUD, Core modules, Fastify integration and SQL migration runner.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @opengis/fcore
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Bootstrap
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createFCore } from '@opengis/fcore';
|
|
15
|
+
import resources from './resources/index.js';
|
|
16
|
+
|
|
17
|
+
export const ctx = await createFCore({ resources });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import Fastify from 'fastify';
|
|
22
|
+
import fcoreFastify from '@opengis/fcore/fastify';
|
|
23
|
+
import { ctx } from './app.js';
|
|
24
|
+
|
|
25
|
+
const app = Fastify();
|
|
26
|
+
await app.register(fcoreFastify, { ctx });
|
|
27
|
+
await app.listen({ port: ctx.config.port });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Resource
|
|
31
|
+
|
|
32
|
+
All dynamic table/column identifiers come from registered `ResourceContract` metadata. Values are SQL parameters.
|
|
33
|
+
|
|
34
|
+
## Migrations
|
|
35
|
+
|
|
36
|
+
Project SQL files stay in `./migrations`. Build the package/application, then run `fcore-migrate` or import `runMigrations()`.
|
|
37
|
+
|
|
38
|
+
## Module service convention
|
|
39
|
+
|
|
40
|
+
Module services are plain async functions with the canonical `service(params, ctx)` signature. `ctx` is passed explicitly from `fastify.ts` to each module `route.ts`; there is no `service.ts` or `createService()` factory.
|
|
41
|
+
|
|
42
|
+
## Structure
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
@opengis/fcore
|
|
46
|
+
├── src/
|
|
47
|
+
│ ├── plugins/
|
|
48
|
+
│ │ ├── logger/
|
|
49
|
+
│ │ ├── redis/
|
|
50
|
+
│ │ ├── pg/
|
|
51
|
+
│ │ ├── file/
|
|
52
|
+
│ │ ├── audit/
|
|
53
|
+
│ │ └── resource/
|
|
54
|
+
│ ├── modules/
|
|
55
|
+
│ │ ├── auth/
|
|
56
|
+
│ │ ├── access/
|
|
57
|
+
│ │ ├── resource/
|
|
58
|
+
│ │ ├── file/
|
|
59
|
+
│ │ ├── template/
|
|
60
|
+
│ │ └── system/
|
|
61
|
+
│ ├── migrations/
|
|
62
|
+
│ ├── config.ts # loadConfig
|
|
63
|
+
│ ├── context.ts # createContext, set, get
|
|
64
|
+
│ ├── errors.ts # standard Errors
|
|
65
|
+
│ ├── fastify.ts # fastify Plugins
|
|
66
|
+
│ ├── fcore.ts # createFcore
|
|
67
|
+
│ └── index.ts # export type, methods, etc
|
|
68
|
+
├── test/
|
|
69
|
+
├── engineering/
|
|
70
|
+
├── package.json
|
|
71
|
+
└── tsconfig.json
|
|
72
72
|
```
|
package/dist/config.d.ts
CHANGED
|
@@ -55,16 +55,8 @@ export interface FCoreConfig {
|
|
|
55
55
|
sessionTimeout: number;
|
|
56
56
|
cookieName: string;
|
|
57
57
|
jwtSecret: string;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
login: string;
|
|
61
|
-
afterLogin?: string;
|
|
62
|
-
};
|
|
63
|
-
twoFactor?: {
|
|
64
|
-
login: string;
|
|
65
|
-
afterLogin?: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
58
|
+
redirect?: string;
|
|
59
|
+
twoFactorRedirect?: string;
|
|
68
60
|
cookieOptions: {
|
|
69
61
|
domain?: string;
|
|
70
62
|
path?: string;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,KAAK,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAIvD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QACT,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE;QACN,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,EAAE,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,EAAE,EAAE;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,KAAK,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAIvD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QACT,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE;QACN,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,EAAE,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,EAAE,EAAE;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,EAAE;YACb,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,MAAM,CAAC,EAAE,OAAO,CAAC;YACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;SAC5C,CAAC;KACH,CAAC;CACH;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAItC;AAED,wBAAgB,UAAU,CAAC,SAAS,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAgG5E;AACD,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import'dotenv/config';function r(n,k){n=n-0x1b3;const Z=g();let K=Z[n];return K;}function g(){const d=['false','password','split','map','us-east-1','session_user_auth','0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','true','logger'];g=function(){return d;};return g();}const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function required(n){const k=process.env[n];if(!k)throw new Error('Missing\x20environment\x20variable:\x20'+n);return k;}export function loadConfig(n={}){const K=r,k={'env':process.env.NODE_ENV??'development','debug':process.env.DEBUG==='true','port':Number(process.env.PORT??0xbb8),'maxFileSize':+(process.env.MAX_FILE_SIZE||0x200),'rateLimit':{'disabled':process.env.RATE_LIMIT===K(0x1b3),'max':+(process.env.RATE_LIMIT_MAX||0x64),'timeWindow':+(process.env.RATE_LIMIT_TIME_WINDOW||0xea60)},'storagePath':process.env.STORAGE_PATH??'./storage','redactionList':(process.env.REDACTION_LIST||K(0x1b4))[K(0x1b5)](','),'logger':{'level':process.env.LOG_LEVEL??'info','responses':process.env.LOG_RESPONSES==='true'?!![]:![],'responseCodes':process.env.LOG_RESPONSE_STATUS_CODES?process.env.LOG_RESPONSE_STATUS_CODES['split'](',')[K(0x1b6)](Z=>Z-0x0):DEFAULT_LOG_RESPONSE_STATUS_CODES,'directory':process.env.LOG_DIRECTORY||process['cwd']()+'/log'},'pg':{'host':process.env.PG_HOST??'localhost','port':Number(process.env.PG_PORT??0x1538),'database':process.env.PG_DATABASE??'','user':process.env.PG_USER??'','password':process.env.PG_PASSWORD??''},'redis':{'host':process.env.REDIS_HOST??'','port':Number(process.env.REDIS_PORT??0x18eb),'password':process.env.REDIS_PASSWORD,'lazyConnect':!![],'db':process.env.REDIS_DB?Number(process.env.REDIS_DB):undefined},'s3':{'endpoint':process.env.S3_ENDPOINT,'region':process.env.S3_REGION??K(0x1b7),'bucket':process.env.S3_BUCKET??'','accessKey':process.env.S3_ACCESS_KEY,'secretKey':process.env.S3_SECRET_KEY,'folder':process.env.S3_FOLDER,'forcePathStyle':process.env.S3_FORCE_PATH_STYLE!=='false','tokenSecret':process.env.FILE_TOKEN_SECRET,'tokenTtl':Number(process.env.FILE_TOKEN_TTL??0xe10)},'auth':{'accessToken':process.env.AUTH_ACCESS_TOKEN||'Ch7QR4e73Jg0wx0xOjm','user':process.env.AUTH_USER?JSON['parse'](process.env.AUTH_USER):undefined,'sessionTimeout':+(process.env.AUTH_SESSION_TIMEOUT||0x258),'secret':process.env.AUTH_SECRET??'x5y30KBsEKCENT04tu6549Vxx3No1ztJ2q2K8r79S59420RaZ5','cookieName':process.env.AUTH_COOKIE_NAME??K(0x1b8),'jwtSecret':process.env.AUTH_JWT_SECRET??K(0x1b9),'redirect':process.env.AUTH_REDIRECT??'/','twoFactorRedirect':process.env.AUTH_TWOFACTOR_REDIRECT??'/','cookieOptions':process.env.AUTH_COOKIE_OPTIONS_DOMAIN?{'domain':process.env.AUTH_COOKIE_OPTIONS_DOMAIN,'path':process.env.AUTH_COOKIE_OPTIONS_PATH||'/','httpOnly':Boolean(process.env.AUTH_COOKIE_OPTIONS_HTTP_ONLY||'true'),'secure':Boolean(process.env.AUTH_COOKIE_OPTIONS_SECURE||'true'),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&['lax','strict','none']['includes'](process.env.AUTH_COOKIE_OPTIONS_SAME_SITE)?process.env.AUTH_COOKIE_OPTIONS_SAME_SITE:Boolean(process.env.AUTH_COOKIE_OPTIONS_SAME_SITE||K(0x1ba))}:{'path':'/','httpOnly':!![],'secure':![],'sameSite':!![]}}};return{...k,...n,'logger':{...k[K(0x1bb)],...n['logger']},'pg':{...k['pg'],...n['pg']},'redis':{...k['redis'],...n['redis']},'s3':{...k['s3'],...n['s3']},'auth':{...k['auth'],...n['auth']}};}export{required as requireEnv};
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let defaultContext;function g(){const K=['Application\x20context\x20is\x20not\x20initialized','end','logger'];g=function(){return K;};return g();}export function setContext(n){defaultContext=n;}export function getContext(){const k=r;if(!defaultContext)throw new Error(k(0x1e3));return defaultContext;}function r(n,k){n=n-0x1e3;const Z=g();let K=Z[n];return K;}export function createContext(n){return{...n,async 'close'(){const Z=r;await Promise['allSettled']([n['redis']?.['close'](),n['pg']?.[Z(0x1e4)]()]),await n[Z(0x1e5)]['close']();}};}
|
package/dist/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var J=r;export class FCoreError extends Error{['code'];['statusCode'];['details'];constructor(n,k,Z=0x1f4,K){var d=r;super(k),this['code']=n,this['statusCode']=Z,this[d(0x1b8)]=K,this['name']=new.target.name;}}function r(n,k){n=n-0x1b8;var Z=g();var K=Z[n];return K;}export class BadRequestError extends FCoreError{constructor(n,k){super('BAD_REQUEST_ERROR',n,0x190,k);}}export class UnauthorizedError extends FCoreError{constructor(n='Authentication\x20required'){super('UNAUTHORIZED',n,0x191);}}export class ForbiddenError extends FCoreError{constructor(n=J(0x1b9)){super('FORBIDDEN',n,0x193);}}export class NotFoundError extends FCoreError{constructor(n=J(0x1ba)){super('NOT_FOUND',n,0x194);}}export class ConflictError extends FCoreError{constructor(n='Conflict'){super('CONFLICT',n,0x199);}}function g(){var l=['details','Access\x20denied','Not\x20found','Operation\x20is\x20not\x20configured','UNSUPPORTED'];g=function(){return l;};return g();}export class ValidationError extends FCoreError{constructor(n,k){super('VALIDATION_ERROR',n,0x1a6,k);}}export class UnsupportedError extends FCoreError{constructor(n=J(0x1bb)){var B=J;super(B(0x1bc),n,0x1f5);}}
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { type FastifyPluginAsync } from "fastify";
|
|
2
2
|
import type { AppContext } from "./context.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const _default: FastifyPluginAsync<FCoreFastifyOptions>;
|
|
7
|
-
export default _default;
|
|
3
|
+
export type FCoreApiModule = "auth" | "resource" | "file" | "system";
|
|
4
|
+
export default function fcoreFastify(ctx: AppContext, modules?: readonly FCoreApiModule[]): FastifyPluginAsync;
|
|
8
5
|
//# sourceMappingURL=fastify.d.ts.map
|
package/dist/fastify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY/C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAYrE,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,GAClC,kBAAkB,CA8IpB"}
|
package/dist/fastify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import n from'fastify-plugin';import{FCoreError}from'./errors.js';import{authRoutes}from'./modules/auth/route.js';import{fileRoutes}from'./modules/file/route.js';import{resourceRoutes}from'./modules/resource/route.js';import{systemRoutes}from'./modules/system/route.js';import{createSessionStore}from'./plugins/auth/index.js';function r(n,k){n=n-0xc0;const Z=g();let K=Z[n];return K;}import{ForbiddenError}from'./errors.js';import{jwtVerifyToken}from'./plugins/jwt.js';function urlencodedContentParser(k,Z,K){const d=decodeURIComponent(Z['toString']())['split']('&')['reduce']((J,B)=>{const [l,f]=B['split']('=');return{...J,[l]:f};},{});K(null,d);}export default function fcoreFastify(k,Z){return n(async K=>{const O=r;K['decorate']('ctx',k);const {config:d}=k,J=new Map();K[O(0xc0)]('onRoute',l=>{const m=O,f=l['schema'],R=Array['isArray'](l['method'])?l['method']:[l['method']];for(const Q of R){if(Q==='HEAD')continue;const a={'method':Q,'endpoint':l['url'],'package':f?.['package']??m(0xc1),'tags':f?.['tags']??[],'summary':f?.['summary']??'','description':f?.['description']??'','access':f?.[m(0xc2)]??m(0xc3),'permissions':f?.['permissions']??[]};J['set'](Q+'\x20'+l['url'],a);}}),K['addHook']('preHandler',async l=>{const p=O;if(l['routeOptions']['url']==='*')return!![];const f=J['get'](l[p(0xc4)]+'\x20'+l['routeOptions']['url']),R=!l['user']&&process[p(0xc5)]==='win32'&&k['config']?.[p(0xc6)]?.['user']?k['config']?.['auth']?.['user']:null,Q=l['raw']['headers']?.['authorization'],a=Q?.['startsWith']('Bearer\x20')?Q['slice'](0x7):null,H=l['user']??(a?await jwtVerifyToken(a):R);!l['user']&&a&&process.env.AUTH_JWT_SECRET&&(l['user']=await jwtVerifyToken(a));if(!f?.['access'])throw new Error(p(0xc7));if(f['access']===p(0xc3))return!![];if(!H)throw new ForbiddenError(p(0xc8));if(f['access']==='user'&&!f['permissions']?.['length'])return!![];if(H['type']=='admin')return!![];if(f[p(0xc2)]==='admin')throw new ForbiddenError('Admin\x20access\x20required');for(const A of f[p(0xc9)]){const I=A?.[p(0xca)]('$resource',l['params']['resource']??'');if(!H['permissions']?.['includes'](I))throw new ForbiddenError('Missing\x20permission:\x20'+I);}return!![];}),await createSessionStore(K,k),await K['register'](import('@fastify/multipart'),{'limits':{'fileSize':d['maxFileSize']*0x400*0x400}}),K[O(0xcb)]((l,f,R)=>{const C=O;if(l instanceof FCoreError||l['code']===C(0xcc)||l[C(0xcd)]<0x1f4)return l[C(0xcd)]<0x1f4&&k['logger']['warn'](l),R['code'](l['statusCode'])['send']({'error':l[C(0xce)],'message':l[C(0xcf)],'details':l[C(0xd0)]});return k['logger']['error'](l),(d['debug']||process.env.NODE_ENV==='test'||process.env.VITEST)&&console['error'](l),R[C(0xce)](0x1f4)['send']({'error':'INTERNAL_ERROR','message':C(0xd1)});});const B=l=>!Z||Z[O(0xd2)](l);if(B('auth'))await K['register'](authRoutes(k));if(B('resource'))await K['register'](resourceRoutes(k));if(B('file'))await K[O(0xd3)](fileRoutes(k));if(B('system'))await K['register'](systemRoutes(k,J));K[O(0xd4)]('application/x-www-form-urlencoded',{'parseAs':'buffer'},urlencodedContentParser),!d['rateLimit']?.[O(0xd5)]?K['register'](import(O(0xd6)),{'max':d['rateLimit']?.['max']||0x64,'timeWindow':d[O(0xd7)]?.['timeWindow']||0xea60,'hook':O(0xd8),'global':!![],'keyGenerator':l=>(l['user']?.['id']||l['ip'])+'-'+l['raw']['url'][O(0xd9)]('?')[0x0]}):console['log']('⚠️\x20rate\x20limit\x20is\x20disabled');});}function g(){const T=['addHook','fcore','access','public','method','platform','auth','Route\x20access\x20not\x20defined','User\x20required','permissions','replace','setErrorHandler','FST_ERR_VALIDATION','statusCode','code','message','details','Internal\x20server\x20error','includes','register','addContentTypeParser','disabled','@fastify/rate-limit','rateLimit','preHandler','split'];g=function(){return T;};return g();}
|
package/dist/fcore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';function g(){const a=['accessKey','secretKey','tokenSecret','tokenTtl','resources'];g=function(){return a;};return g();}import{createAudit,createDatabase,createDictionary,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';function r(n,k){n=n-0x1d7;const Z=g();let K=Z[n];return K;}export async function createFCore(n={}){const Q=r,k=loadConfig(n['config']),Z=createRedis(k['redis']),K=createLogger(),d=createDatabase(k['pg']),J=createFileS3({'endpoint':k['s3']['endpoint'],'region':k['s3']['region'],'bucket':k['s3']['bucket'],'accessKey':k['s3'][Q(0x1d7)],'secretKey':k['s3'][Q(0x1d8)],'folder':k['s3']['folder'],'forcePathStyle':k['s3']['forcePathStyle'],'tokenSecret':k['s3'][Q(0x1d9)],'tokenTtl':k['s3'][Q(0x1da)]}),B=createAudit({'pg':d,'logger':K}),l=createDictionary({'pg':d,'dictionaries':n['dictionaries']}),f=createResource({'pg':d,'logger':K,'audit':B,'dictionary':l,'file':J});n['resources']?.['length']&&f['register'](n[Q(0x1db)]);const R=createContext({'config':k,'logger':K,'redis':Z,'pg':d,'file':J,'resource':f,'audit':B,'dictionary':l});return setContext(R),R;}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./errors.js';export*from'./config.js';export*from'./context.js';export*from'./plugins/index.js';export*from'./fcore.js';export*from'./migrations/runner.js';export*from'./type.js';
|
package/dist/migrations/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const R=n;import{runMigrations}from'./runner.js';import{loadConfig}from'../config.js';function g(){const Q=['--fcore','startsWith','****','log','run'];g=function(){return Q;};return g();}import k from'node:path';function n(r,k){r=r-0x14f;const Z=g();let K=Z[r];return K;}import{fileURLToPath}from'node:url';const packageMigrations=fileURLToPath(new URL('../../migrations',import.meta.url));function migrationDirectory(Z){const f=n,K=Z['indexOf']('--dir');if(K>=0x0){const J=Z[K+0x1];if(!J)throw new Error('--dir\x20requires\x20a\x20folder\x20path');return k['resolve'](J);}if(Z['includes'](f(0x14f)))return packageMigrations;const d=Z['find'](B=>!B[f(0x150)]('--'));return k['resolve'](d??'migrations');}try{const config=loadConfig(),dir=migrationDirectory(process['argv']['slice'](0x2));console['log']('Loaded\x20configuration:',{...config['pg'],'user':R(0x151),'password':R(0x151)}),console['log']('Using\x20migration\x20directory:',dir,process['argv']['slice'](0x2));for(const r of await runMigrations({'database':config['pg'],'dir':dir}))console[R(0x152)]((r['status']===R(0x153)?'OK\x20\x20':'SKIP')+'\x20'+r['file']);}catch(l){console['error'](l),process['exitCode']=0x1;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function g(){const m=['migrations','databaseUrl','query','filter','.sql','skip','readFile','connect','ROLLBACK','push','run','pathname','slice'];g=function(){return m;};return g();}import n from'node:fs/promises';import k from'node:path';import{createDatabase}from'../plugins/pg.js';function r(n,k){n=n-0x19b;const Z=g();let K=Z[n];return K;}export async function runMigrations(Z={}){const I=r,K=k['resolve'](Z['dir']??I(0x19b)),d=Z['database']??databaseFromUrl(Z[I(0x19c)]??process.env.DATABASE_URL);if(!d)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const J=createDatabase(d);if(!J)throw new Error('empty\x20pg');const B=[];try{await J[I(0x19d)]('\x0a\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20schema_migrations\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20version\x20varchar(255)\x20PRIMARY\x20KEY,\x0a\x20\x20\x20\x20\x20\x20\x20\x20applied_at\x20timestamptz\x20NOT\x20NULL\x20DEFAULT\x20now()\x0a\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20');const l=await J['query']('SELECT\x20version\x20FROM\x20schema_migrations'),f=new Set(l['rows']['map'](Q=>Q['version'])),R=(await n['readdir'](K))[I(0x19e)](Q=>Q['endsWith'](I(0x19f)))['sort']();for(const Q of R){if(f['has'](Q)){B['push']({'file':Q,'status':I(0x1a0)});continue;}const a=await n[I(0x1a1)](k['join'](K,Q),'utf8'),H=await J[I(0x1a2)]();try{await H[I(0x19d)]('BEGIN'),await H[I(0x19d)](a),await H['query']('INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)',[Q]),await H[I(0x19d)]('COMMIT');}catch(A){await H[I(0x19d)](I(0x1a3));throw A;}finally{H['release']();}B[I(0x1a4)]({'file':Q,'status':I(0x1a5)});}return B;}finally{await J['end']();}}function databaseFromUrl(Z){const O=r;if(!Z)return undefined;const K=new URL(Z);return{'host':K['hostname'],'port':Number(K['port']||0x1538),'database':K[O(0x1a6)][O(0x1a7)](0x1),'user':decodeURIComponent(K['username']),'password':decodeURIComponent(K['password'])};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adduser-cli.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/adduser-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const Z=r;import{loadConfig}from'../../config.js';function g(){const K=['argv','exitCode','end'];g=function(){return K;};return g();}import{createDatabase}from'../../plugins/pg.js';import n from'./services/registration.js';const [user,password,type]=process[Z(0xab)]['slice'](0x2);function r(n,k){n=n-0xab;const Z=g();let K=Z[n];return K;}if(!user||!password)console['error']('Usage:\x20fcore-registration\x20<login>\x20<password>\x20[type]'),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const {user:data}=await n({'user':user,'password':password,'type':type},{'pg':pg});console['log']('Registered\x20user\x20'+data['id']+'\x20('+data['type']+')');}catch(k){console['error'](k),process[Z(0xac)]=0x1;}finally{await pg[Z(0xad)]();}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwd-cli.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/passwd-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const Z=r;function g(){const K=['exitCode','SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201','rows','User\x20not\x20found','end'];g=function(){return K;};return g();}import{loadConfig}from'../../config.js';function r(n,k){n=n-0x128;const Z=g();let K=Z[n];return K;}import{createDatabase}from'../../plugins/pg.js';import n from'./services/change-password.js';const [login,password]=process['argv']['slice'](0x2);if(!login||!password)console['error']('Usage:\x20fcore-password\x20<login>\x20<password>'),process[Z(0x128)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg['query'](Z(0x129),[login]),user=result[Z(0x12a)][0x0];if(!user)throw new Error(Z(0x12b));await n({'userId':user['id'],'password':password},{'pg':pg}),console['log']('Password\x20changed\x20for\x20'+login);}catch(k){console['error'](k),process['exitCode']=0x1;}finally{await pg[Z(0x12c)]();}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-cli.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/permission-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
function g(){const Q=['list','argv','map','filter','add','system','Usage:\x20fcore-permission\x20<login>\x20<system|resource|resource:action[,...]|clear>','User\x20not\x20found','query','push','set','SELECT\x20access_id,\x20actions\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL\x20AND\x20resource\x20=\x20$2','actions','log','error'];g=function(){return Q;};return g();}const f=r;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function r(n,k){n=n-0xe9;const Z=g();let K=Z[n];return K;}const SYSTEM_ACTIONS=['logs','audit',f(0xe9),'check','access','settings','dictionaries'],RESOURCE_ACTIONS=['read','update','create','delete'],[login,permissionArg]=process[f(0xea)]['slice'](0x2);function expandPermissions(n){const R=f,k=n['split'](',')[R(0xeb)](K=>K['trim']())[R(0xec)](Boolean),Z=new Set();for(const K of k){if(K['includes'](':')){Z[R(0xed)](K);continue;}const d=K===R(0xee)?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const J of d){Z[R(0xed)](K+':'+J);}}return[...Z];}if(!login||!permissionArg)console['error'](f(0xef)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg['query']('SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201',[login]),user=result['rows'][0x0];if(!user)throw new Error(f(0xf0));if(permissionArg['trim']()==='clear')await pg[f(0xf1)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[user['id']]),console['log']('Permissions\x20cleared\x20for\x20'+login);else{const permissions=expandPermissions(permissionArg),byResource=new Map();for(const permission of permissions){const [resource,action]=permission['split'](':'),actions=byResource['get'](resource)??[];actions[f(0xf2)](action),byResource[f(0xf3)](resource,actions);}const client=await pg['connect']();try{await client[f(0xf1)]('BEGIN');for(const [resource,actions]of byResource){const existing=await client['query'](f(0xf4),[user['id'],resource]),row=existing['rows'][0x0];if(row){const merged=[...new Set([...row[f(0xf5)]??[],...actions])];await client['query']('UPDATE\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SET\x20actions\x20=\x20$1,\x20updated_by\x20=\x20$2,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20access_id\x20=\x20$3',[merged,user['id'],row['access_id']]);}else await client[f(0xf1)]('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)',[resource,actions,user['id'],user['id']]);}await client['query']('COMMIT');}catch(B){await client['query']('ROLLBACK');throw B;}finally{client['release']();}console[f(0xf6)]('Granted\x20permissions\x20for\x20'+login+':\x20'+permissions['join'](',\x20'));}}catch(l){console[f(0xf7)](l),process['exitCode']=0x1;}finally{await pg['end']();}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CAoK9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_0x26137a,_0x35a3c2){const _0x1be33d=_0x3532,_0x36a89d=_0x26137a();while(!![]){try{const _0x35c94f=parseInt(_0x1be33d(0xfa))/0x1+parseInt(_0x1be33d(0x12e))/0x2*(parseInt(_0x1be33d(0xfb))/0x3)+parseInt(_0x1be33d(0x168))/0x4+-parseInt(_0x1be33d(0x163))/0x5+parseInt(_0x1be33d(0x13c))/0x6+-parseInt(_0x1be33d(0x11c))/0x7+parseInt(_0x1be33d(0x101))/0x8;if(_0x35c94f===_0x35a3c2)break;else _0x36a89d['push'](_0x36a89d['shift']());}catch(_0x5a1cb2){_0x36a89d['push'](_0x36a89d['shift']());}}}(_0x58d2,0x9ddb8));import _0x11f01e from'./services/login.js';function _0x58d2(){const _0x3f765c=['udlSu','ImMtP','Verifies\x20a\x20two-factor\x20authentication\x20code.','destroy','Verify\x20two-factor\x20code','nJiMC','olidE','aduso','redirectUrl','wcQkZ','5099410STezrF','Resets\x20two-factor\x20authentication\x20for\x20the\x20current\x20user.','tags','Uses\x20a\x20recovery\x20code\x20to\x20restore\x20two-factor\x20access.','twoFactor','1143912aWIgzi','Get\x20current\x20user','/api/2factor/qr','gqWwl','zJuFs','dMlej','cookieName','Sign\x20out','bWear','vAAWp','sSurx','defineProperty','cgFQD','session','Sign\x20in','Not\x20authorized','summary','AmeFS','clearCookie','dgTDF','public','NdDYm','517468cbOFmm','3Akkrty','jDEeh','/api/user','jnfjG','YhFfo','xayUY','2631792XZdqFw','not\x20supported\x20yet','Dqpnj','NGiAt','sessionTimeout','credentials','lZwTa','description','Returns\x20the\x20current\x20two-factor\x20authentication\x20status.','URXoK','Get\x20two-factor\x20QR\x20code','rRUDA','xsHpc','config','permissions','cookie','LhtGH','fcore','MaOay','Recover\x20two-factor\x20access','EfIGC','dPFMJ','ZWeyV','login','/api/login','bJbFH','/api/2factor/recovery','2932748bnIgGr','XTxnT','Reset\x20two-factor\x20authentication','Terminates\x20the\x20current\x20user\x20session.','VFKmc','hHuyZ','/api/2factor/reset','/api/2factor','configurable','maxAge','josdS','Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','writable','dRMCH','save','fAazJ','iRkcd','yPYVT','1897570iXnELP','fgGNV','mMMhp','HCAhN','dFMBU','user','schema','TVbyA','FwezN','GKBMD','DXRQK','type','qmzUc','auth','25350nSMhEi','ogxfz','Get\x20two-factor\x20status','get','post','WeNYG','iOFOT','NaXeB','/api/logout','fEqIP','vOFyy','yIYfw','AtOXj','kUYIk','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','tpglp','value','body','sessionId','FDYHW','Fskgu','eDSNS','iMPrV','AuGRr','/api/2factor/verify','KJnKS','Returns\x20the\x20QR\x20code\x20required\x20to\x20configure\x20two-factor\x20authentication.','zANpf','access'];_0x58d2=function(){return _0x3f765c;};return _0x58d2();}import _0x53bde7 from'./services/logout.js';import _0x27db49 from'./services/get-current-user.js';function _0x3532(_0x267b95,_0x2ee8fb){_0x267b95=_0x267b95-0xf0;const _0x58d2d7=_0x58d2();let _0x35322c=_0x58d2d7[_0x267b95];return _0x35322c;}import{authSchemas}from'./schema.js';import _0x5549dd from'../../shared/getIP.js';import{UnauthorizedError,UnsupportedError}from'../../errors.js';export function authRoutes(_0xbeaa0b){const _0x95b738=_0x3532,_0x222c6e={'olidE':_0x95b738(0xf3),'dMlej':_0x95b738(0x102),'ZWeyV':function(_0x5f4c91,_0x42d450){return _0x5f4c91!==_0x42d450;},'dFMBU':_0x95b738(0x115),'fAazJ':_0x95b738(0x145),'qmzUc':_0x95b738(0x149),'FwezN':_0x95b738(0x107),'WeNYG':_0x95b738(0x10a),'vOFyy':function(_0x24b607,_0x283d32,_0x47766e){return _0x24b607(_0x283d32,_0x47766e);},'hHuyZ':function(_0x7ef8c6,_0x2a5daf){return _0x7ef8c6*_0x2a5daf;},'bWear':_0x95b738(0xf1),'zANpf':function(_0x4cac84,_0x575053){return _0x4cac84!==_0x575053;},'jnfjG':_0x95b738(0x143),'AuGRr':_0x95b738(0x14b),'FDYHW':function(_0x18e8da,_0x8443d2){return _0x18e8da===_0x8443d2;},'Dqpnj':_0x95b738(0x172),'eDSNS':_0x95b738(0x119),'nJiMC':_0x95b738(0x112),'josdS':_0x95b738(0x13b),'AmeFS':_0x95b738(0xf2),'NGiAt':_0x95b738(0xf8),'AtOXj':_0x95b738(0x144),'xayUY':_0x95b738(0x16f),'zJuFs':_0x95b738(0x11f),'VFKmc':_0x95b738(0xfd),'jDEeh':_0x95b738(0x169),'fgGNV':_0x95b738(0x14a),'MaOay':_0x95b738(0x133),'dgTDF':_0x95b738(0x13e),'dPFMJ':_0x95b738(0x109),'iMPrV':_0x95b738(0x10b),'DXRQK':_0x95b738(0x156),'iOFOT':_0x95b738(0x154),'xsHpc':_0x95b738(0x15d),'aduso':_0x95b738(0x15b),'XTxnT':_0x95b738(0x11b),'NdDYm':_0x95b738(0x114),'KJnKS':_0x95b738(0x166),'yIYfw':_0x95b738(0x164)};return async _0x47fcc1=>{const _0x27f1a9=_0x95b738,_0x1ba5f6={'wcQkZ':function(_0x1643aa,_0x25fe0a,_0x81f45e){const _0x17728c=_0x3532;return _0x222c6e[_0x17728c(0x146)](_0x1643aa,_0x25fe0a,_0x81f45e);},'bJbFH':function(_0x1a3ec9,_0x5d781b){const _0x2516d6=_0x3532;return _0x222c6e[_0x2516d6(0x121)](_0x1a3ec9,_0x5d781b);},'Fskgu':_0x222c6e[_0x27f1a9(0x15f)],'yPYVT':function(_0x556c95,_0x935214){return _0x556c95===_0x935214;},'HCAhN':_0x27f1a9(0x13d),'cgFQD':function(_0x381a7c,_0x26f2be,_0x7e9c2f){return _0x381a7c(_0x26f2be,_0x7e9c2f);},'YhFfo':_0x222c6e[_0x27f1a9(0x170)],'iRkcd':_0x222c6e[_0x27f1a9(0x16d)],'ImMtP':function(_0x3bc6ff,_0x4988cd){const _0x259b3b=_0x27f1a9;return _0x222c6e[_0x259b3b(0x157)](_0x3bc6ff,_0x4988cd);},'gqWwl':_0x222c6e[_0x27f1a9(0xfe)],'mMMhp':_0x222c6e[_0x27f1a9(0x153)],'udlSu':_0x27f1a9(0x135),'vAAWp':function(_0x692a1f,_0xcde3d9){const _0x33a92f=_0x27f1a9;return _0x222c6e[_0x33a92f(0x14f)](_0x692a1f,_0xcde3d9);},'LhtGH':_0x27f1a9(0x137)};if(_0x222c6e[_0x27f1a9(0x157)](_0x222c6e[_0x27f1a9(0x103)],_0x222c6e[_0x27f1a9(0x103)])){if(!_0x4a4fa2[_0x27f1a9(0x133)])throw new _0x3cfb04(_0x222c6e[_0x27f1a9(0x15f)]);throw new _0x1160e4(_0x222c6e[_0x27f1a9(0x16d)]);}else{_0x47fcc1[_0x27f1a9(0x140)](_0x222c6e[_0x27f1a9(0x151)],{'schema':{'tags':[_0x222c6e[_0x27f1a9(0x15e)],_0x222c6e[_0x27f1a9(0x126)]],'summary':_0x222c6e[_0x27f1a9(0xf5)],'description':_0x27f1a9(0x127),'access':_0x222c6e[_0x27f1a9(0x104)],'permissions':[],'body':authSchemas[_0x27f1a9(0x106)]}},async _0x46d020=>{const _0x55af2c=_0x27f1a9,_0x1b8a7c=_0x5549dd(_0x46d020),_0x450660={..._0x46d020[_0x55af2c(0x14d)]};_0x450660['ip']=_0x1b8a7c;const {user:_0x45c469,redirectUrl:redirectUrl='/'}=await _0x1ba5f6[_0x55af2c(0x162)](_0x11f01e,_0x450660,_0xbeaa0b);await _0x46d020[_0x55af2c(0x118)](_0x45c469);const _0x51c4d8=_0x1ba5f6[_0x55af2c(0x11a)](_0x1ba5f6[_0x55af2c(0x11a)](_0xbeaa0b[_0x55af2c(0x10e)][_0x55af2c(0x13b)][_0x55af2c(0x105)],0x3e8),0x3c);_0x46d020[_0x55af2c(0xf1)]?.[_0x55af2c(0x110)]&&(_0x46d020[_0x55af2c(0xf1)][_0x55af2c(0x110)][_0x55af2c(0x125)]=_0x51c4d8);await _0x46d020[_0x55af2c(0xf1)][_0x55af2c(0x12a)]();const _0x286494={};_0x286494['id']=_0x45c469['id'],_0x286494[_0x55af2c(0x139)]=_0x45c469[_0x55af2c(0x139)];const _0x170a2e={};return _0x170a2e[_0x55af2c(0x133)]=_0x286494,_0x170a2e[_0x55af2c(0x161)]=redirectUrl,_0x170a2e;}),_0x47fcc1[_0x27f1a9(0x140)](_0x222c6e[_0x27f1a9(0x148)],{'schema':{'tags':[_0x222c6e[_0x27f1a9(0x15e)],_0x27f1a9(0x13b)],'summary':_0x222c6e[_0x27f1a9(0x100)],'description':_0x222c6e[_0x27f1a9(0x16c)],'access':_0x27f1a9(0x133),'permissions':[]}},async(_0x5065df,_0x5b7cd6)=>{const _0x48fac3=_0x27f1a9,_0x1d1012={};_0x1d1012[_0x48fac3(0x161)]='/';const _0x2fd385=_0x1d1012;if(!_0x5065df[_0x48fac3(0x133)]){if(_0x1ba5f6[_0x48fac3(0x12d)](_0x1ba5f6[_0x48fac3(0x131)],_0x1ba5f6[_0x48fac3(0x131)]))return _0x2fd385;else throw new _0x126262(_0x1ba5f6[_0x48fac3(0x150)]);}const _0x4d35dd={};_0x4d35dd[_0x48fac3(0x14e)]=_0x5065df[_0x48fac3(0xf1)][_0x48fac3(0x14e)],_0x4d35dd[_0x48fac3(0x133)]=_0x5065df[_0x48fac3(0x133)],await _0x1ba5f6[_0x48fac3(0xf0)](_0x53bde7,_0x4d35dd,_0xbeaa0b),await _0x5065df[_0x48fac3(0xf1)][_0x48fac3(0x15c)](),_0x5b7cd6[_0x48fac3(0xf6)](_0xbeaa0b[_0x48fac3(0x10e)][_0x48fac3(0x13b)][_0x48fac3(0x16e)]);const _0x2fa29e={};return _0x2fa29e[_0x48fac3(0x14c)]=null,_0x2fa29e[_0x48fac3(0x128)]=![],_0x2fa29e[_0x48fac3(0x124)]=![],Object[_0x48fac3(0x173)](_0x5065df,_0x1ba5f6[_0x48fac3(0xff)],_0x2fa29e),_0x2fd385;}),_0x47fcc1[_0x27f1a9(0x13f)](_0x222c6e[_0x27f1a9(0x120)],{'schema':{'tags':[_0x222c6e[_0x27f1a9(0x15e)],_0x27f1a9(0x13b)],'summary':_0x222c6e[_0x27f1a9(0xfc)],'description':_0x222c6e[_0x27f1a9(0x12f)],'access':_0x222c6e[_0x27f1a9(0x113)],'permissions':[]}},async _0x56cf64=>_0x27db49({'user':_0x56cf64[_0x27f1a9(0x133)]}));const _0x260798={};_0x260798[_0x27f1a9(0x165)]=[_0x27f1a9(0x112),_0x222c6e[_0x27f1a9(0x126)]],_0x260798[_0x27f1a9(0xf4)]=_0x222c6e[_0x27f1a9(0xf7)],_0x260798[_0x27f1a9(0x108)]=_0x222c6e[_0x27f1a9(0x116)],_0x260798[_0x27f1a9(0x158)]=_0x222c6e[_0x27f1a9(0x113)],_0x260798[_0x27f1a9(0x10f)]=[];const _0x5abd17={};_0x5abd17[_0x27f1a9(0x134)]=_0x260798,_0x47fcc1[_0x27f1a9(0x13f)](_0x27f1a9(0x123),_0x5abd17,async _0x5a6302=>{const _0x3da8c9=_0x27f1a9;if(!_0x5a6302[_0x3da8c9(0x133)]){if(_0x1ba5f6[_0x3da8c9(0x15a)](_0x1ba5f6[_0x3da8c9(0x16b)],_0x1ba5f6[_0x3da8c9(0x130)]))throw new UnauthorizedError(_0x3da8c9(0xf3));else{if(!_0x1afa3c[_0x3da8c9(0x133)])throw new _0x232994(_0x3da8c9(0xf3));throw new _0x3ac338(_0x1ba5f6[_0x3da8c9(0x12c)]);}}throw new UnsupportedError(_0x3da8c9(0x102));});const _0x3fb63e={};_0x3fb63e[_0x27f1a9(0x165)]=[_0x222c6e[_0x27f1a9(0x15e)],_0x222c6e[_0x27f1a9(0x126)]],_0x3fb63e[_0x27f1a9(0xf4)]=_0x222c6e[_0x27f1a9(0x152)],_0x3fb63e[_0x27f1a9(0x108)]=_0x222c6e[_0x27f1a9(0x138)],_0x3fb63e[_0x27f1a9(0x158)]=_0x222c6e[_0x27f1a9(0x113)],_0x3fb63e[_0x27f1a9(0x10f)]=[];const _0x353734={};_0x353734[_0x27f1a9(0x134)]=_0x3fb63e,_0x47fcc1[_0x27f1a9(0x13f)](_0x27f1a9(0x16a),_0x353734,async _0x14c709=>{const _0x3d6e6a=_0x27f1a9;if(_0x1ba5f6[_0x3d6e6a(0x12d)](_0x1ba5f6[_0x3d6e6a(0x159)],_0x1ba5f6[_0x3d6e6a(0x159)])){if(!_0x14c709[_0x3d6e6a(0x133)]){if(_0x1ba5f6[_0x3d6e6a(0x171)](_0x1ba5f6[_0x3d6e6a(0x111)],_0x1ba5f6[_0x3d6e6a(0x111)]))throw new UnauthorizedError(_0x3d6e6a(0xf3));else throw new _0x208197(_0x3d6e6a(0xf3));}throw new UnsupportedError(_0x3d6e6a(0x102));}else throw new _0x53b641(_0x1ba5f6[_0x3d6e6a(0x150)]);}),_0x47fcc1[_0x27f1a9(0x140)](_0x222c6e[_0x27f1a9(0x142)],{'schema':{'tags':[_0x222c6e[_0x27f1a9(0x15e)],_0x222c6e[_0x27f1a9(0x126)]],'summary':_0x222c6e[_0x27f1a9(0x10d)],'description':_0x222c6e[_0x27f1a9(0x160)],'access':_0x27f1a9(0x133),'permissions':[],'body':authSchemas[_0x27f1a9(0x167)]}},async _0x1da055=>{const _0x84b994=_0x27f1a9;if(_0x222c6e[_0x84b994(0x117)](_0x222c6e[_0x84b994(0x132)],_0x222c6e[_0x84b994(0x132)])){if(!_0x5e947f[_0x84b994(0x133)])throw new _0x177985(_0x1ba5f6[_0x84b994(0x150)]);throw new _0x2e2a2c(_0x84b994(0x102));}else{if(!_0x1da055[_0x84b994(0x133)])throw new UnauthorizedError(_0x222c6e[_0x84b994(0x15f)]);throw new UnsupportedError(_0x222c6e[_0x84b994(0x16d)]);}}),_0x47fcc1[_0x27f1a9(0x140)](_0x222c6e[_0x27f1a9(0x11d)],{'schema':{'tags':[_0x222c6e[_0x27f1a9(0x15e)],_0x222c6e[_0x27f1a9(0x126)]],'summary':_0x222c6e[_0x27f1a9(0xf9)],'description':_0x222c6e[_0x27f1a9(0x155)],'access':_0x222c6e[_0x27f1a9(0x113)],'permissions':[],'body':authSchemas[_0x27f1a9(0x167)]}},async _0xe21d1e=>{const _0x55240c=_0x27f1a9,_0x127b3d={};_0x127b3d[_0x55240c(0x129)]=_0x222c6e[_0x55240c(0x15f)];const _0x5b4183=_0x127b3d;if(_0x222c6e[_0x55240c(0x117)](_0x222c6e[_0x55240c(0x12b)],_0x222c6e[_0x55240c(0x13a)])){if(!_0xe21d1e[_0x55240c(0x133)]){if(_0x222c6e[_0x55240c(0x136)]!==_0x55240c(0x10c))throw new UnauthorizedError(_0x55240c(0xf3));else{if(!_0xd6600d[_0x55240c(0x133)])throw new _0xdc2d(JvfxHu[_0x55240c(0x129)]);throw new _0x2a1c7d(_0x55240c(0x102));}}throw new UnsupportedError(_0x222c6e[_0x55240c(0x16d)]);}else throw new _0x2bdd29(_0x1ba5f6[_0x55240c(0x150)]);});const _0x50463a={};_0x50463a[_0x27f1a9(0x165)]=[_0x222c6e[_0x27f1a9(0x15e)],_0x27f1a9(0x13b)],_0x50463a[_0x27f1a9(0xf4)]=_0x27f1a9(0x11e),_0x50463a[_0x27f1a9(0x108)]=_0x222c6e[_0x27f1a9(0x147)],_0x50463a[_0x27f1a9(0x158)]=_0x27f1a9(0x133),_0x50463a[_0x27f1a9(0x10f)]=[],_0x50463a[_0x27f1a9(0x14d)]=authSchemas[_0x27f1a9(0x167)];const _0x109f3b={};_0x109f3b[_0x27f1a9(0x134)]=_0x50463a,_0x47fcc1[_0x27f1a9(0x140)](_0x27f1a9(0x122),_0x109f3b,async _0x487ee5=>{const _0x43e11c=_0x27f1a9;if(!_0x487ee5[_0x43e11c(0x133)]){if(_0x222c6e[_0x43e11c(0x117)](_0x222c6e[_0x43e11c(0x141)],_0x43e11c(0x10a)))_0x4577fc[_0x43e11c(0xf1)][_0x43e11c(0x110)][_0x43e11c(0x125)]=_0x593ba5;else throw new UnauthorizedError(_0x43e11c(0xf3));}throw new UnsupportedError(_0x222c6e[_0x43e11c(0x16d)]);});}};}
|
|
1
|
+
import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';import n from'./services/get-current-user.js';import k from'./services/registration.js';function r(n,k){n=n-0x105;const Z=g();let K=Z[n];return K;}import Z from'./services/change-password.js';import{authSchemas}from'./schema.js';function g(){const p=['method','query','body','auth','session','cookie','audit','type','permissions','Sign\x20in','/api/auth/login','public','credentials','/api/auth/registration','fcore','Register','admin','post','password','user','write','sessionId','config','cookieName','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','token'];g=function(){return p;};return g();}import K from'../../shared/getIP.js';import{UnauthorizedError}from'../../errors.js';export function authRoutes(d){return async J=>{const I=r,B=async l=>{const A=r,f=l[A(0x105)]==='GET'?l[A(0x106)]:l[A(0x107)],R=K(l),Q=await verifyUser({...f,'ip':R},d);Q['permissions']=await getUserPermissions(Q['id'],d);const a=Q['twofa']?d['config']['auth']['twoFactorRedirect']:d['config'][A(0x108)]['redirect'];await l['login'](Q);const H=d['config'][A(0x108)]['sessionTimeout']*0x3e8*0x3c;return l[A(0x109)]?.['cookie']&&(l['session'][A(0x10a)]['maxAge']=H),await l['session']['save'](),await d[A(0x10b)]?.['write']?.({'module':A(0x108),'resource':'session','resourceId':l['session']['sessionId'],'action':'login','userId':Q['id'],'ipAddress':R}),{'user':{'id':Q['id'],'type':Q[A(0x10c)],'permissions':Q[A(0x10d)]},'redirectUrl':a};};J['get']('/api/auth/login',{'schema':{'tags':['fcore',I(0x108)],'summary':I(0x10e),'description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'querystring':authSchemas['credentials']}},B),J['post'](I(0x10f),{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20in','description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':I(0x110),'permissions':[],'body':authSchemas[I(0x111)]}},B),J['post'](I(0x112),{'schema':{'tags':[I(0x113),'auth'],'summary':I(0x114),'description':'Creates\x20a\x20regular\x20user\x20account.','access':I(0x115),'permissions':['user:create'],'body':authSchemas['credentials']}},async l=>k(l['body'],d)),J[I(0x116)]('/api/auth/password',{'schema':{'tags':[I(0x113),I(0x108)],'summary':'Change\x20password','description':'Changes\x20the\x20password\x20for\x20the\x20current\x20user.','access':'user','permissions':[],'body':authSchemas[I(0x117)]}},async l=>{const O=I;if(!l[O(0x118)])throw new UnauthorizedError('Not\x20authorized');return await Z({'userId':l['user']['id'],...l['body']},d),{'success':!![]};}),J['post']('/api/auth/logout',{'schema':{'tags':[I(0x113),'auth'],'summary':'Sign\x20out','description':'Terminates\x20the\x20current\x20user\x20session.','access':I(0x118),'permissions':[]}},async(l,f)=>{const m=I,R={'redirectUrl':'/'};if(!l['user'])return R;return await d['audit']?.[m(0x119)]?.({'module':'auth','resource':'session','resourceId':l['session'][m(0x11a)],'action':'logout','userId':l[m(0x118)]?.['id']}),await l[m(0x109)]['destroy'](),f['clearCookie'](d[m(0x11b)]['auth'][m(0x11c)]),Object['defineProperty'](l,'session',{'value':null,'writable':![],'configurable':![]}),R;}),J['get']('/api/auth/user',{'schema':{'tags':['fcore','auth'],'summary':'Get\x20current\x20user','description':I(0x11d),'access':I(0x118),'permissions':[],'querystring':authSchemas['query']}},async l=>n({'user':l['user'],'token':l['query'][I(0x11e)]}));};}
|
|
@@ -3,13 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Static } from "@sinclair/typebox";
|
|
5
5
|
export declare const authSchemas: {
|
|
6
|
+
query: import("@sinclair/typebox").TObject<{
|
|
7
|
+
token: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
8
|
+
}>;
|
|
6
9
|
credentials: import("@sinclair/typebox").TObject<{
|
|
7
|
-
|
|
10
|
+
user: import("@sinclair/typebox").TString;
|
|
11
|
+
password: import("@sinclair/typebox").TString;
|
|
12
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
13
|
+
}>;
|
|
14
|
+
password: import("@sinclair/typebox").TObject<{
|
|
8
15
|
password: import("@sinclair/typebox").TString;
|
|
16
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
17
|
}>;
|
|
10
18
|
twoFactor: import("@sinclair/typebox").TObject<{
|
|
11
19
|
code: import("@sinclair/typebox").TString;
|
|
12
20
|
}>;
|
|
13
21
|
};
|
|
14
22
|
export type Credentials = Static<typeof authSchemas.credentials>;
|
|
23
|
+
export type Password = Static<typeof authSchemas.password>;
|
|
15
24
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,WAAW;IACtB,WAAW;;;;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,WAAW;IACtB,KAAK;;;IAGL,WAAW;;;;;IAKX,QAAQ;;;;IAIR,SAAS;;;CAGV,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function r(n,k){n=n-0xee;const Z=g();let K=Z[n];return K;}const n=r;function g(){const k=['Optional','Object','String'];g=function(){return k;};return g();}import{Type}from'@sinclair/typebox';export const authSchemas={'query':Type['Object']({'token':Type[n(0xee)](Type['Boolean']())}),'credentials':Type[n(0xef)]({'user':Type['String']({'minLength':0x1,'maxLength':0x64}),'password':Type[n(0xf0)]({'minLength':0x1,'maxLength':0x64}),'type':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'id':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type['Object']({'code':Type[n(0xf0)]({'minLength':0x1})})};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContextDependencies } from "../../../context.js";
|
|
2
|
+
type Params = {
|
|
3
|
+
id?: string;
|
|
4
|
+
password: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
};
|
|
7
|
+
export default function changePassword({ id, password, userId }: Params, { pg }: Pick<ContextDependencies, "pg">): Promise<void>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=change-password.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-password.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/change-password.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,KAAK,MAAM,GAAG;IACV,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAA8B,cAAc,CACxC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAChC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,iBAU1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n,k){n=n-0xef;const Z=g();let K=Z[n];return K;}function g(){const B=['query','UPDATE\x20admin.users\x0a\x20\x20\x20\x20\x20SET\x20password_hash\x20=\x20$1,\x20updated_at\x20=\x20now(),\x20updated_by\x20=\x20$3\x0a\x20\x20\x20\x20\x20WHERE\x20uid\x20=\x20$2'];g=function(){return B;};return g();}import{hashPassword}from'../../../plugins/auth/index.js';export default async function changePassword({id:n,password:k,userId:Z},{pg:K}){const J=r,d=await hashPassword(k);await K[J(0xef)](J(0xf0),[d,n||Z,Z]);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/get-current-user.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAA8B,cAAc,CAAC,MAAM,EAAE;IACnD,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/get-current-user.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAA8B,cAAc,CAAC,MAAM,EAAE;IACnD,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5B,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAenC"}
|