@opengis/fcore 0.0.1-beta.9 → 0.0.28
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 +1 -0
- 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 +0 -3
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.d.ts.map +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +2 -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.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.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.d.ts.map +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.d.ts +19 -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.js +1 -1
- package/dist/modules/resource/services/create-resource.js +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/generate-resource-code.d.ts +16 -0
- package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
- package/dist/modules/resource/services/generate-resource-code.js +1 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
- package/dist/modules/resource/services/get-resource-schema.js +1 -0
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
- package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-as-user.js +1 -0
- package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
- package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-list.js +1 -0
- 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.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.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.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +25 -2
- 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.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +1 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -1
- package/dist/modules/system/services/get-access.js +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-resource-access.d.ts +23 -0
- package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-access.js +1 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-scopes.js +1 -0
- 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 +3 -1
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.d.ts +18 -0
- package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-access.js +1 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-scopes.js +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +7 -3
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.d.ts.map +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts +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.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +66 -14
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +5 -2
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- 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 +6 -3
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts +9 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- 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/get-table-columns.d.ts +8 -0
- package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
- package/dist/plugins/resource/services/get-table-columns.js +1 -0
- package/dist/plugins/resource/services/update-relation.d.ts +5 -2
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts +9 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +2 -1
- 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.js +1 -1
- package/dist/plugins/resource/utils/scope.d.ts +10 -0
- package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
- package/dist/plugins/resource/utils/scope.js +1 -0
- package/dist/plugins/resource/utils/sort.d.ts +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +7 -0
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
- package/dist/plugins/resource/utils/summary.js +1 -0
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903120000_core_schema.sql +5 -2
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +93 -93
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppContext } from "../../../context.js";
|
|
2
|
+
export interface ResourceUserAccess {
|
|
3
|
+
type: "user";
|
|
4
|
+
uid: string;
|
|
5
|
+
actions: string[];
|
|
6
|
+
scopes?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ResourceRoleAccess {
|
|
9
|
+
type: "role";
|
|
10
|
+
role_id: string;
|
|
11
|
+
name: string | null;
|
|
12
|
+
actions: string[];
|
|
13
|
+
users_count: number;
|
|
14
|
+
scopes?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export declare function getResourceAccess(params: {
|
|
17
|
+
resource: string;
|
|
18
|
+
}, ctx: AppContext): Promise<{
|
|
19
|
+
resource: string;
|
|
20
|
+
users: ResourceUserAccess[];
|
|
21
|
+
roles: ResourceRoleAccess[];
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=get-resource-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resource-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-resource-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AASD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B,CAAC,CA0ED"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(p,Z){p=p-0xaa;const A=s();let I=A[p];return I;}export async function getResourceAccess(p,Z){const K=f,[A,I,j]=await Promise['all']([Z['pg']['query'](K(0xaa),[p[K(0xab)]]),Z['pg'][K(0xac)](K(0xad),[p[K(0xab)]]),Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE',[p['resource']])]),D=new Map(),o=new Map();for(const H of j['rows']){if(H['user_id']!==null){const e=D[K(0xae)](H['user_id'])??{};e[H['scope']]=H[K(0xaf)],D[K(0xb0)](H['user_id'],e);}else{if(H['role_id']!==null){const g=o['get'](H['role_id'])??{};g[H['scope']]=H['value'],o[K(0xb0)](H['role_id'],g);}}}const R=A['rows'][K(0xb1)](N=>({...N,...D['has'](N[K(0xb2)])?{'scopes':D[K(0xae)](N['uid'])}:{}}));for(const [N,h]of D){!R['some'](E=>E[K(0xb2)]===N)&&R[K(0xb3)]({'type':'user','uid':N,'actions':[],'scopes':h});}const B=I['rows']['map'](E=>({...E,...o['has'](E['role_id'])?{'scopes':o['get'](E['role_id'])}:{}}));for(const [E,a]of o){!B['some'](X=>X['role_id']===E)&&B['push']({'type':'role','role_id':E,'name':null,'actions':[],'users_count':0x0,'scopes':a});}return{'resource':p[K(0xab)],'users':R,'roles':B};}function s(){const Q=['SELECT\x20\x27user\x27::text\x20AS\x20type,\x20user_uid\x20AS\x20uid,\x20actions\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20user_uid','resource','query','SELECT\x20\x27role\x27::text\x20AS\x20type,\x20ra.role_id,\x20r.name,\x20ra.actions,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(DISTINCT\x20ur.user_uid)::int\x20AS\x20users_count\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.roles\x20r\x20ON\x20r.role_id\x20=\x20ra.role_id\x0a\x20\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\x20\x20WHERE\x20ra.resource\x20=\x20$1\x20AND\x20ra.role_id\x20IS\x20NOT\x20NULL\x20AND\x20ra.user_uid\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20GROUP\x20BY\x20ra.role_id,\x20r.name,\x20ra.actions\x0a\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20r.name,\x20ra.role_id','get','value','set','map','uid','push'];s=function(){return Q;};return s();}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppContext } from "../../../context.js";
|
|
2
|
+
export declare function getResourceScopes(params: {
|
|
3
|
+
resource: string;
|
|
4
|
+
}, ctx: AppContext): Promise<{
|
|
5
|
+
resource: string;
|
|
6
|
+
users: Array<{
|
|
7
|
+
user_id: string;
|
|
8
|
+
role_id: string | null;
|
|
9
|
+
scopes: Record<string, unknown>;
|
|
10
|
+
}>;
|
|
11
|
+
roles: Array<{
|
|
12
|
+
role_id: string;
|
|
13
|
+
scopes: Record<string, unknown>;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=get-resource-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resource-scopes.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-resource-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAStD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3F,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACpE,CAAC,CAoCD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(){const e=['role_id','set','resource','values'];s=function(){return e;};return s();}function f(p,Z){p=p-0x1e7;const A=s();let I=A[p];return I;}export async function getResourceScopes(p,Z){const H=f,{rows:A}=await Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20role_id,\x20user_id\x20NULLS\x20FIRST,\x20scope',[p['resource']]),I=new Map(),j=new Map();for(const D of A){if(D['user_id']!==null){const o=D['user_id']+':'+(D['role_id']??''),R=I['get'](o)??{'user_id':D['user_id'],'role_id':D[H(0x1e7)],'scopes':{}};R['scopes'][D['scope']]=D['value'],I['set'](o,R);continue;}if(D['role_id']!==null){const B=j['get'](D['role_id'])??{'role_id':D['role_id'],'scopes':{}};B['scopes'][D['scope']]=D['value'],j[H(0x1e8)](D['role_id'],B);}}return{'resource':p[H(0x1e9)],'users':[...I['values']()],'roles':[...j[H(0x1ea)]()]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function f(p,Z){p=p-0x1d1;const A=s();let I=A[p];return I;}import p from'node:fs/promises';import Z from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=Z['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(A,I){const E=f,j=normalizePath(A['path']),D=Z['resolve'](LOGS_ROOT,j);if(D!==LOGS_ROOT&&!D['startsWith'](LOGS_ROOT+Z[E(0x1d1)]))throw new ValidationError('Invalid\x20log\x20path');const o=await p['stat'](D)['catch'](()=>null);if(!o)throw new NotFoundError('Log\x20path\x20not\x20found');if(o[E(0x1d2)]()){const B=await p['readdir'](D,{'withFileTypes':!![]}),H=await Promise['all'](B['map'](async e=>{const a=E,g=await p['stat'](Z['join'](D,e['name']));return{'name':e['name'],'path':j?j+'/'+e['name']:e['name'],'type':e['isDirectory']()?'directory':'file','size':e['isDirectory']()?undefined:g['size'],'modified':g[a(0x1d3)]['toISOString']()};}));H['sort']((e,g)=>e['name'][E(0x1d4)](g['name']));if(j){const e=j['split']('/')['slice'](0x0,-0x1)[E(0x1d5)]('/');H['unshift']({'name':'..','path':e,'type':'directory'});}return{'contentType':E(0x1d6),'body':renderDirectory(j,H)};}const R=await tailFile(D,TAIL_LINES);return{'contentType':E(0x1d7),'body':R[E(0x1d5)]('\x0a')};}function renderDirectory(A,I){const K=f,j=I['map'](o=>{const X=f,R=X(0x1d8)+encodeURIComponent(o['path']),B=o['type']==='directory'?o[X(0x1d9)]+'/':o['name'];return'<li><a\x20href=\x22'+R+'\x22>'+escapeHtml(B)+'</a></li>';})[K(0x1d5)]('\x0a'),D=escapeHtml('logs/'+A);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+D+K(0x1da)+D+K(0x1db)+j+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(A){const Q=f;return A['replace'](/&/g,'&')[Q(0x1dc)](/</g,Q(0x1dd))['replace'](/>/g,Q(0x1de))[Q(0x1dc)](/"/g,Q(0x1df));}function normalizePath(A){const G=f,I=(A??'')[G(0x1dc)](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(I['split']('/')['some'](j=>j==='..'))throw new ValidationError('Invalid\x20log\x20path');return I;}async function tailFile(A,I){const V=f,j=await p[V(0x1e0)](A,'r');try{const {size:D}=await j['stat'](),o=0x40*0x400;let R=D,B=Buffer['alloc'](0x0),H=0x0;while(R>0x0&&H<=I){const g=Math['min'](o,R);R-=g;const N=Buffer['alloc'](g);await j['read'](N,0x0,g,R),B=Buffer['concat']([N,B]),H+=countNewlines(N);}const e=B['toString']('utf8')['split']('\x0a')['filter'](h=>h['length']>0x0);return e[V(0x1e1)](-I)['reverse']();}finally{await j['close']();}}function countNewlines(A){let I=0x0;for(const j of A){if(j===0xa)I++;}return I;}function s(){const O=['sep','isDirectory','mtime','localeCompare','join','text/html;\x20charset=utf-8','text/plain;\x20charset=utf-8','?path=','name','</title></head>\x0a<body>\x0a<h1>','</h1>\x0a<ul>\x0a','replace','<','>','"','open','slice'];s=function(){return O;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getSystemSettings(
|
|
1
|
+
export async function getSystemSettings(p,Z){const B=f,A=await Z['pg'][B(0xfe)]('\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 A['rows']['reduce']((I,j)=>{const D=String(j['key'])['split']('.');let o=I;for(const R of D['slice'](0x0,-0x1)){o[R]??={},o=o[R];}return o[D['at'](-0x1)]=j['value'],I;},{});}function f(p,Z){p=p-0xfe;const A=s();let I=A[p];return I;}function s(){const H=['query'];s=function(){return H;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listDictionaries(
|
|
1
|
+
export async function listDictionaries(p,Z){return Z['dictionary']['list']();}
|
|
@@ -7,7 +7,9 @@ type AccessInput = {
|
|
|
7
7
|
export declare function setAccess(params: {
|
|
8
8
|
type: "user" | "role";
|
|
9
9
|
id: string;
|
|
10
|
-
access
|
|
10
|
+
access?: AccessInput[];
|
|
11
|
+
permissions?: string[];
|
|
12
|
+
roles?: string[];
|
|
11
13
|
user: User;
|
|
12
14
|
}, ctx: AppContext): Promise<{
|
|
13
15
|
access: AccessRecord[];
|
|
@@ -1 +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;
|
|
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;AAC5D,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;AAoBF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAiErC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0xf9;const A=s();let I=A[p];return I;}const e=f;import{getAccess}from'./get-access.js';function s(){const h=['read','update','create','split','map','BEGIN','user','roles','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)','resource','actions'];s=function(){return h;};return s();}const CRUD_ACTIONS=[e(0xf9),e(0xfa),e(0xfb),'delete'];function permissionsToAccess(p){const g=e,Z=new Map();for(const A of p){const [I,j]=A[g(0xfc)](':');if(!I)continue;const D=j==='edit'?'update':j,o=Z['get'](I)??new Set();for(const R of D?[D]:CRUD_ACTIONS)o['add'](R);Z['set'](I,o);}return[...Z][g(0xfd)](([B,H])=>({'resource':B,'actions':[...H]}));}export async function setAccess(p,Z){const N=e,A=await Z['pg']['connect']();try{await A['query'](N(0xfe));if(p['type']===N(0xff)){await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[p['id']]);if(p[N(0x100)]!==undefined){await A['query']('DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1',[p['id']]);for(const j of p[N(0x100)]){await A[N(0x101)]('INSERT\x20INTO\x20admin.user_roles\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(user_uid,\x20role_id,\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)',[p['id'],j,p[N(0xff)]['id'],p['user']['id']]);}}}else await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[p['id']]);const I=p['permissions']?permissionsToAccess(p['permissions']):p['access']??[];for(const D of I){p['type']==='user'?await A['query'](N(0x102),[D[N(0x103)],D['actions'],p['id'],p['user']['id'],p[N(0xff)]['id']]):await A['query']('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)',[D[N(0x103)],D[N(0x104)],p['id'],p['user']['id'],p['user']['id']]);}await A[N(0x101)]('COMMIT');}catch(o){await A['query']('ROLLBACK');throw o;}finally{A['release']();}return getAccess(p,Z);}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import { getResourceAccess } from "./get-resource-access.js";
|
|
3
|
+
interface UserAccessInput {
|
|
4
|
+
uid: string;
|
|
5
|
+
actions: string[];
|
|
6
|
+
}
|
|
7
|
+
interface RoleAccessInput {
|
|
8
|
+
role_id: string;
|
|
9
|
+
actions: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function setResourceAccess(params: {
|
|
12
|
+
resource: string;
|
|
13
|
+
users?: UserAccessInput[];
|
|
14
|
+
roles?: RoleAccessInput[];
|
|
15
|
+
user: User;
|
|
16
|
+
}, ctx: AppContext): ReturnType<typeof getResourceAccess>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=set-resource-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-resource-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAsEtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x6d;const A=s();let I=A[p];return I;}function s(){const g=['roles','uid','has','role_id','query','length','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\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$4)','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\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$4)','resource'];s=function(){return g;};return s();}import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(p,Z){const e=f;if(p['users']===undefined&&p[e(0x6d)]===undefined)throw new ValidationError('At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided');const A=new Set();for(const D of p['users']??[]){if(A['has'](D['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+D['uid']);A['add'](D[e(0x6e)]);}const I=new Set();for(const o of p[e(0x6d)]??[]){if(I[e(0x6f)](o['role_id']))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+o['role_id']);I['add'](o[e(0x70)]);}const j=await Z['pg']['connect']();try{await j[e(0x71)]('BEGIN');if(p['users']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[p['resource']]);for(const R of p['users']){if(R['actions'][e(0x72)]===0x0)continue;await j['query'](e(0x73),[p['resource'],R['actions'],R['uid'],p['user']['id']]);}}if(p['roles']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[p['resource']]);for(const B of p['roles']){if(B[e(0x74)]['length']===0x0)continue;await j[e(0x71)](e(0x75),[p[e(0x76)],B['actions'],B['role_id'],p['user']['id']]);}}await j[e(0x71)]('COMMIT');}catch(H){await j['query']('ROLLBACK');throw H;}finally{j['release']();}return getResourceAccess({'resource':p['resource']},Z);}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import { getResourceScopes } from "./get-resource-scopes.js";
|
|
3
|
+
export declare function setResourceScopes(params: {
|
|
4
|
+
resource: string;
|
|
5
|
+
user_id?: string;
|
|
6
|
+
role_id?: string;
|
|
7
|
+
scopes: Record<string, unknown>;
|
|
8
|
+
user: User;
|
|
9
|
+
}, ctx: AppContext): ReturnType<typeof getResourceScopes>;
|
|
10
|
+
//# sourceMappingURL=set-resource-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-resource-scopes.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CA6CtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function s(){const R=['Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id','keys','BEGIN','query','COMMIT','ROLLBACK','release'];s=function(){return R;};return s();}import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';function f(p,Z){p=p-0x16d;const A=s();let I=A[p];return I;}import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(p,Z){const o=f;if(Boolean(p['user_id'])===Boolean(p['role_id']))throw new ValidationError(o(0x16d));if(Object[o(0x16e)](p['scopes'])['length']===0x0)throw new ValidationError('At\x20least\x20one\x20scope\x20must\x20be\x20provided');const A=await Z['pg']['connect']();try{await A['query'](o(0x16f)),await A['query']('DELETE\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20role_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20user_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$3',[p['resource'],p['role_id']??null,p['user_id']??null]);for(const [I,j]of Object['entries'](p['scopes'])){await A[o(0x170)]('INSERT\x20INTO\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20role_id,\x20user_id,\x20scope,\x20value,\x20enabled,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5::jsonb,\x20TRUE,\x20$6,\x20$6)',[p['resource'],p['role_id']??null,p['user_id']??null,I,JSON['stringify'](j),p['user']['id']]);}await A['query'](o(0x171));}catch(D){await A['query'](o(0x172));throw D;}finally{A[o(0x173)]();}return clearResourceScopeCache(),getResourceScopes({'resource':p['resource']},Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateDictionary(
|
|
1
|
+
function s(){var I=['dictionary','items'];s=function(){return I;};return s();}function f(p,Z){p=p-0xc7;var A=s();var I=A[p];return I;}export async function updateDictionary(p,Z){var A=f;return await Z[A(0xc7)]['put'](p['name'],p[A(0xc8)]),{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function s(){const D=['patch','length','entries','user'];s=function(){return D;};return s();}function f(p,Z){p=p-0x135;const A=s();let I=A[p];return I;}export async function updateSystemSettings(p,Z){const j=f;if(!Object['keys'](p[j(0x135)])[j(0x136)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [A,I]of Object[j(0x137)](p['patch'])){if(!A['trim']()||A['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+A);await Z['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',[A,JSON['stringify'](I),p[j(0x138)]['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../errors.js';function
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function s(){var I=['permissions','Missing\x20permission:\x20'];s=function(){return I;};return s();}function f(p,Z){p=p-0x19c;var A=s();var I=A[p];return I;}export function requireAdmin(p,Z){var A=f;if(!p)throw new ForbiddenError('User\x20required');if(p['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p['type']!=='admin'&&Z&&!p[A(0x19c)]?.['includes'](Z))throw new ForbiddenError(A(0x19d)+Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){const D=['salt','entries','some','toLowerCase'];s=function(){return D;};return s();}function f(p,Z){p=p-0x154;const A=s();let I=A[p];return I;}export const safeUser=p=>{const j=f,Z=['password',j(0x154),'secret','credentials'];return Object['fromEntries'](Object[j(0x155)](p)['filter'](([A])=>!Z[j(0x156)](I=>A[j(0x157)]()['includes'](I))));};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';export function unsupported(
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(p){throw new UnsupportedError(p+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(p){const Z=writeAudit(p);return{'write':Z};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/audit/audit.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,WAAW,UAAU;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC1C,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/audit/audit.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,WAAW,UAAU;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AACD,MAAM,WAAW,WAAW;IACxB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const secretPattern=/password|token|secret|credential|salt/i;function f(p,Z){p=p-0x84;const A=s();let I=A[p];return I;}function clean(p){const H=f;if(Array['isArray'](p))return p[H(0x84)](clean);if(p&&typeof p==='object')return Object['fromEntries'](Object['entries'](p)[H(0x84)](([Z,A])=>[Z,secretPattern['test'](Z)?'[REDACTED]':clean(A)]));return p;}function s(){const E=['map','\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','audit_log','audit_log_data','logger','query','userId','resourceId','ipAddress','changes','field','stringify','newValue'];s=function(){return E;};return s();}export function writeAudit(p){let Z,A;async function I(){const e=f;if(!p['pg'])return![];if(Z!==undefined)return Z;return A??=p['pg']['query'](e(0x85))['then'](j=>{const g=e,D=new Set(j['rows']['map'](o=>o['table_name']));return Z=D['has'](g(0x86))&&D['has'](g(0x87)),!Z&&p[g(0x88)]['warn']({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...D]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),Z;})['catch'](j=>{const N=e;return Z=![],p[N(0x88)]['warn']({'err':j},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),A;}return async function j(D){const h=f;if(!await I())return p[h(0x88)]['info']({'auditFallback':!![],'event':clean({...D,'changes':D['changes']?.['map'](B=>({...B,'oldValue':clean(B['oldValue']),'newValue':clean(B['newValue'])}))})},'audit'),0x0;if(!p['pg'])throw new Error('empty\x20pg');const o=await p['pg'][h(0x89)]('\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',[D[h(0x8a)]??null,D['module'],D['resource'],D['resourceId']==null?null:String(D[h(0x8b)]),D['fields']??null,D['action'],D['requestId']??null,D[h(0x8c)]??null,clean(D['metadata']??{})]),R=o['rows'][0x0]['id'];for(const B of D[h(0x8d)]??[]){if(secretPattern['test'](B['field']))continue;await p['pg'][h(0x89)]('\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',[R,B[h(0x8e)],JSON[h(0x8f)](clean(B['oldValue'])),JSON['stringify'](clean(B[h(0x90)]))]);}return R;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getUserPermissions(
|
|
1
|
+
function f(p,Z){p=p-0x10d;const A=s();let I=A[p];return I;}export async function getUserPermissions(p,Z){const j=f,A=await Z['pg'][j(0x10d)]('\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',[p]);return A['rows']['map'](I=>I[j(0x10e)]);}function s(){const D=['query','permission'];s=function(){return D;};return s();}
|
|
@@ -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;AAYhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAwD5D,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,iBAmDzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./auth.types.js';import{randomBytes,scrypt as
|
|
1
|
+
export*from'./auth.types.js';import{randomBytes,scrypt as p,timingSafeEqual}from'node:crypto';import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';import{join,resolve}from'node:path';import{promisify}from'node:util';function s(){const G=['path','.json','fileFor','stringify','utf8','toString','hex','scrypt','from','warn','register','redis','host','auth','database','./storage','sessions','cookieName','secureSession','permissions'];s=function(){return G;};return s();}const scrypt=promisify(p);import Z from'@fastify/cookie';import A from'@fastify/session';import{Authenticator}from'@fastify/passport';function f(p,Z){p=p-0xc7;const A=s();let I=A[p];return I;}import I from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();class FileSessionStore{['path'];constructor(j){this['path']=j,void mkdir(this['path'],{'recursive':!![]});}['fileFor'](j){const N=f;return join(this[N(0xc7)],j+N(0xc8));}async['get'](j,D){try{const o=await readFile(this['fileFor'](j),'utf8');D(null,JSON['parse'](o));}catch(R){const B=R;if(B['code']==='ENOENT'){D(null,undefined);return;}D(B,undefined);}}async['set'](j,D,o){const h=f;try{await mkdir(this[h(0xc7)],{'recursive':!![]}),await writeFile(this[h(0xc9)](j),JSON[h(0xca)](D),h(0xcb)),o();}catch(R){o(R);}}async['destroy'](j,D){const E=f;try{await unlink(this[E(0xc9)](j))['catch'](o=>{if(o['code']!=='ENOENT')throw o;}),D();}catch(o){D(o);}}}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(j){const a=f,D=randomBytes(0x10),o=await scrypt(j,D,0x40);return'scrypt$'+D[a(0xcc)]('hex')+'$'+o['toString'](a(0xcd));}export async function verifyPassword(j,D){const X=f,[o,R,B]=D?.['split']('$')||[];if(o!==X(0xce)||!R||!B)return![];const H=Buffer['from'](R,X(0xcd)),e=Buffer[X(0xcf)](B,X(0xcd)),g=await scrypt(j,H,e['length']);return timingSafeEqual(g,e);}export async function createSessionStore(j,D){const K=f,{config:o,redis:R}=D;if(!o){console[K(0xd0)]('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await j[K(0xd1)](Z,{'parseOptions':o['auth']['cookieOptions']});const B=o[K(0xd2)][K(0xd3)]?new I({'prefix':o[K(0xd4)]['cookieName']+':'+(o['pg']?.[K(0xd5)]||'db')+':','client':R}):new FileSessionStore(resolve(o['storagePath']??K(0xd6),K(0xd7)));await j[K(0xd1)](A,{'secret':o[K(0xd4)]['secret'],'cookieName':o['auth'][K(0xd8)],'cookie':o['auth']['cookieOptions'],'store':B}),await j[K(0xd1)](fastifyPassport['initialize']()),await j['register'](fastifyPassport[K(0xd9)]()),fastifyPassport['registerUserSerializer'](async H=>({'user':H})),fastifyPassport['registerUserDeserializer'](async H=>{const Q=K,e=H?.['user']||H;return e?.['id']&&(e[Q(0xda)]=await getUserPermissions(e['id'],D)),e;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{BadRequestError}from'../../errors.js';function f(p,Z){p=p-0xd8;const A=s();let I=A[p];return I;}function s(){const g=['select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa,\x20first_name,\x20middle_name,last_name,email,phone,avatar,last_activity_date\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201','then','auth/warn','update\x20admin.users\x20set\x20last_activity_date\x20=\x20now()\x20where\x20uid\x20=\x20$1','password_hash'];s=function(){return g;};return s();}import{verifyPassword}from'./index.js';export async function verifyUser({user:p,password:Z,ip:A},{pg:I,logger:j}){const e=f;if(!p||p==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!Z||Z==='')throw new BadRequestError('not\x20enough\x20params:\x20password');j['metrics']('user.login');const D=e(0xd8),o=await I['query'](D,[p])[e(0xd9)](B=>B['rows']?.[0x0]);if(!o){const B='user\x20not\x20found';j['info']({'file':e(0xda),'error':B,'user':p,'ip':A});throw new BadRequestError(B);}const R=await verifyPassword(Z,o['password_hash']);if(!R){const H='Wrong\x20password';j['info']({'file':'auth/warn','error':H,'user':p,'ip':A});throw new BadRequestError(H);}return I['query'](e(0xdb),[o['id']]),delete o[e(0xdc)],o;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';
|
|
1
|
+
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function f(p,Z){p=p-0x1a3;const A=s();let I=A[p];return I;}function s(){const m=['\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','then','rows','table_name','isArray','code','Dictionary\x20already\x20registered:\x20','get','set','empty\x20pg','query','custom','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','name','parentId','COMMIT','ROLLBACK','values','push'];s=function(){return m;};return s();}export function createDictionary({pg:p,dictionaries:dictionaries=[]}){const Z=new Map(),A=new Map();let I,j;async function D(){const F=f;if(I!==undefined)return I;if(!p)throw new Error('empty\x20pg');return j??=p['query'](F(0x1a3))[F(0x1a4)](E=>{const T=F,a=E[T(0x1a5)][0x0]?.[T(0x1a6)];I=a==='dictionaries'?a:null;}),await j,I;}function o(E){if(!dictionaryName['test'](E))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+E);}function R(E){const L=f;for(const a of Array[L(0x1a7)](E)?E:[E]){o(a[L(0x1a8)]);if(!Array['isArray'](a['items']))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+a['code']);if(Z['has'](a['code']))throw new ConflictError(L(0x1a9)+a[L(0x1a8)]);Z['set'](a['code'],{...a,'source':'static'});}}function B(E){return Z['has'](E);}async function H(E){const y=f;o(E);const a=Z[y(0x1aa)](E);if(a&&a['checked'])return a['items'];const X=await D();if(!X)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const K=await p?.['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',[E]);if(K?.[y(0x1a5)]?.['length']){const Q=K?.[y(0x1a5)];return Z[y(0x1ab)](E,{'code':E,'name':E,'items':Q,'source':'database','checked':!![]}),Q;}if(!a?.['items'])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+E);return a['checked']=!![],a['items'];}async function e(E,a){const z=f;o(E);if(!Array[z(0x1a7)](a))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const X=await D();if(!X)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!p)throw new Error(z(0x1ac));const K=await p['connect']();try{await K[z(0x1ad)]('BEGIN');const Q=await K['query']('\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',[E,E,'fcore',z(0x1ae),!![]]),G=Q[z(0x1a5)][0x0]['id'];await K['query'](z(0x1af),[G]);for(const V of a){await K['query']('\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',[G,V['code'],V[z(0x1b0)],V[z(0x1b1)]??null]);}await K[z(0x1ad)](z(0x1b2));}catch(O){await K['query'](z(0x1b3));throw O;}finally{K['release']();}Z['set'](E,{'items':a,'code':E,'source':'static','checked':!![]}),A['set'](E,(A['get'](E)??0x0)+0x1);}function g(E){return o(E),A['set'](E,(A['get'](E)??0x0)+0x1),Z['delete'](E);}function N(E){return A['get'](E)??0x0;}async function h(){const t=f,E=[...Z[t(0x1b4)]()]['map'](({code:K,name:Q,source:G})=>({'code':K,'name':Q??K,'source':G})),a=await D();if(!a)return E;if(!p)throw new Error('empty\x20pg');const X=await p['query']('\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');for(const K of X['rows']){!Z['has'](K['code'])&&E[t(0x1b5)](K);}return E;}return R(dictionaries),{'register':R,'get':H,'put':e,'clear':g,'revision':N,'list':h,'has':B};}
|
package/dist/plugins/file.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements the S3-compatible file storage adapter and its contracts.
|
|
3
|
-
*/
|
|
4
1
|
import type { Readable } from "node:stream";
|
|
5
2
|
export interface FileAdapter {
|
|
6
3
|
put(path: string, body: Buffer | Readable): Promise<void>;
|
|
@@ -23,5 +20,12 @@ export interface FileS3Config {
|
|
|
23
20
|
tokenSecret?: string;
|
|
24
21
|
tokenTtl?: number;
|
|
25
22
|
}
|
|
23
|
+
export interface FileLocalConfig {
|
|
24
|
+
storagePath: string;
|
|
25
|
+
folder?: string;
|
|
26
|
+
tokenSecret?: string;
|
|
27
|
+
tokenTtl?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function createFileLocal(config: FileLocalConfig): FileAdapter;
|
|
26
30
|
export declare function createFileS3(config: FileS3Config): FileAdapter;
|
|
27
31
|
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":"AAKA,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;AAED,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAoCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAiFpE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiF9D"}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){const b=['alloc','transformToByteArray','resolve','tokenSecret','join','startsWith','dirname','access','code','ENOENT','toString','createHmac','Invalid\x20file\x20token','length','from','base64url','randomBytes','us-east-1','accessKeyId','bucket','tokenTtl','sha256','digest','split','utf8'];s=function(){return b;};return s();}import p from'node:fs/promises';import Z from'node:path';import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';function f(p,Z){p=p-0x1a8;const A=s();let I=A[p];return I;}import A from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function normalizeRelativePath(I){if(!I||I['startsWith']('/')||I['includes']('..'))throw new ValidationError('Invalid\x20file\x20path');return I['replace'](/\\/g,'/')['replace'](/^\/+/,'');}function keyFor(I,j){return''+((I??'')['replace'](/^\/+|\/+$/g,'')?(I??'')['replace'](/^\/+|\/+$/g,'')+'/':'')+normalizeRelativePath(j);}async function bodyToBuffer(I){const X=f;if(!I)return Buffer[X(0x1a8)](0x0);const j=I;if(typeof j[X(0x1a9)]==='function')return Buffer['from'](await j['transformToByteArray']());const D=[];for await(const o of I){D['push'](Buffer['from'](o));}return Buffer['concat'](D);}export function createFileLocal(I){const K=f,j=Z[K(0x1aa)](I['storagePath']||'./storage'),D=Z['join'](j,'removed'),o=I[K(0x1ab)]??process.env.FILE_TOKEN_SECRET??A['randomBytes'](0x20)['toString']('hex'),R=e=>{const Q=K,g=normalizeRelativePath(e),N=(I['folder']??'files')['replace'](/^\/+|\/+$/g,'');return N?Z[Q(0x1ac)](N,g):g;},B=e=>{const G=K,g=R(e),N=Z['resolve'](j,g),h=Z['relative'](j,N);if(h[G(0x1ad)]('..')||Z['isAbsolute'](h))throw new ValidationError('Invalid\x20file\x20path');return N;},H=e=>{const V=K,g=R(e),N=Z['resolve'](D,g),h=Z['relative'](D,N);if(h[V(0x1ad)]('..')||Z['isAbsolute'](h))throw new ValidationError('Invalid\x20file\x20path');return N;};return{async 'put'(e,g){const O=K,N=B(e);await p['mkdir'](Z[O(0x1ae)](N),{'recursive':!![]}),await p['writeFile'](N,g instanceof Buffer?g:await bodyToBuffer(g));},async 'get'(e){return p['readFile'](B(e));},async 'exists'(e){const F=K;try{return await p[F(0x1af)](B(e)),!![];}catch{return![];}},async 'delete'(e){const T=K,g=B(e),N=H(e);try{await p['mkdir'](Z['dirname'](N),{'recursive':!![]}),await p['rename'](g,N);}catch(h){const E=h;if(E[T(0x1b0)]!==T(0x1b1))throw h;}},'create'(e,g=I['tokenTtl']??0xe10){const L=K,N=Buffer['from'](e)[L(0x1b2)]('base64url'),h=A[L(0x1b3)]('sha256',o)['update'](N)['digest']('base64url');return N+'.'+h;},'verify'(e){const y=K,[g,N]=e['split']('.');if(!g||!N)throw new UnauthorizedError(y(0x1b4));const h=A['createHmac']('sha256',o)['update'](g)['digest'](),E=Buffer['from'](N,'base64url');if(h[y(0x1b5)]!==E['length']||!A['timingSafeEqual'](h,E))throw new UnauthorizedError(y(0x1b4));const a=Buffer[y(0x1b6)](g,y(0x1b7))[y(0x1b2)]('utf8');return a;}};}export function createFileS3(I){const z=f,j=I['tokenSecret']??process.env.FILE_TOKEN_SECRET??A[z(0x1b8)](0x20)[z(0x1b2)]('hex'),D=new S3Client({'endpoint':I['endpoint'],'region':I['region']??z(0x1b9),'forcePathStyle':I['forcePathStyle']??!![],'credentials':I['accessKeyId']||I['accessKey']?{'accessKeyId':I[z(0x1ba)]??I['accessKey'],'secretAccessKey':I['secretAccessKey']??I['secretKey']}:undefined}),o=R=>keyFor(I['folder'],R);return{async 'put'(R,B){await D['send'](new PutObjectCommand({'Bucket':I['bucket'],'Key':o(R),'Body':B}));},async 'get'(R){const B=await D['send'](new GetObjectCommand({'Bucket':I['bucket'],'Key':o(R)}));return bodyToBuffer(B['Body']);},async 'exists'(R){try{return await D['send'](new HeadObjectCommand({'Bucket':I['bucket'],'Key':o(R)})),!![];}catch(B){const H=B;if(H['$metadata']?.['httpStatusCode']===0x194||H['name']==='NotFound')return![];throw B;}},async 'delete'(R){const t=z;await D['send'](new DeleteObjectCommand({'Bucket':I[t(0x1bb)],'Key':o(R)}));},'create'(R,B=I[z(0x1bc)]??0xe10){const m=z,H=Buffer[m(0x1b6)](R)['toString']('base64url'),e=A['createHmac'](m(0x1bd),j)['update'](H)[m(0x1be)](m(0x1b7));return H+'.'+e;},'verify'(R){const r=z,[B,H]=R[r(0x1bf)]('.');if(!B||!H)throw new UnauthorizedError('Invalid\x20file\x20token');const e=A['createHmac']('sha256',j)['update'](B)['digest'](),g=Buffer['from'](H,r(0x1b7));if(e[r(0x1b5)]!==g['length']||!A['timingSafeEqual'](e,g))throw new UnauthorizedError(r(0x1b4));const N=Buffer[r(0x1b6)](B,'base64url')['toString'](r(0x1c0));return N;}};}
|
package/dist/plugins/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SignJWT,jwtVerify}from'jose';function f(p,Z){p=p-0x7f;const A=s();let I=A[p];return I;}const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);export async function jwtSignToken(p){const D=f;if(!process.env.AUTH_JWT_SECRET)return;const {id:Z,type:A,permissions:I}=p,j=await new SignJWT({'id':Z,'type':A,'permissions':I})[D(0x7f)]({'alg':'HS256'})[D(0x80)]()[D(0x81)]('1h')['sign'](secret);return j;}export async function jwtVerifyToken(p){const o=f,Z=await jwtVerify(p,secret,{'algorithms':[o(0x82)]})['catch'](A=>{console['log'](A['message']);});return Z?.['payload'];}function s(){const R=['setProtectedHeader','setIssuedAt','setExpirationTime','HS256'];s=function(){return R;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import p from'pino';function f(p,Z){p=p-0x80;const A=s();let I=A[p];return I;}export function createLogger(){const R=f,Z=p['transport']({'target':'./transport.js'}),A=p({'level':'info','timestamp':p[R(0x80)]['isoTime'],'base':{'service':'app'},'redact':{'paths':[R(0x81),'password',R(0x82),'accessToken',R(0x83)],'censor':'[REDACTED]'}},Z),I={};function j(D,o){if(D===undefined)return{...I};I[D]=(I[D]??0x0)+(o??0x1);}return Object['assign'](A,{'close':async()=>Z['end'](),'metrics':j,'file':()=>A[R(0x84)]['bind'](A)});}function s(){const B=['stdTimeFunctions','req.headers.authorization','token','refreshToken','info'];s=function(){return B;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R=f;function s(){const h=['info','warn','slice','resolve','mkdirSync','get','stream','end','write'];s=function(){return h;};return s();}import p from'node:fs';import Z from'node:path';import A from'pino-abstract-transport';const LEVELS={0x1e:R(0xa0),0x28:R(0xa1),0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const B=R;return new Date()['toISOString']()[B(0xa2)](0x0,0xa);}function createStream(I,j){const H=R,D=Z[H(0xa3)]('logs',I);return p[H(0xa4)](D,{'recursive':!![]}),p['createWriteStream'](Z['join'](D,j+'.log'),{'flags':'a'});}function f(p,Z){p=p-0xa0;const A=s();let I=A[p];return I;}function getStream(I){const e=R,j=getDate(),D=streams[e(0xa5)](I);if(D&&D['date']===j)return D[e(0xa6)];D?.['stream']['end']();const o=createStream(I,j);return streams['set'](I,{'date':j,'stream':o}),o;}function closeStreams(){const g=R;for(const {stream:I}of streams['values']()){I[g(0xa7)]();}streams['clear']();}export default async function loggerTransport(){return A(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(I){const N=R;for await(const j of I){const D=LEVELS[j['level']];if(!D)continue;const o=getStream(j['file']||D);delete j['file'],o[N(0xa8)](JSON['stringify'](j)+'\x0a');}}
|
package/dist/plugins/pg.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export interface DatabaseConfig {
|
|
|
10
10
|
password: string;
|
|
11
11
|
max?: number;
|
|
12
12
|
}
|
|
13
|
-
export declare function createDatabase(config: DatabaseConfig):
|
|
14
|
-
export type DatabaseAdapter = pg.Pool
|
|
13
|
+
export declare function createDatabase(config: DatabaseConfig): DatabaseAdapter;
|
|
14
|
+
export type DatabaseAdapter = pg.Pool & {
|
|
15
|
+
transaction: <T>(callback: (client: pg.PoolClient) => Promise<T>) => Promise<T>;
|
|
16
|
+
};
|
|
15
17
|
//# sourceMappingURL=pg.d.ts.map
|
package/dist/plugins/pg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,cAAc,mBAiDzB;AACD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC,IAAI,GAAG;IACpC,WAAW,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACnF,CAAC"}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from'pg';function s(){const E=['query','stack','callerStack'];s=function(){return E;};return s();}function f(p,Z){p=p-0x179;const A=s();let I=A[p];return I;}const {Pool}=p;export function createDatabase(Z){const g=f,A=new Pool(Z),I=A[g(0x179)]['bind'](A);function j(D,o){const R=new Error();return Error['captureStackTrace']?.(R,j),I(D,o)['catch'](B=>{const N=f,H=B;H['sql']=D,H['callerStack']=R[N(0x17a)];throw H;});}return A['query']=j,A['transaction']=async function(D){const h=g,o=new Error();Error['captureStackTrace']?.(o,A['transaction']);const R=await A['connect']();try{await R[h(0x179)]('BEGIN');const B=await D(R);return await R[h(0x179)]('COMMIT'),B;}catch(H){await R[h(0x179)]('ROLLBACK');const e=H;e[h(0x17b)]=o[h(0x17a)];throw e;}finally{R['release']();}},A;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/plugins/redis.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/plugins/redis.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AACD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW;IAI3C,GAAG,QAAQ,MAAM;IACjB,GAAG,QACI,MAAM,SACJ,MAAM,WACJ,MAAM,GAAG,MAAM,QAClB,MAAM;IAWd,GAAG,QAAQ,MAAM;IACjB,MAAM,QAAQ,MAAM;IACpB,KAAK;IACL,IAAI;IACJ,OAAO,QAAQ,MAAM,SAAS,MAAM,OAAO,MAAM;IAEjD,MAAM,QAAQ,MAAM,OAAO,MAAM;EAEpC;AACD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{Redis}from'ioredis';export function createRedis(p){const o=f;console['log'](o(0x1ac),p);const Z=new Redis(p);return{'get':A=>Z['get'](A),'set':(A,I,j,D)=>{if(D)return Z['set'](A,I,'EX',D);if(typeof j==='number')return Z['set'](A,I,'EX',j);return Z['set'](A,I);},'del':A=>Z['del'](A),'delete':A=>Z['del'](A),'close':()=>Z[o(0x1ad)](),'ping':()=>Z['ping'](),'hincrby':(A,I,j)=>Z['hincrby'](A,I,j),'incrby':(A,I)=>Z['incrby'](A,I)};}function f(p,Z){p=p-0x1ac;const A=s();let I=A[p];return I;}function s(){const R=['Creating\x20Redis\x20client\x20with\x20config:','quit'];s=function(){return R;};return s();}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ResourceDependencies, ResourcePlugin } from
|
|
1
|
+
import type { ResourceDependencies, ResourcePlugin } from "./resource.types.js";
|
|
2
2
|
export declare function createResource(deps: ResourceDependencies): ResourcePlugin;
|
|
3
3
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA4BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';
|
|
1
|
+
function f(p,Z){p=p-0x1a5;const A=s();let I=A[p];return I;}import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(p){const g=f,Z=new ResourceRegistry(),A=createFind(p,Z),I=createFindOne(p,Z),j=createCreate(p,Z),D=createUpdate(p,Z),o=createRemove(p,Z),R=createFindRelation(p,Z),B=createCreateRelation(p,Z),H=createUpdateRelation(p,Z),e=createDeleteRelation(p,Z);return{'register':Z['register']['bind'](Z),'unregister':Z['unregister'][g(0x1a5)](Z),'has':Z['has']['bind'](Z),'get':Z[g(0x1a6)]['bind'](Z),'list':Z['list']['bind'](Z),'find':A,'findOne':I,'create':j,'update':D,'delete':o,'findRelation':R,'createRelation':B,'updateRelation':H,'deleteRelation':e};}function s(){const N=['bind','get'];s=function(){return N;};return s();}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ResourceContract } from
|
|
1
|
+
import type { ResourceContract } from "./resource.types.js";
|
|
2
2
|
export declare class ResourceRegistry {
|
|
3
3
|
private readonly resources;
|
|
4
|
-
|
|
4
|
+
unregister(name: string): void;
|
|
5
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
5
6
|
has(name: string): boolean;
|
|
6
7
|
get(name: string): ResourceContract;
|
|
7
8
|
list(): ResourceContract[];
|