@opengis/fcore 0.0.1-beta.1 → 0.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +5 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.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 +22 -1
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +14 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts +9 -5
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +16 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.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.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.d.ts +3 -0
- package/dist/plugins/logger/transport.d.ts.map +1 -0
- package/dist/plugins/logger/transport.js +1 -0
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +60 -6
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- package/dist/plugins/resource/services/create.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- package/dist/plugins/resource/services/delete.d.ts +5 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +5 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/dist/type.d.ts +37 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +1 -0
- package/migrations/20260903120000_core_schema.sql +22 -19
- package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +13 -8
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const d=S;import{Type}from'@sinclair/typebox';export const identifier=Type[d(0x1aa)]({'minLength':0x1,'maxLength':0x80,'pattern':d(0x1ab)});function S(d,h){d=d-0x1aa;const p=v();let Z=p[d];return Z;}export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type[d(0x1ac)]([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type[d(0x1ac)]([Type['String'](),Type['Number'](),Type[d(0x1ad)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type[d(0x1ae)]({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'access':Type['Object']({'access':Type[d(0x1af)](Type['Object']({'resource':Type[d(0x1aa)]({'minLength':0x1,'maxLength':0x80}),'actions':Type[d(0x1af)](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})}))}),'apiListQuery':Type['Object']({'format':Type[d(0x1b0)](Type['Union']([Type['Literal'](d(0x1b1)),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type[d(0x1b0)](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type[d(0x1b2)]()),'logger':Type['Object']({'path':Type[d(0x1b0)](Type['String']({'maxLength':0x100,'pattern':d(0x1b3)}))})};function v(){const h=['String','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Union','Null','Object','Array','Optional','short','Unknown','^[A-Za-z0-9_.\x5c-/]*$'];v=function(){return h;};return v();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-system.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/check-system.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"check-system.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/check-system.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAcd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(d,h){d=d-0xd4;const p=v();let Z=p[d];return Z;}export async function checkSystem(d,h){const D=S,[p,Z]=await Promise['allSettled']([h['pg']['query']('SELECT\x201'),h['redis'][D(0xd4)]()]);return{'status':p[D(0xd5)]===D(0xd6)&&Z['status']==='fulfilled'?'ok':'degraded','pg':p['status'],'redis':Z['status']};}function v(){const u=['ping','status','fulfilled'];v=function(){return u;};return v();}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
export interface AccessRecord {
|
|
3
|
+
resource: string | null;
|
|
4
|
+
actions: string[] | null;
|
|
5
|
+
role: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function getAccess(params: {
|
|
8
|
+
type: "user" | "role";
|
|
9
|
+
id: string;
|
|
10
|
+
user: User;
|
|
11
|
+
}, ctx: AppContext): Promise<{
|
|
12
|
+
access: AccessRecord[];
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=get-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAkBrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export async function getAccess(d,h){const p=d['type']==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20',Z=await h['pg']['query'](p,[d['id']]);return{'access':Z['rows']};}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* Implements the get API list application service for the System module.
|
|
3
3
|
*/
|
|
4
4
|
import type { AppContext, User } from "../../../context.js";
|
|
5
|
+
import type { ApiRoute } from "../../../type.js";
|
|
5
6
|
export declare function getApiList(params: {
|
|
6
7
|
user: User;
|
|
7
|
-
|
|
8
|
+
apiRoutes: ReadonlyMap<string, ApiRoute>;
|
|
9
|
+
format?: "short" | "extended";
|
|
10
|
+
}, ctx: AppContext): Promise<ApiRoute[] | string[]>;
|
|
8
11
|
//# sourceMappingURL=get-api-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-api-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-api-list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-api-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-api-list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,kBAAkB,CAAC;AAEhE,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,CAWhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(d,h){d=d-0x1d1;const p=v();let Z=p[d];return Z;}export async function getApiList(d,h){const X=S,p=[...d['apiRoutes']['values']()][X(0x1d1)]((Z,D)=>(Z['endpoint']+'\x20'+Z[X(0x1d2)])['localeCompare'](D[X(0x1d3)]+'\x20'+D['method']));if(d['format']!==X(0x1d4))return p;return p['map'](({method:Z,endpoint:D,access:u,permissions:n})=>Z+'\x20'+D);}function v(){const Y=['sort','method','endpoint','short'];v=function(){return Y;};return v();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAcd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getAuditLog(d,h){const u=S,p=Math['min'](Math['max'](d['limit']??0x32,0x1),0xc8),Z=Math['max']((d['page']??0x1)-0x1,0x0)*p,D=await h['pg'][u(0x122)]('SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[p,Z]);return{'rows':D['rows'],'page':d[u(0x123)]??0x1,'limit':p};}function S(d,h){d=d-0x122;const p=v();let Z=p[d];return Z;}function v(){const n=['query','page'];v=function(){return n;};return v();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function v(){var Z=['dictionary'];v=function(){return Z;};return v();}function S(d,h){d=d-0xec;var p=v();var Z=p[d];return Z;}export async function getDictionary(d,h){var p=S;return h[p(0xec)]['get'](d['name']);}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
export interface LogResult {
|
|
3
|
+
contentType: string;
|
|
4
|
+
body: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function getSystemLog(params: {
|
|
7
|
+
path?: string;
|
|
8
|
+
user: User;
|
|
9
|
+
}, ctx: AppContext): Promise<LogResult>;
|
|
6
10
|
//# sourceMappingURL=get-system-log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-system-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-system-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-log.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAc5D,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACrC,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,SAAS,CAAC,CA0CpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const K=S;import d from'node:fs/promises';function v(){const U=['resolve','catch','Log\x20path\x20not\x20found','isDirectory','map','name','localeCompare','slice','join','unshift','?path=','<li><a\x20href=\x22','logs/','</h1>\x0a<ul>\x0a','\x0a</ul>\x0a</body>\x0a</html>','replace','<','Invalid\x20log\x20path','stat','min','toString','filter','length'];v=function(){return U;};return v();}import h from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=h[K(0xfb)](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(p,Z){const g=K,D=normalizePath(p['path']),u=h['resolve'](LOGS_ROOT,D);if(u!==LOGS_ROOT&&!u['startsWith'](LOGS_ROOT+h['sep']))throw new ValidationError('Invalid\x20log\x20path');const n=await d['stat'](u)[g(0xfc)](()=>null);if(!n)throw new NotFoundError(g(0xfd));if(n[g(0xfe)]()){const Y=await d['readdir'](u,{'withFileTypes':!![]}),w=await Promise['all'](Y[g(0xff)](async y=>{const s=g,Q=await d['stat'](h['join'](u,y['name']));return{'name':y[s(0x100)],'path':D?D+'/'+y['name']:y['name'],'type':y['isDirectory']()?'directory':'file','size':y[s(0xfe)]()?undefined:Q['size'],'modified':Q['mtime']['toISOString']()};}));w['sort']((y,Q)=>y[g(0x100)][g(0x101)](Q['name']));if(D){const y=D['split']('/')[g(0x102)](0x0,-0x1)[g(0x103)]('/');w[g(0x104)]({'name':'..','path':y,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(D,w)};}const X=await tailFile(u,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':X[g(0x103)]('\x0a')};}function renderDirectory(p,Z){const M=K,D=Z[M(0xff)](n=>{const O=M,X=O(0x105)+encodeURIComponent(n['path']),Y=n['type']==='directory'?n['name']+'/':n['name'];return O(0x106)+X+'\x22>'+escapeHtml(Y)+'</a></li>';})['join']('\x0a'),u=escapeHtml(M(0x107)+p);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+u+'</title></head>\x0a<body>\x0a<h1>'+u+M(0x108)+D+M(0x109);}function escapeHtml(p){const R=K;return p[R(0x10a)](/&/g,'&')['replace'](/</g,R(0x10b))['replace'](/>/g,'>')['replace'](/"/g,'"');}function normalizePath(p){const E=K,Z=(p??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(Z['split']('/')['some'](D=>D==='..'))throw new ValidationError(E(0x10c));return Z;}async function tailFile(p,Z){const J=K,D=await d['open'](p,'r');try{const {size:u}=await D[J(0x10d)](),n=0x40*0x400;let X=u,Y=Buffer['alloc'](0x0),w=0x0;while(X>0x0&&w<=Z){const Q=Math[J(0x10e)](n,X);X-=Q;const F=Buffer['alloc'](Q);await D['read'](F,0x0,Q,X),Y=Buffer['concat']([F,Y]),w+=countNewlines(F);}const y=Y[J(0x10f)]('utf8')['split']('\x0a')[J(0x110)](B=>B[J(0x111)]>0x0);return y['slice'](-Z)['reverse']();}finally{await D['close']();}}function S(d,h){d=d-0xfb;const p=v();let Z=p[d];return Z;}function countNewlines(p){let Z=0x0;for(const D of p){if(D===0xa)Z++;}return Z;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"get-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkBlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function S(d,h){d=d-0x19a;const p=v();let Z=p[d];return Z;}function v(){const w=['split','value'];v=function(){return w;};return v();}export async function getSystemSettings(d,h){const p=await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return p['rows']['reduce']((Z,D)=>{const Y=S,u=String(D['key'])[Y(0x19a)]('.');let n=Z;for(const X of u['slice'](0x0,-0x1)){n[X]??={},n=n[X];}return n[u['at'](-0x1)]=D[Y(0x19b)],Z;},{});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function listDictionaries(d,h){return h['dictionary']['list']();}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import { type AccessRecord } from "./get-access.js";
|
|
3
|
+
type AccessInput = {
|
|
4
|
+
resource: string;
|
|
5
|
+
actions: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function setAccess(params: {
|
|
8
|
+
type: "user" | "role";
|
|
9
|
+
id: string;
|
|
10
|
+
access: AccessInput[];
|
|
11
|
+
user: User;
|
|
12
|
+
}, ctx: AppContext): Promise<{
|
|
13
|
+
access: AccessRecord[];
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=set-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,KAAK,WAAW,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CA6CrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAccess}from'./get-access.js';function v(){const n=['query','user','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','ROLLBACK'];v=function(){return n;};return v();}function S(d,h){d=d-0x69;const p=v();let Z=p[d];return Z;}export async function setAccess(d,h){const u=S,p=await h['pg']['connect']();try{await p['query']('BEGIN');d['type']==='user'?await p[u(0x69)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[d['id']]):await p['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[d['id']]);for(const Z of d['access']){d['type']===u(0x6a)?await p['query']('INSERT\x20INTO\x20admin.role_access\x0a\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\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[Z['resource'],Z['actions'],d['id'],d['user']['id'],d[u(0x6a)]['id']]):await p[u(0x69)](u(0x6b),[Z['resource'],Z['actions'],d['id'],d[u(0x6a)]['id'],d[u(0x6a)]['id']]);}await p[u(0x69)]('COMMIT');}catch(D){await p['query'](u(0x6c));throw D;}finally{p['release']();}return getAccess(d,h);}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the update dictionary application service for the System module.
|
|
3
|
+
*/
|
|
4
|
+
import type { AppContext, User } from "../../../context.js";
|
|
5
|
+
import type { DictionaryItem } from "../../../plugins/dictionary.js";
|
|
6
|
+
export declare function updateDictionary(params: {
|
|
7
|
+
name: string;
|
|
8
|
+
items: DictionaryItem[];
|
|
9
|
+
user: User;
|
|
10
|
+
}, ctx: AppContext): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=update-dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-dictionary.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-dictionary.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EAC7D,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAI/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(d,h){d=d-0x1de;var p=v();var Z=p[d];return Z;}function v(){var Z=['put'];v=function(){return Z;};return v();}export async function updateDictionary(d,h){var p=S;return await h['dictionary'][p(0x1de)](d['name'],d['items']),{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,oBAAoB,CACxC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"update-system-settings.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/update-system-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,oBAAoB,CACxC,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAqB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function v(){const u=['keys','length','patch','Invalid\x20setting\x20key:\x20','stringify','user'];v=function(){return u;};return v();}function S(d,h){d=d-0x159;const p=v();let Z=p[d];return Z;}export async function updateSystemSettings(d,h){const D=S;if(!Object[D(0x159)](d['patch'])[D(0x15a)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [p,Z]of Object['entries'](d[D(0x15b)])){if(!p['trim']()||p['includes']('..'))throw new ValidationError(D(0x15c)+p);await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[p,JSON[D(0x15d)](Z),d[D(0x15e)]['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function S(d,h){d=d-0xda;var p=v();var Z=p[d];return Z;}export function requireAdmin(d,h){var p=S;if(!d)throw new ForbiddenError(p(0xda));if(d['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(d['type']!=='admin'&&h&&!d[p(0xdb)]?.['includes'](h))throw new ForbiddenError('Missing\x20permission:\x20'+h);}function v(){var Z=['User\x20required','permissions'];v=function(){return Z;};return v();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const safeUser=d=>{const D=S,h=['password','salt','secret','credentials'];return Object['fromEntries'](Object['entries'](d)['filter'](([p])=>!h[D(0x14d)](Z=>p['toLowerCase']()[D(0x14e)](Z))));};function S(d,h){d=d-0x14d;const p=v();let Z=p[d];return Z;}function v(){const u=['some','includes'];v=function(){return u;};return v();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(d){throw new UnsupportedError(d+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(d){const h=writeAudit(d);return{'write':h};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./audit.types.js';export*from'./audit.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const secretPattern=/password|token|secret|credential|salt/i;function v(){const B=['fromEntries','[REDACTED]','query','map','table_name','has','audit_log_data','Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled','oldValue','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20','userId','resourceId','rows','changes','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20'];v=function(){return B;};return v();}function clean(d){const w=S;if(Array['isArray'](d))return d['map'](clean);if(d&&typeof d==='object')return Object[w(0x170)](Object['entries'](d)['map'](([h,p])=>[h,secretPattern['test'](h)?w(0x171):clean(p)]));return d;}function S(d,h){d=d-0x170;const p=v();let Z=p[d];return Z;}export function writeAudit(d){let h,p;async function Z(){const y=S;if(!d['pg'])return![];if(h!==undefined)return h;return p??=d['pg'][y(0x172)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](D=>{const Q=y,u=new Set(D['rows'][Q(0x173)](n=>n[Q(0x174)]));return h=u['has']('audit_log')&&u[Q(0x175)](Q(0x176)),!h&&d['logger']['warn']({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...u]},Q(0x177)),h;})['catch'](D=>{return h=![],d['logger']['warn']({'err':D},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),p;}return async function D(u){const F=S;if(!await Z())return d['logger']['info']({'auditFallback':!![],'event':clean({...u,'changes':u['changes']?.[F(0x173)](Y=>({...Y,'oldValue':clean(Y[F(0x178)]),'newValue':clean(Y['newValue'])}))})},'audit'),0x0;if(!d['pg'])throw new Error('empty\x20pg');const n=await d['pg']['query'](F(0x179),[u[F(0x17a)]??null,u['module'],u['resource'],u[F(0x17b)]==null?null:String(u['resourceId']),u['fields']??null,u['action'],u['requestId']??null,u['ipAddress']??null,clean(u['metadata']??{})]),X=n[F(0x17c)][0x0]['id'];for(const Y of u[F(0x17d)]??[]){if(secretPattern['test'](Y['field']))continue;await d['pg']['query'](F(0x17e),[X,Y['field'],JSON['stringify'](clean(Y[F(0x178)])),JSON['stringify'](clean(Y['newValue']))]);}return X;};}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-user-permissions.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/get-user-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,GACnC,OAAO,CAAC,MAAM,EAAE,CAAC,CAenB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function v(){const u=['query'];v=function(){return u;};return v();}function S(d,h){d=d-0x170;const p=v();let Z=p[d];return Z;}export async function getUserPermissions(d,h){const D=S,p=await h['pg'][D(0x170)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[d]);return p['rows']['map'](Z=>Z['permission']);}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from "./auth.types.js";
|
|
2
2
|
import { type FastifyInstance } from "fastify";
|
|
3
3
|
import { type ContextDependencies } from "../../context.js";
|
|
4
|
+
export * from "./verifyUser.js";
|
|
5
|
+
export * from "./get-user-permissions.js";
|
|
6
|
+
export declare function hashPassword(password: string): Promise<string>;
|
|
7
|
+
export declare function verifyPassword(password: string, stored: string): Promise<boolean>;
|
|
4
8
|
export declare function createSessionStore(app: FastifyInstance, ctx: ContextDependencies): Promise<void>;
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAUhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAI5D,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAE1C,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKpE;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,mBAAmB,iBA6CzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./auth.types.js';import{randomBytes,scrypt as d,timingSafeEqual}from'node:crypto';import{promisify}from'node:util';const scrypt=promisify(d);import h from'@fastify/cookie';import p from'@fastify/session';function S(d,h){d=d-0x97;const p=v();let Z=p[d];return Z;}import{Authenticator}from'@fastify/passport';import Z from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();export*from'./verifyUser.js';export*from'./get-user-permissions.js';function v(){const g=['hex','split','scrypt','from','length','warn','cookieOptions','register','cookieName','auth','database'];v=function(){return g;};return v();}export async function hashPassword(D){const F=S,u=randomBytes(0x10),n=await scrypt(D,u,0x40);return'scrypt$'+u['toString'](F(0x97))+'$'+n['toString']('hex');}export async function verifyPassword(D,u){const B=S,[n,X,Y]=u?.[B(0x98)]('$')||[];if(n!==B(0x99)||!X||!Y)return![];const w=Buffer['from'](X,'hex'),y=Buffer[B(0x9a)](Y,B(0x97)),Q=await scrypt(D,w,y[B(0x9b)]);return timingSafeEqual(Q,y);}export async function createSessionStore(D,u){const K=S,{config:n,redis:X}=u;if(!n||!X){console[K(0x9c)]('Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await D['register'](h,{'parseOptions':n['auth'][K(0x9d)]}),await D[K(0x9e)](p,{'secret':n['auth']['secret'],'cookieName':n['auth'][K(0x9f)],'cookie':n['auth']['cookieOptions'],'store':new Z({'prefix':n[K(0xa0)]['cookieName']+':'+(n['pg']?.[K(0xa1)]||'db')+':','client':X})}),await D[K(0x9e)](fastifyPassport['initialize']()),await D['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async Y=>({'user':Y})),fastifyPassport['registerUserDeserializer'](async Y=>{const w=Y?.['user']||Y;return w?.['id']&&(w['permissions']=await getUserPermissions(w['id'],u)),w;});}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContextDependencies } from "../../context.js";
|
|
2
|
+
type params = {
|
|
3
|
+
user: string;
|
|
4
|
+
password: string;
|
|
5
|
+
ip?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function verifyUser({ user, password, ip, }: params, { pg, logger }: Pick<ContextDependencies, "pg" | "logger">): Promise<import("./auth.types.js").AuthUser>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=verifyUser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyUser.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/verifyUser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAQ,MAAM,kBAAkB,CAAC;AAI7D,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,UAAU,CAC9B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,MAAM,EAC/B,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,QAAQ,CAAC,+CAgC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function v(){const Q=['not\x20enough\x20params:\x20user','user.login','select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201','query','rows','auth/warn','password_hash','Wrong\x20password'];v=function(){return Q;};return v();}import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';function S(d,h){d=d-0x11f;const p=v();let Z=p[d];return Z;}export async function verifyUser({user:d,password:h,ip:p},{pg:Z,logger:D}){const y=S;if(!d||d==='')throw new BadRequestError(y(0x11f));if(!h||h==='')throw new BadRequestError('not\x20enough\x20params:\x20password');D['metrics'](y(0x120));const u=y(0x121),n=await Z[y(0x122)](u,[d])['then'](Y=>Y[y(0x123)]?.[0x0]);if(!n){const Y='user\x20not\x20found';D['info']({'file':y(0x124),'error':Y,'user':d,'ip':p});throw new BadRequestError(Y);}const X=await verifyPassword(h,n[y(0x125)]);if(!X){const w=y(0x126);D['info']({'file':'auth/warn','error':w,'user':d,'ip':p});throw new BadRequestError(w);}return delete n['password_hash'],n;}
|
|
@@ -9,13 +9,16 @@ export interface DictionaryItem {
|
|
|
9
9
|
export interface DictionaryDefinition {
|
|
10
10
|
code: string;
|
|
11
11
|
name?: string;
|
|
12
|
+
checked?: boolean;
|
|
12
13
|
items: DictionaryItem[];
|
|
13
14
|
}
|
|
14
15
|
export interface DictionaryPlugin {
|
|
15
16
|
register(input: DictionaryDefinition | DictionaryDefinition[]): void;
|
|
17
|
+
has(name: string): boolean;
|
|
16
18
|
get(name: string): Promise<DictionaryItem[]>;
|
|
17
19
|
put(name: string, items: DictionaryItem[]): Promise<void>;
|
|
18
20
|
clear(name: string): boolean;
|
|
21
|
+
revision(name: string): number;
|
|
19
22
|
list(): Promise<Array<{
|
|
20
23
|
code: string;
|
|
21
24
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/plugins/dictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,IAAI,IAAI,OAAO,CACb,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAAE,CAAC,CACrE,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,EAAE,EACF,YAAiB,GAClB,EAAE,sBAAsB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/plugins/dictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,IAAI,OAAO,CACb,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAA;KAAE,CAAC,CACrE,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACvC;AAID,wBAAgB,gBAAgB,CAAC,EAC/B,EAAE,EACF,YAAiB,GAClB,EAAE,sBAAsB,GAAG,gBAAgB,CAkN3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function S(d,h){d=d-0x8f;const p=v();let Z=p[d];return Z;}const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:d,dictionaries:dictionaries=[]}){const h=new Map(),p=new Map();let Z,D;async function u(){const U=S;if(Z!==undefined)return Z;if(!d)throw new Error('empty\x20pg');return D??=d['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')[U(0x8f)](K=>{const I=U,g=K[I(0x90)][0x0]?.[I(0x91)];Z=g==='dictionaries'?g:null;}),await D,Z;}function n(K){if(!dictionaryName['test'](K))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+K);}function X(K){const k=S;for(const g of Array[k(0x92)](K)?K:[K]){n(g[k(0x93)]);if(!Array[k(0x92)](g[k(0x94)]))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+g[k(0x93)]);if(h['has'](g[k(0x93)]))throw new ConflictError(k(0x95)+g[k(0x93)]);h[k(0x96)](g['code'],{...g,'source':'static'});}}function Y(K){const c=S;return h[c(0x97)](K);}async function w(K){const q=S;n(K);const g=h[q(0x98)](K);if(g&&g['checked'])return g['items'];const s=await u();if(!s)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const M=await d?.['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[K]);if(M?.['rows']?.['length']){const O=M?.['rows'];return h['set'](K,{'code':K,'name':K,'items':O,'source':q(0x99),'checked':!![]}),O;}if(!g?.[q(0x94)])throw new NotFoundError(q(0x9a)+K);return g[q(0x9b)]=!![],g['items'];}async function y(K,g){const j=S;n(K);if(!Array['isArray'](g))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const s=await u();if(!s)throw new NotFoundError(j(0x9c));if(!d)throw new Error('empty\x20pg');const M=await d[j(0x9d)]();try{await M['query']('BEGIN');const O=await M[j(0x9e)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[K,K,'fcore','custom',!![]]),R=O['rows'][0x0]['id'];await M['query'](j(0x9f),[R]);for(const E of g){await M[j(0x9e)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[R,E['code'],E[j(0xa0)],E['parentId']??null]);}await M['query']('COMMIT');}catch(J){await M['query'](j(0xa1));throw J;}finally{M['release']();}h['set'](K,{'items':g,'code':K,'source':'static','checked':!![]}),p[j(0x96)](K,(p['get'](K)??0x0)+0x1);}function Q(K){return n(K),p['set'](K,(p['get'](K)??0x0)+0x1),h['delete'](K);}function F(K){return p['get'](K)??0x0;}async function B(){const P=S,K=[...h['values']()][P(0xa2)](({code:M,name:O,source:R})=>({'code':M,'name':O??M,'source':R})),g=await u();if(!g)return K;if(!d)throw new Error(P(0xa3));const s=await d[P(0x9e)](P(0xa4));for(const M of s[P(0x90)]){!h['has'](M['code'])&&K['push'](M);}return K;}return X(dictionaries),{'register':X,'get':w,'put':y,'clear':Q,'revision':F,'list':B,'has':Y};}function v(){const L=['then','rows','table_name','isArray','code','items','Dictionary\x20already\x20registered:\x20','set','has','get','database','Dictionary\x20not\x20found:\x20','checked','Dictionary\x20table\x20not\x20found','connect','query','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','name','ROLLBACK','map','empty\x20pg','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20'];v=function(){return L;};return v();}
|
package/dist/plugins/file.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the S3-compatible file storage adapter and its contracts.
|
|
3
3
|
*/
|
|
4
|
+
import type { Readable } from "node:stream";
|
|
4
5
|
export interface FileAdapter {
|
|
5
|
-
put(path: string,
|
|
6
|
+
put(path: string, body: Buffer | Readable): Promise<void>;
|
|
6
7
|
get(path: string): Promise<Buffer>;
|
|
7
8
|
exists(path: string): Promise<boolean>;
|
|
8
9
|
delete(path: string): Promise<void>;
|
|
9
10
|
create(path: string, ttl?: number): string;
|
|
10
|
-
verify(token: string):
|
|
11
|
-
}
|
|
12
|
-
export interface FileTokenPayload {
|
|
13
|
-
p: string;
|
|
14
|
-
exp: number;
|
|
11
|
+
verify(token: string): string;
|
|
15
12
|
}
|
|
16
13
|
export interface FileS3Config {
|
|
17
14
|
endpoint?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAKD,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAgCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import d from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function keyFor(h,p){const Q=S;if(!p||p['startsWith']('/')||p['includes']('..'))throw new ValidationError(Q(0xcd));const Z=p['replace'](/\\/g,'/')[Q(0xce)](/^\/+/,''),D=(h??'')[Q(0xce)](/^\/+|\/+$/g,'');return D?D+'/'+Z:Z;}function S(d,h){d=d-0xcd;const p=v();let Z=p[d];return Z;}async function bodyToBuffer(h){if(!h)return Buffer['alloc'](0x0);const p=h;if(typeof p['transformToByteArray']==='function')return Buffer['from'](await p['transformToByteArray']());const Z=[];for await(const D of h){Z['push'](Buffer['from'](D));}return Buffer['concat'](Z);}function v(){const R=['Invalid\x20file\x20path','replace','toString','region','us-east-1','forcePathStyle','accessKey','bucket','send','$metadata','from','update','timingSafeEqual','base64url'];v=function(){return R;};return v();}export function createFileS3(h){const F=S,p=h['tokenSecret']??process.env.FILE_TOKEN_SECRET??d['randomBytes'](0x20)[F(0xcf)]('hex'),Z=new S3Client({'endpoint':h['endpoint'],'region':h[F(0xd0)]??F(0xd1),'forcePathStyle':h[F(0xd2)]??!![],'credentials':h['accessKeyId']||h[F(0xd3)]?{'accessKeyId':h['accessKeyId']??h['accessKey'],'secretAccessKey':h['secretAccessKey']??h['secretKey']}:undefined}),D=u=>keyFor(h['folder'],u);return{async 'put'(u,n){const B=F;await Z['send'](new PutObjectCommand({'Bucket':h[B(0xd4)],'Key':D(u),'Body':n}));},async 'get'(u){const K=F,n=await Z[K(0xd5)](new GetObjectCommand({'Bucket':h['bucket'],'Key':D(u)}));return bodyToBuffer(n['Body']);},async 'exists'(u){const g=F;try{return await Z['send'](new HeadObjectCommand({'Bucket':h[g(0xd4)],'Key':D(u)})),!![];}catch(n){const X=n;if(X[g(0xd6)]?.['httpStatusCode']===0x194||X['name']==='NotFound')return![];throw n;}},async 'delete'(u){const s=F;await Z[s(0xd5)](new DeleteObjectCommand({'Bucket':h['bucket'],'Key':D(u)}));},'create'(u,n=h['tokenTtl']??0xe10){const M=F,X=Buffer[M(0xd7)](u)['toString']('base64url'),Y=d['createHmac']('sha256',p)[M(0xd8)](X)['digest']('base64url');return X+'.'+Y;},'verify'(u){const O=F,[n,X]=u['split']('.');if(!n||!X)throw new UnauthorizedError('Invalid\x20file\x20token');const Y=d['createHmac']('sha256',p)['update'](n)['digest'](),w=Buffer['from'](X,'base64url');if(Y['length']!==w['length']||!d[O(0xd9)](Y,w))throw new UnauthorizedError('Invalid\x20file\x20token');const y=Buffer['from'](n,O(0xda))['toString']('utf8');return y;}};}
|