@opengis/fcore 0.0.1-beta.4 → 0.0.1-beta.6
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.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 +7 -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.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/route.js +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.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +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.js +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +7 -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.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +3 -0
- 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.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 +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.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.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.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/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.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +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 +23 -0
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +13 -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.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +15 -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.js +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +12 -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.js +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +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 +14 -0
- package/dist/type.d.ts.map +1 -1
- package/migrations/20260903120000_core_schema.sql +22 -19
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/package.json +10 -5
- 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
|
-
function
|
|
1
|
+
function H(){const X=['true','false','./storage','split','map','cwd','lax','strict','includes'];H=function(){return X;};return H();}function T(r,u){r=r-0x1ed;const G=H();let o=G[r];return o;}import'dotenv/config';const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function required(r){const u=process.env[r];if(!u)throw new Error('Missing\x20environment\x20variable:\x20'+r);return u;}export function loadConfig(r={}){const o=T,u={'env':process.env.NODE_ENV??'development','debug':process.env.DEBUG===o(0x1ed),'port':Number(process.env.PORT??0xbb8),'maxFileSize':+(process.env.MAX_FILE_SIZE||0x200),'rateLimit':{'disabled':process.env.RATE_LIMIT===o(0x1ee),'max':+(process.env.RATE_LIMIT_MAX||0x64),'timeWindow':+(process.env.RATE_LIMIT_TIME_WINDOW||0xea60)},'storagePath':process.env.STORAGE_PATH??o(0x1ef),'redactionList':(process.env.REDACTION_LIST||'password')[o(0x1f0)](','),'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'](',')[o(0x1f1)](G=>G-0x0):DEFAULT_LOG_RESPONSE_STATUS_CODES,'directory':process.env.LOG_DIRECTORY||process[o(0x1f2)]()+'/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??'us-east-1','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??'session_user_auth','jwtSecret':process.env.AUTH_JWT_SECRET??'0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','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||o(0x1ed)),'secure':Boolean(process.env.AUTH_COOKIE_OPTIONS_SECURE||'true'),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&[o(0x1f3),o(0x1f4),'none'][o(0x1f5)](process.env.AUTH_COOKIE_OPTIONS_SAME_SITE)?process.env.AUTH_COOKIE_OPTIONS_SAME_SITE:Boolean(process.env.AUTH_COOKIE_OPTIONS_SAME_SITE||o(0x1ed))}:{'path':'/','httpOnly':!![],'secure':![],'sameSite':!![]}}};return{...u,...r,'logger':{...u['logger'],...r['logger']},'pg':{...u['pg'],...r['pg']},'redis':{...u['redis'],...r['redis']},'s3':{...u['s3'],...r['s3']},'auth':{...u['auth'],...r['auth']}};}export{required as requireEnv};
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let defaultContext;function T(r,u){r=r-0x86;const G=H();let o=G[r];return o;}export function setContext(r){defaultContext=r;}export function getContext(){const u=T;if(!defaultContext)throw new Error(u(0x86));return defaultContext;}export function createContext(r){return{...r,async 'close'(){const G=T;await Promise['allSettled']([r['redis']?.['close'](),r['pg']?.['end']()]),await r[G(0x87)][G(0x88)]();}};}function H(){const o=['Application\x20context\x20is\x20not\x20initialized','logger','close'];H=function(){return o;};return H();}
|
package/dist/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var X=T;export class FCoreError extends Error{[X(0xbb)];['statusCode'];['details'];constructor(r,u,G=0x1f4,o){super(u),this['code']=r,this['statusCode']=G,this['details']=o,this['name']=new.target.name;}}export class BadRequestError extends FCoreError{constructor(r,u){var w=X;super(w(0xbc),r,0x190,u);}}export class UnauthorizedError extends FCoreError{constructor(r='Authentication\x20required'){var a=X;super(a(0xbd),r,0x191);}}export class ForbiddenError extends FCoreError{constructor(r='Access\x20denied'){var q=X;super(q(0xbe),r,0x193);}}export class NotFoundError extends FCoreError{constructor(r=X(0xbf)){var p=X;super(p(0xc0),r,0x194);}}function T(r,u){r=r-0xbb;var G=H();var o=G[r];return o;}export class ConflictError extends FCoreError{constructor(r=X(0xc1)){super('CONFLICT',r,0x199);}}export class ValidationError extends FCoreError{constructor(r,u){var F=X;super(F(0xc2),r,0x1a6,u);}}export class UnsupportedError extends FCoreError{constructor(r='Operation\x20is\x20not\x20configured'){super('UNSUPPORTED',r,0x1f5);}}function H(){var E=['code','BAD_REQUEST_ERROR','UNAUTHORIZED','FORBIDDEN','Not\x20found','NOT_FOUND','Conflict','VALIDATION_ERROR'];H=function(){return E;};return H();}
|
package/dist/fastify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoB/C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CA6FxE"}
|
package/dist/fastify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
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';function T(r,u){r=r-0xaa;const G=H();let o=G[r];return o;}import{systemRoutes}from'./modules/system/route.js';import{createSessionStore}from'./plugins/auth/index.js';function urlencodedContentParser(r,u,G){const o=decodeURIComponent(u['toString']())['split']('&')['reduce']((X,w)=>{const F=T,[a,q]=w[F(0xaa)]('=');return{...X,[a]:q};},{});G(null,o);}export default function fcoreFastify(r){return async u=>{const E=T;u[E(0xab)](E(0xac),r);const {config:G}=r,o=new Map();u[E(0xad)]('onRoute',X=>{const Y=E;if(X['url'][Y(0xae)](Y(0xaf))){const w=X['schema'],a=Array[Y(0xb0)](X[Y(0xb1)])?X[Y(0xb1)]:[X['method']];for(const q of a){if(q===Y(0xb2))continue;const p={'method':q,'endpoint':X['url'],'package':w?.['package']??Y(0xb3),'tags':w?.['tags']??[],'summary':w?.['summary']??'','description':w?.['description']??'','access':w?.['access']??'public','permissions':w?.['permissions']??[]};o[Y(0xb4)](q+'\x20'+X[Y(0xb5)],p);}}}),await createSessionStore(u,r),u['setErrorHandler']((X,w,a)=>{const S=E;if(X instanceof FCoreError||X[S(0xb6)]==='FST_ERR_VALIDATION')return a[S(0xb6)](X[S(0xb7)])['send']({'error':X['code'],'message':X[S(0xb8)],'details':X['details']});return r['logger'][S(0xb9)](X),(G[S(0xba)]||process.env.NODE_ENV==='test'||process.env.VITEST)&&console[S(0xb9)](X),a[S(0xb6)](0x1f4)['send']({'error':S(0xbb),'message':S(0xbc)});}),await u[E(0xbd)](authRoutes(r)),await u[E(0xbd)](resourceRoutes(r)),await u['register'](fileRoutes(r)),await u['register'](systemRoutes(r,o)),u['addContentTypeParser']('application/x-www-form-urlencoded',{'parseAs':'buffer'},urlencodedContentParser),!G['rateLimit']?.[E(0xbe)]?u['register'](import(E(0xbf)),{'max':G['rateLimit']?.['max']||0x64,'timeWindow':G['rateLimit']?.[E(0xc0)]||0xea60,'hook':'preHandler','global':!![],'keyGenerator':X=>(X[E(0xc1)]?.['id']||X['ip'])+'-'+X[E(0xc2)]['url']['split']('?')[0x0]}):console['log']('⚠️\x20rate\x20limit\x20is\x20disabled'),u['register'](import(E(0xc3)),{'limits':{'fileSize':G[E(0xc4)]*0x400*0x400}});};}function H(){const I=['split','decorate','ctx','addHook','startsWith','/api/','isArray','method','HEAD','fcore','set','url','code','statusCode','message','error','debug','INTERNAL_ERROR','Internal\x20server\x20error','register','disabled','@fastify/rate-limit','timeWindow','user','raw','@fastify/multipart','maxFileSize'];H=function(){return I;};return H();};
|
package/dist/fcore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function H(){const Y=['bucket','folder'];H=function(){return Y;};return H();}import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';import{createAudit,createDatabase,createDictionary,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';function T(r,u){r=r-0x150;const G=H();let o=G[r];return o;}export async function createFCore(r={}){const E=T,u=loadConfig(r['config']),G=createRedis(u['redis']),o=createLogger(),X=createDatabase(u['pg']),w=createFileS3({'endpoint':u['s3']['endpoint'],'region':u['s3']['region'],'bucket':u['s3'][E(0x150)],'accessKey':u['s3']['accessKey'],'secretKey':u['s3']['secretKey'],'folder':u['s3'][E(0x151)],'forcePathStyle':u['s3']['forcePathStyle'],'tokenSecret':u['s3']['tokenSecret'],'tokenTtl':u['s3']['tokenTtl']}),a=createAudit({'pg':X,'logger':o}),q=createDictionary({'pg':X,'dictionaries':r['dictionaries']}),p=createResource({'pg':X,'logger':o,'audit':a});r['resources']?.['length']&&p['register'](r['resources']);const F=createContext({'config':u,'logger':o,'redis':G,'pg':X,'file':w,'resource':p,'audit':a,'dictionary':q});return setContext(F),F;}
|
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
|
-
function
|
|
2
|
+
function H(){const o=['error'];H=function(){return o;};return H();}function T(r,u){r=r-0xb6;const G=H();let o=G[r];return o;}const G=T;import{runMigrations}from'./runner.js';import{loadConfig}from'../config.js';try{const config=loadConfig();console['log']('Loaded\x20configuration:',config['pg']);for(const r of await runMigrations({'database':config['pg']}))console['log']((r['status']==='run'?'OK\x20\x20':'SKIP')+'\x20'+r['file']);}catch(u){console[G(0xb6)](u),process['exitCode']=0x1;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import r from'node:fs/promises';import u from'node:path';import{createDatabase}from'../plugins/pg.js';export async function runMigrations(G={}){const c=T,o=u['resolve'](G['dir']??'migrations'),X=G['database']??databaseFromUrl(G['databaseUrl']??process.env.DATABASE_URL);if(!X)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const w=createDatabase(X);if(!w)throw new Error('empty\x20pg');const a=[];try{await w['query'](c(0x1b7));const q=await w['query']('SELECT\x20version\x20FROM\x20schema_migrations'),p=new Set(q['rows']['map'](E=>E['version'])),F=(await r['readdir'](o))['filter'](E=>E['endsWith']('.sql'))[c(0x1b8)]();for(const E of F){if(p[c(0x1b9)](E)){a['push']({'file':E,'status':'skip'});continue;}const Y=await r['readFile'](u['join'](o,E),'utf8'),S=await w[c(0x1ba)]();try{await S[c(0x1bb)](c(0x1bc)),await S['query'](Y),await S[c(0x1bb)](c(0x1bd),[E]),await S['query']('COMMIT');}catch(I){await S['query'](c(0x1be));throw I;}finally{S[c(0x1bf)]();}a['push']({'file':E,'status':c(0x1c0)});}return a;}finally{await w['end']();}}function H(){const P=['\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','sort','has','connect','query','BEGIN','INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)','ROLLBACK','release','run','pathname','username'];H=function(){return P;};return H();}function T(r,u){r=r-0x1b7;const G=H();let o=G[r];return o;}function databaseFromUrl(G){const h=T;if(!G)return undefined;const o=new URL(G);return{'host':o['hostname'],'port':Number(o['port']||0x1538),'database':o[h(0x1c1)]['slice'](0x1),'user':decodeURIComponent(o[h(0x1c2)]),'password':decodeURIComponent(o['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 G=T;function H(){const o=['argv','slice','type'];H=function(){return o;};return H();}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function T(r,u){r=r-0x112;const G=H();let o=G[r];return o;}import r from'./services/registration.js';const [user,password,type]=process[G(0x112)][G(0x113)](0x2);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 r({'user':user,'password':password,'type':type},{'pg':pg});console['log']('Registered\x20user\x20'+data['id']+'\x20('+data[G(0x114)]+')');}catch(u){console['error'](u),process['exitCode']=0x1;}finally{await pg['end']();}}
|
|
@@ -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 G=T;function H(){const o=['Usage:\x20fcore-password\x20<login>\x20<password>','SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201','exitCode','end'];H=function(){return o;};return H();}import{loadConfig}from'../../config.js';function T(r,u){r=r-0x15d;const G=H();let o=G[r];return o;}import{createDatabase}from'../../plugins/pg.js';import r from'./services/change-password.js';const [login,password]=process['argv']['slice'](0x2);if(!login||!password)console['error'](G(0x15d)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg['query'](G(0x15e),[login]),user=result['rows'][0x0];if(!user)throw new Error('User\x20not\x20found');await r({'userId':user['id'],'password':password},{'pg':pg}),console['log']('Password\x20changed\x20for\x20'+login);}catch(u){console['error'](u),process[G(0x15f)]=0x1;}finally{await pg[G(0x160)]();}}
|
|
@@ -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
|
+
const p=T;function T(r,u){r=r-0x1f0;const G=H();let o=G[r];return o;}function H(){const E=['logs','settings','dictionaries','create','delete','argv','split','map','system','add','Usage:\x20fcore-permission\x20<login>\x20<system|resource|resource:action[,...]|clear>','query','SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201','trim','Permissions\x20cleared\x20for\x20','get','push','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','rows','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','access_id','ROLLBACK','release','log'];H=function(){return E;};return H();}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';const SYSTEM_ACTIONS=[p(0x1f0),'audit','list','check','access',p(0x1f1),p(0x1f2)],RESOURCE_ACTIONS=['read','update',p(0x1f3),p(0x1f4)],[login,permissionArg]=process[p(0x1f5)]['slice'](0x2);function expandPermissions(r){const F=p,u=r[F(0x1f6)](',')[F(0x1f7)](o=>o['trim']())['filter'](Boolean),G=new Set();for(const o of u){if(o['includes'](':')){G['add'](o);continue;}const X=o===F(0x1f8)?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const w of X){G[F(0x1f9)](o+':'+w);}}return[...G];}if(!login||!permissionArg)console['error'](p(0x1fa)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[p(0x1fb)](p(0x1fc),[login]),user=result['rows'][0x0];if(!user)throw new Error('User\x20not\x20found');if(permissionArg[p(0x1fd)]()==='clear')await pg[p(0x1fb)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[user['id']]),console['log'](p(0x1fe)+login);else{const permissions=expandPermissions(permissionArg),byResource=new Map();for(const permission of permissions){const [resource,action]=permission['split'](':'),actions=byResource[p(0x1ff)](resource)??[];actions[p(0x200)](action),byResource['set'](resource,actions);}const client=await pg['connect']();try{await client['query']('BEGIN');for(const [resource,actions]of byResource){const existing=await client[p(0x1fb)](p(0x201),[user['id'],resource]),row=existing[p(0x202)][0x0];if(row){const merged=[...new Set([...row['actions']??[],...actions])];await client['query'](p(0x203),[merged,user['id'],row[p(0x204)]]);}else await client[p(0x1fb)]('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(a){await client['query'](p(0x205));throw a;}finally{client[p(0x206)]();}console[p(0x207)]('Granted\x20permissions\x20for\x20'+login+':\x20'+permissions['join'](',\x20'));}}catch(q){console['error'](q),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,CAmK9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _0x41c7(){const _0x36ff0b=['ugZnD','Verify\x20two-factor\x20code','public','login','cITBF','AcbwL','vMORg','wYLVX','cookie','hMEYk','Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','destroy','wyIPZ','VOOvE','/api/logout','yICAO','fXgRZ','zgIDO','Get\x20current\x20user','Get\x20two-factor\x20status','uKTnd','JISoj','35008mJkCku','sessionTimeout','ARxIo','13826800hgCkkY','yxbhJ','BtLCm','twoFactor','/api/2factor','Returns\x20the\x20current\x20two-factor\x20authentication\x20status.','GkpRc','mkeRH','schema','1166054NtDOHM','aCRGO','description','nircs','post','Recover\x20two-factor\x20access','get','UWrcm','writable','clearCookie','Not\x20authorized','uTVJk','fArRA','config','sBaGO','sBOHm','29976RKStjS','fcore','auth','MvFdm','JsuPP','7504fziKTB','/api/2factor/reset','configurable','save','credentials','fGVgL','FhkGu','JnTMk','tags','/api/2factor/verify','2724SsZxLx','VHbTQ','Uses\x20a\x20recovery\x20code\x20to\x20restore\x20two-factor\x20access.','eJsJI','408536SlVZBU','Terminates\x20the\x20current\x20user\x20session.','OGaTy','/api/login','Sign\x20out','not\x20supported\x20yet','FvgVB','/api/2factor/qr','permissions','bSyNd','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','kGaET','UIsTN','DENtL','Sign\x20in','session','RiSGv','Reset\x20two-factor\x20authentication','243XJbomE','JzITa','value','qzChq','Returns\x20the\x20QR\x20code\x20required\x20to\x20configure\x20two-factor\x20authentication.','Resets\x20two-factor\x20authentication\x20for\x20the\x20current\x20user.','cookieName','summary','ezAug','type','/api/2factor/recovery','695755pWLZSJ','redirectUrl','NVVeR','access','gJOEq','Tfifr','user','body','fRilX','RWKYX','Verifies\x20a\x20two-factor\x20authentication\x20code.','cMwWn','RPNBx','153pjXccS','maxAge','/api/user','ZTPiS','Get\x20two-factor\x20QR\x20code','sessionId','VKcHz','JsuBI','mRpdZ','jvagO','defineProperty'];_0x41c7=function(){return _0x36ff0b;};return _0x41c7();}(function(_0x361f2b,_0x387ba8){const _0x1d5e93=_0x4b8c,_0x479c2f=_0x361f2b();while(!![]){try{const _0x595384=parseInt(_0x1d5e93(0x8f))/0x1+parseInt(_0x1d5e93(0xe6))/0x2+parseInt(_0x1d5e93(0xb9))/0x3*(parseInt(_0x1d5e93(0xda))/0x4)+-parseInt(_0x1d5e93(0xac))/0x5+parseInt(_0x1d5e93(0x8b))/0x6*(parseInt(_0x1d5e93(0x81))/0x7)+-parseInt(_0x1d5e93(0x7c))/0x8*(parseInt(_0x1d5e93(0xa1))/0x9)+-parseInt(_0x1d5e93(0xdd))/0xa;if(_0x595384===_0x387ba8)break;else _0x479c2f['push'](_0x479c2f['shift']());}catch(_0x4e3ee6){_0x479c2f['push'](_0x479c2f['shift']());}}}(_0x41c7,0x49a23));import _0xa92e02 from'./services/login.js';import _0x5c2e1d from'./services/logout.js';function _0x4b8c(_0x1f139a,_0x8ef65){_0x1f139a=_0x1f139a-0x70;const _0x41c71c=_0x41c7();let _0x4b8cc2=_0x41c71c[_0x1f139a];return _0x4b8cc2;}import _0x4f70c2 from'./services/get-current-user.js';import{authSchemas}from'./schema.js';import _0x1ca37d from'../../shared/getIP.js';import{UnauthorizedError,UnsupportedError}from'../../errors.js';export function authRoutes(_0x3a4362){const _0x255fe4=_0x4b8c,_0x5030ee={'eJsJI':_0x255fe4(0x76),'jvagO':_0x255fe4(0x94),'VHbTQ':function(_0x1cf5c3,_0x41d936,_0x436a5b){return _0x1cf5c3(_0x41d936,_0x436a5b);},'bSyNd':_0x255fe4(0x9e),'MvFdm':function(_0x5f0d24,_0x282f43){return _0x5f0d24(_0x282f43);},'FvgVB':function(_0xc8fd1f,_0x1f76ff,_0x5ec4c2){return _0xc8fd1f(_0x1f76ff,_0x5ec4c2);},'UWrcm':function(_0x594a05,_0x54b451){return _0x594a05*_0x54b451;},'uKTnd':function(_0xd8e4e9,_0x3cc0f5){return _0xd8e4e9===_0x3cc0f5;},'aCRGO':_0x255fe4(0xb0),'cITBF':_0x255fe4(0xe9),'mRpdZ':_0x255fe4(0x86),'Tfifr':function(_0x183957,_0x3db13c){return _0x183957===_0x3db13c;},'JsuBI':_0x255fe4(0xe4),'UIsTN':function(_0x26e8e0,_0x5dfd77){return _0x26e8e0!==_0x5dfd77;},'RWKYX':_0x255fe4(0xa2),'yICAO':_0x255fe4(0x7e),'AcbwL':_0x255fe4(0x9d),'hMEYk':_0x255fe4(0xce),'fXgRZ':_0x255fe4(0xc6),'vMORg':_0x255fe4(0xd2),'RiSGv':_0x255fe4(0x7d),'JISoj':_0x255fe4(0xb2),'VOOvE':_0x255fe4(0xd6),'wYLVX':_0x255fe4(0x99),'fRilX':_0x255fe4(0xe1),'zgIDO':_0x255fe4(0xd7),'sBOHm':_0x255fe4(0xe2),'qzChq':_0x255fe4(0x96),'yxbhJ':_0x255fe4(0xa5),'fArRA':_0x255fe4(0x8a),'kGaET':_0x255fe4(0xc5),'OGaTy':_0x255fe4(0xb6),'ARxIo':_0x255fe4(0x71),'sBaGO':_0x255fe4(0x8d),'BtLCm':_0x255fe4(0x82),'cMwWn':_0x255fe4(0xa0),'VKcHz':_0x255fe4(0xa6)};return async _0x19499=>{const _0x56251f=_0x255fe4,_0x3fed30={'wyIPZ':function(_0x59c0f6,_0x3e6cd3){const _0x525b9f=_0x4b8c;return _0x5030ee[_0x525b9f(0x7f)](_0x59c0f6,_0x3e6cd3);},'JsuPP':function(_0x348115,_0x2ff3a3,_0x3a291c){const _0x534f15=_0x4b8c;return _0x5030ee[_0x534f15(0x95)](_0x348115,_0x2ff3a3,_0x3a291c);},'FhkGu':function(_0x4fe5f0,_0x461c48){const _0x2f0a0c=_0x4b8c;return _0x5030ee[_0x2f0a0c(0x73)](_0x4fe5f0,_0x461c48);},'ezAug':function(_0x4251bc,_0x34320e){const _0x5944c1=_0x4b8c;return _0x5030ee[_0x5944c1(0xd8)](_0x4251bc,_0x34320e);},'RPNBx':_0x5030ee[_0x56251f(0xe7)],'JnTMk':_0x5030ee[_0x56251f(0xc2)],'ZTPiS':function(_0x4effbb,_0x596acd){return _0x4effbb===_0x596acd;},'GkpRc':_0x5030ee[_0x56251f(0xc8)],'uTVJk':_0x5030ee[_0x56251f(0x8e)],'NVVeR':_0x5030ee[_0x56251f(0xc1)],'ugZnD':function(_0x596f6d,_0x484a26){const _0x3f3476=_0x56251f;return _0x5030ee[_0x3f3476(0xb1)](_0x596f6d,_0x484a26);},'DENtL':_0x5030ee[_0x56251f(0xc0)]};if(_0x5030ee[_0x56251f(0x9b)](_0x56251f(0xa2),_0x5030ee[_0x56251f(0xb5)])){if(!_0x5a7f72[_0x56251f(0xb2)])throw new _0x4cc73c(_0x5030ee[_0x56251f(0x8e)]);throw new _0x4618cb(_0x5030ee[_0x56251f(0xc2)]);}else{const _0x18b99c={};_0x18b99c[_0x56251f(0x89)]=[_0x56251f(0x7d),_0x5030ee[_0x56251f(0xd3)]],_0x18b99c[_0x56251f(0xa8)]=_0x5030ee[_0x56251f(0xc9)],_0x18b99c[_0x56251f(0xe8)]=_0x5030ee[_0x56251f(0xcd)],_0x18b99c[_0x56251f(0xaf)]=_0x5030ee[_0x56251f(0xd4)],_0x18b99c[_0x56251f(0x97)]=[],_0x18b99c[_0x56251f(0xb3)]=authSchemas[_0x56251f(0x85)];const _0x1d2494={};_0x1d2494[_0x56251f(0xe5)]=_0x18b99c,_0x19499[_0x56251f(0x70)](_0x56251f(0x92),_0x1d2494,async _0x1f8d60=>{const _0x2304c2=_0x56251f,_0x34a297=_0x3fed30[_0x2304c2(0xd0)](_0x1ca37d,_0x1f8d60),_0x1b1f1f={..._0x1f8d60[_0x2304c2(0xb3)]};_0x1b1f1f['ip']=_0x34a297;const {user:_0x117ca0,redirectUrl:redirectUrl='/'}=await _0x3fed30[_0x2304c2(0x80)](_0xa92e02,_0x1b1f1f,_0x3a4362);await _0x1f8d60[_0x2304c2(0xc7)](_0x117ca0);const _0x3412f9=_0x3fed30[_0x2304c2(0x87)](_0x3fed30[_0x2304c2(0x87)](_0x3a4362[_0x2304c2(0x79)][_0x2304c2(0x7e)][_0x2304c2(0xdb)],0x3e8),0x3c);if(_0x1f8d60[_0x2304c2(0x9e)]?.[_0x2304c2(0xcc)]){if(_0x3fed30[_0x2304c2(0xa9)](_0x2304c2(0xb0),_0x3fed30[_0x2304c2(0xb8)]))_0x1f8d60[_0x2304c2(0x9e)][_0x2304c2(0xcc)][_0x2304c2(0xba)]=_0x3412f9;else throw new _0x2ae357(_0x2304c2(0x76));}await _0x1f8d60[_0x2304c2(0x9e)][_0x2304c2(0x84)]();const _0x550e56={};_0x550e56['id']=_0x117ca0['id'],_0x550e56[_0x2304c2(0xaa)]=_0x117ca0[_0x2304c2(0xaa)];const _0x20b7ec={};return _0x20b7ec[_0x2304c2(0xb2)]=_0x550e56,_0x20b7ec[_0x2304c2(0xad)]=redirectUrl,_0x20b7ec;}),_0x19499[_0x56251f(0x70)](_0x5030ee[_0x56251f(0xca)],{'schema':{'tags':[_0x5030ee[_0x56251f(0x9f)],_0x5030ee[_0x56251f(0xd3)]],'summary':_0x56251f(0x93),'description':_0x56251f(0x90),'access':_0x5030ee[_0x56251f(0xd9)],'permissions':[]}},async(_0x33220e,_0x49bd6)=>{const _0x1f984a=_0x56251f,_0x4c5056={};_0x4c5056[_0x1f984a(0xad)]='/';const _0x8238e5=_0x4c5056;if(!_0x33220e[_0x1f984a(0xb2)])return _0x8238e5;const _0x5963f1={};_0x5963f1[_0x1f984a(0xbe)]=_0x33220e[_0x1f984a(0x9e)][_0x1f984a(0xbe)],_0x5963f1[_0x1f984a(0xb2)]=_0x33220e[_0x1f984a(0xb2)],await _0x5030ee[_0x1f984a(0x8c)](_0x5c2e1d,_0x5963f1,_0x3a4362),await _0x33220e[_0x1f984a(0x9e)][_0x1f984a(0xcf)](),_0x49bd6[_0x1f984a(0x75)](_0x3a4362[_0x1f984a(0x79)][_0x1f984a(0x7e)][_0x1f984a(0xa7)]);const _0x104e3={};return _0x104e3[_0x1f984a(0xa3)]=null,_0x104e3[_0x1f984a(0x74)]=![],_0x104e3[_0x1f984a(0x83)]=![],Object[_0x1f984a(0xc3)](_0x33220e,_0x5030ee[_0x1f984a(0x98)],_0x104e3),_0x8238e5;});const _0x3d7773={};_0x3d7773[_0x56251f(0x89)]=[_0x5030ee[_0x56251f(0x9f)],_0x5030ee[_0x56251f(0xd3)]],_0x3d7773[_0x56251f(0xa8)]=_0x5030ee[_0x56251f(0xd1)],_0x3d7773[_0x56251f(0xe8)]=_0x5030ee[_0x56251f(0xcb)],_0x3d7773[_0x56251f(0xaf)]=_0x5030ee[_0x56251f(0xd9)],_0x3d7773[_0x56251f(0x97)]=[];const _0x1a4f3a={};_0x1a4f3a[_0x56251f(0xe5)]=_0x3d7773,_0x19499[_0x56251f(0x72)](_0x56251f(0xbb),_0x1a4f3a,async _0x16c1a8=>_0x4f70c2({'user':_0x16c1a8[_0x56251f(0xb2)]})),_0x19499[_0x56251f(0x72)](_0x5030ee[_0x56251f(0xb4)],{'schema':{'tags':[_0x5030ee[_0x56251f(0x9f)],_0x56251f(0x7e)],'summary':_0x5030ee[_0x56251f(0xd5)],'description':_0x5030ee[_0x56251f(0x7b)],'access':_0x5030ee[_0x56251f(0xd9)],'permissions':[]}},async _0x2c551a=>{const _0x1f831b=_0x56251f;if(!_0x2c551a[_0x1f831b(0xb2)]){if(_0x3fed30[_0x1f831b(0xbc)](_0x3fed30[_0x1f831b(0xe3)],_0x1f831b(0xe9)))throw new UnauthorizedError(_0x3fed30[_0x1f831b(0x77)]);else{if(!_0x2f859e[_0x1f831b(0xb2)])throw new _0x5a34bd(_0x1f831b(0x76));throw new _0x4c8118(_0x3fed30[_0x1f831b(0x88)]);}}throw new UnsupportedError(_0x3fed30[_0x1f831b(0x88)]);}),_0x19499[_0x56251f(0x72)](_0x5030ee[_0x56251f(0xa4)],{'schema':{'tags':[_0x5030ee[_0x56251f(0x9f)],_0x5030ee[_0x56251f(0xd3)]],'summary':_0x56251f(0xbd),'description':_0x5030ee[_0x56251f(0xde)],'access':_0x5030ee[_0x56251f(0xd9)],'permissions':[]}},async _0x3a5303=>{const _0x37619f=_0x56251f;if(!_0x3a5303[_0x37619f(0xb2)])throw new UnauthorizedError(_0x3fed30[_0x37619f(0x77)]);throw new UnsupportedError(_0x37619f(0x94));}),_0x19499[_0x56251f(0x70)](_0x5030ee[_0x56251f(0x78)],{'schema':{'tags':[_0x5030ee[_0x56251f(0x9f)],_0x56251f(0x7e)],'summary':_0x5030ee[_0x56251f(0x9a)],'description':_0x5030ee[_0x56251f(0x91)],'access':_0x5030ee[_0x56251f(0xd9)],'permissions':[],'body':authSchemas[_0x56251f(0xe0)]}},async _0x3b4d55=>{const _0x2f0755=_0x56251f;if(!_0x3b4d55[_0x2f0755(0xb2)])throw new UnauthorizedError(_0x2f0755(0x76));throw new UnsupportedError(_0x3fed30[_0x2f0755(0x88)]);});const _0x4f703a={};_0x4f703a[_0x56251f(0x89)]=[_0x5030ee[_0x56251f(0x9f)],_0x5030ee[_0x56251f(0xd3)]],_0x4f703a[_0x56251f(0xa8)]=_0x5030ee[_0x56251f(0xdc)],_0x4f703a[_0x56251f(0xe8)]=_0x5030ee[_0x56251f(0x7a)],_0x4f703a[_0x56251f(0xaf)]=_0x5030ee[_0x56251f(0xd9)],_0x4f703a[_0x56251f(0x97)]=[],_0x4f703a[_0x56251f(0xb3)]=authSchemas[_0x56251f(0xe0)];const _0x5c5e50={};_0x5c5e50[_0x56251f(0xe5)]=_0x4f703a,_0x19499[_0x56251f(0x70)](_0x56251f(0xab),_0x5c5e50,async _0x4e29b7=>{const _0x5ce732=_0x56251f;if(!_0x4e29b7[_0x5ce732(0xb2)])throw new UnauthorizedError(_0x5ce732(0x76));throw new UnsupportedError(_0x3fed30[_0x5ce732(0x88)]);}),_0x19499[_0x56251f(0x70)](_0x5030ee[_0x56251f(0xdf)],{'schema':{'tags':[_0x56251f(0x7d),_0x5030ee[_0x56251f(0xd3)]],'summary':_0x5030ee[_0x56251f(0xb7)],'description':_0x5030ee[_0x56251f(0xbf)],'access':_0x5030ee[_0x56251f(0xd9)],'permissions':[],'body':authSchemas[_0x56251f(0xe0)]}},async _0xd78a4d=>{const _0x2c31dd=_0x56251f;if(_0x3fed30[_0x2c31dd(0xae)]!==_0x2c31dd(0x86))_0x500826[_0x2c31dd(0x9e)][_0x2c31dd(0xcc)][_0x2c31dd(0xba)]=_0x45487b;else{if(!_0xd78a4d[_0x2c31dd(0xb2)]){if(_0x3fed30[_0x2c31dd(0xc4)](_0x3fed30[_0x2c31dd(0x9c)],_0x3fed30[_0x2c31dd(0x9c)]))throw new UnauthorizedError(_0x3fed30[_0x2c31dd(0x77)]);else return _0x3f32f6;}throw new UnsupportedError(_0x3fed30[_0x2c31dd(0x88)]);}});}};}
|
|
1
|
+
function H(){const l=['GET','permissions','twofa','redirect','login','sessionTimeout','session','maxAge','type','auth','Sign\x20in','/api/auth/login','post','/api/auth/registration','fcore','/api/auth/password','Changes\x20the\x20password\x20for\x20the\x20current\x20user.','Not\x20authorized','body','Sign\x20out','Terminates\x20the\x20current\x20user\x20session.','user','sessionId','logout','config','defineProperty','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.'];H=function(){return l;};return H();}import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';function T(r,u){r=r-0x1b2;const G=H();let o=G[r];return o;}import r from'./services/get-current-user.js';import u from'./services/registration.js';import G from'./services/change-password.js';import{authSchemas}from'./schema.js';import o from'../../shared/getIP.js';import{UnauthorizedError}from'../../errors.js';export function authRoutes(X){return async w=>{const c=T,a=async q=>{const I=T,p=q['method']===I(0x1b2)?q['query']:q['body'],F=o(q),E=await verifyUser({...p,'ip':F},X);E[I(0x1b3)]=await getUserPermissions(E['id'],X);const Y=E[I(0x1b4)]?X['config']['auth']['twoFactorRedirect']:X['config']['auth'][I(0x1b5)];await q[I(0x1b6)](E);const S=X['config']['auth'][I(0x1b7)]*0x3e8*0x3c;return q[I(0x1b8)]?.['cookie']&&(q[I(0x1b8)]['cookie'][I(0x1b9)]=S),await q['session']['save'](),await X['audit']?.['write']?.({'module':'auth','resource':'session','resourceId':q['session']['sessionId'],'action':'login','userId':E['id'],'ipAddress':F}),{'user':{'id':E['id'],'type':E[I(0x1ba)],'permissions':E['permissions']},'redirectUrl':Y};};w['get']('/api/auth/login',{'schema':{'tags':['fcore',c(0x1bb)],'summary':c(0x1bc),'description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'querystring':authSchemas['credentials']}},a),w['post'](c(0x1bd),{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20in','description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'body':authSchemas['credentials']}},a),w[c(0x1be)](c(0x1bf),{'schema':{'tags':[c(0x1c0),c(0x1bb)],'summary':'Register','description':'Creates\x20a\x20regular\x20user\x20account.','access':'admin','permissions':['user:create'],'body':authSchemas['credentials']}},async q=>u(q['body'],X)),w['post'](c(0x1c1),{'schema':{'tags':['fcore',c(0x1bb)],'summary':'Change\x20password','description':c(0x1c2),'access':'user','permissions':[],'body':authSchemas['password']}},async q=>{const h=c;if(!q['user'])throw new UnauthorizedError(h(0x1c3));return await G({'userId':q['user']['id'],...q[h(0x1c4)]},X),{'success':!![]};}),w['post']('/api/auth/logout',{'schema':{'tags':[c(0x1c0),'auth'],'summary':c(0x1c5),'description':c(0x1c6),'access':'user','permissions':[]}},async(q,p)=>{const P=c,F={'redirectUrl':'/'};if(!q[P(0x1c7)])return F;return await X['audit']?.['write']?.({'module':'auth','resource':'session','resourceId':q['session'][P(0x1c8)],'action':P(0x1c9),'userId':q['user']?.['id']}),await q['session']['destroy'](),p['clearCookie'](X[P(0x1ca)]['auth']['cookieName']),Object[P(0x1cb)](q,P(0x1b8),{'value':null,'writable':![],'configurable':![]}),F;}),w['get']('/api/auth/user',{'schema':{'tags':['fcore','auth'],'summary':'Get\x20current\x20user','description':c(0x1cc),'access':'user','permissions':[]}},async q=>r({'user':q[c(0x1c7)]}));};}
|
|
@@ -4,12 +4,18 @@
|
|
|
4
4
|
import { Static } from "@sinclair/typebox";
|
|
5
5
|
export declare const authSchemas: {
|
|
6
6
|
credentials: import("@sinclair/typebox").TObject<{
|
|
7
|
-
|
|
7
|
+
user: import("@sinclair/typebox").TString;
|
|
8
8
|
password: import("@sinclair/typebox").TString;
|
|
9
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
10
|
+
}>;
|
|
11
|
+
password: import("@sinclair/typebox").TObject<{
|
|
12
|
+
password: import("@sinclair/typebox").TString;
|
|
13
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
14
|
}>;
|
|
10
15
|
twoFactor: import("@sinclair/typebox").TObject<{
|
|
11
16
|
code: import("@sinclair/typebox").TString;
|
|
12
17
|
}>;
|
|
13
18
|
};
|
|
14
19
|
export type Credentials = Static<typeof authSchemas.credentials>;
|
|
20
|
+
export type Password = Static<typeof authSchemas.password>;
|
|
15
21
|
//# 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,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
|
-
const
|
|
1
|
+
const r=T;import{Type}from'@sinclair/typebox';function H(){const u=['Optional','String','Object'];H=function(){return u;};return H();}function T(r,u){r=r-0xaf;const G=H();let o=G[r];return o;}export const authSchemas={'credentials':Type['Object']({'user':Type['String']({'minLength':0x1,'maxLength':0x64}),'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'type':Type[r(0xaf)](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'id':Type['Optional'](Type[r(0xb0)]({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type[r(0xb1)]({'code':Type[r(0xb0)]({'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 H(){const a=['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'];H=function(){return a;};return H();}function T(r,u){r=r-0xea;const G=H();let o=G[r];return o;}import{hashPassword}from'../../../plugins/auth/index.js';export default async function changePassword({id:r,password:u,userId:G},{pg:o}){const w=T,X=await hashPassword(u);await o[w(0xea)](w(0xeb),[X,r||G,G]);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{safeUser}from'../../utils/safe-user.js';export default async function getCurrentUser(r){const {user:u}=r;return safeUser(u||{});}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ContextDependencies } from "../../../context.js";
|
|
2
|
+
type params = {
|
|
3
|
+
user: string;
|
|
4
|
+
password: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
};
|
|
7
|
+
export default function registration({ user, password, type }: params, { pg }: Pick<ContextDependencies, "pg">): Promise<{
|
|
8
|
+
user: {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,KAAK,MAAM,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAA8B,YAAY,CACtC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,MAAM,EAChC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC;;YAGH,MAAM;cAAQ,MAAM;;GAc3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ConflictError}from'../../../errors.js';import{hashPassword}from'../../../plugins/auth/index.js';export default async function registration({user:r,password:u,type:G},{pg:o}){const q=T,X=await hashPassword(u),w=await o['query']('INSERT\x20INTO\x20admin.users\x20(login,\x20password_hash,\x20user_type)\x0a\x20\x20\x20\x20\x20SELECT\x20$1,\x20$2,\x20$3\x0a\x20\x20\x20\x20\x20WHERE\x20NOT\x20EXISTS\x20(SELECT\x201\x20FROM\x20admin.users\x20WHERE\x20login\x20=\x20$1)\x0a\x20\x20\x20\x20\x20RETURNING\x20uid\x20AS\x20id,\x20user_type\x20AS\x20type',[r,X,G||q(0x14f)]),a=w[q(0x150)][0x0];if(!a)throw new ConflictError('Login\x20is\x20already\x20in\x20use');return{'user':a};}function T(r,u){r=r-0x14f;const G=H();let o=G[r];return o;}function H(){const p=['regular','rows'];H=function(){return p;};return H();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{unsupported}from'../../utils/unsupported.js';function T(r,u){r=r-0x135;var G=H();var o=G[r];return o;}function H(){var o=['Two-factor\x20provider'];H=function(){return o;};return H();}export default async function verifyTwoFactor(r,u){var G=T;return unsupported(G(0x135));}
|