@opengis/fcore 0.0.1-beta.10 → 0.0.1-beta.11
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.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/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.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.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.js +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.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/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.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.js +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.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.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.js +1 -1
- 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/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +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.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.js +1 -1
- package/dist/plugins/redis.js +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 +5 -2
- 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.map +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- 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.map +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts +5 -1
- 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.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/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 +5 -1
- 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.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/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/20260905120000_add_user_foreign_keys.sql +42 -42
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x1a6;const X=G();let g=X[R];return g;}function G(){const m=['INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*'];G=function(){return m;};return G();}export async function addNote(R,t){const g=q,X=await t['pg']['query'](g(0x1a6),[R['resource'],String(R['id']),R['body']]);return X['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x11c;const X=G();let g=X[R];return g;}export async function addResourceFile(R,t){const g=q,X=await t['pg']['query'](g(0x11c),[R['resource'],String(R['id']),R['filePath'],R[g(0x11d)]??null]);return X[g(0x11e)][0x0];}function G(){const m=['\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20','size','rows'];G=function(){return m;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function createResourceRelation(
|
|
1
|
+
export async function createResourceRelation(R,t){const {resource:X,id:g,relation:m,data:Z,user:z}=R;return t['resource']['createRelation']({'name':X,'id':g,'relation':m,'data':Z,'user':z});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0xb7;var X=G();var g=X[R];return g;}function G(){var g=['resource','user'];G=function(){return g;};return G();}export async function createResource(R,t){var X=q;return t[X(0xb7)]['create']({'name':R['resource'],'data':R['data'],'user':R[X(0xb8)]});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResourceRelation(
|
|
1
|
+
export async function deleteResourceRelation(R,t){const z=q,{resource:X,id:g,relation:m,relationId:Z}=R;return t[z(0x1b1)]['deleteRelation']({'name':X,'id':g,'relation':m,'relationId':Z});}function q(R,t){R=R-0x1b1;const X=G();let g=X[R];return g;}function G(){const l=['resource'];G=function(){return l;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResource(
|
|
1
|
+
export async function deleteResource(R,t){var X=q;return t[X(0xd5)][X(0xd6)]({'name':R['resource'],'id':R['id'],'user':R['user']});}function q(R,t){R=R-0xd5;var X=G();var g=X[R];return g;}function G(){var g=['resource','delete'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(R,t){const g=q,X=await t['resource'][g(0x93)]({'name':R[g(0x94)],'query':{'filter':parseFilterQuery(R),'sort':R['sort'],'search':R['search'],'limit':R['limit'],'offset':R[g(0x95)],'fields':R['fields']},'user':R['user']});return X['rows'];}function q(R,t){R=R-0x93;const X=G();let g=X[R];return g;}function G(){const m=['find','resource','offset'];G=function(){return m;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x1b3;var X=G();var g=X[R];return g;}export async function getResource(R,t){var X=q;return t[X(0x1b3)]['findOne']({'name':R['resource'],'id':R['id'],'query':{'include':R[X(0x1b4)]},'user':R['user']});}function G(){var g=['resource','include'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listResourceRelation(
|
|
1
|
+
export async function listResourceRelation(R,t){const {resource:X,id:g,relation:m,query:Z,user:z}=R;return t['resource']['findRelation']({'name':X,'id':g,'relation':m,'query':Z,'user':z});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(){var g=['max'];G=function(){return g;};return G();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function q(R,t){R=R-0x196;var X=G();var g=X[R];return g;}export async function listResources(R,t){var X=q;return t['resource']['find']({'name':R['resource'],'query':{'filter':parseFilterQuery(R),'sort':R['sort'],'search':R['search'],'limit':R['limit'],'offset':R['offset']??(R['page']?Math[X(0x196)](R['page']-0x1,0x0):0x0)*(R['limit']??0x14)},'user':R['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function searchResource(
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function q(R,t){R=R-0x8c;var X=G();var g=X[R];return g;}export async function searchResource(R,t){var X=q;return t['resource']['find']({'name':R[X(0x8c)],'query':{...R,'filter':parseFilterQuery(R)},'user':R[X(0x8d)]});}function G(){var g=['resource','user'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function q(R,t){R=R-0x82;const X=G();let g=X[R];return g;}function G(){const e=['resource','toLowerCase','min','max','fields','table','name','value','query','SELECT\x20','then','length','startsWith','now'];G=function(){return e;};return G();}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(R,t){const U=q,X=t[U(0x82)]['get'](R['resource']),g=String(R['search']??R['q']??'')[U(0x83)](),m=Math[U(0x84)](Math[U(0x85)](Number(R['limit']??0x14),0x1),0xc8),Z=Date['now'](),z=X[U(0x86)][R['field']],l=z?.['dictionary'],y=z?.['lookup']?.[U(0x87)];if(y){const E=z['lookup']?.['text']??U(0x88),C=z['lookup']?.[U(0x89)]??'id';autoIndex(y,E,'text',t['pg']);const L=await t['pg'][U(0x8a)](U(0x8b)+C+'\x20as\x20id,\x20'+E+'\x20as\x20text\x20FROM\x20'+y+'\x20WHERE\x20lower('+E+')\x20~\x20$1\x20LIMIT\x20$2',[''+g[U(0x83)](),m])[U(0x8c)](O=>O['rows']);return{'limit':m,'count':L[U(0x8d)],'search':g,'time':Date['now']()-Z,'data':L};}if(!l)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+R['field']);const h=await t['dictionary']['get'](l),P=h['filter'](O=>!g||O['code'][U(0x8e)](g)||O['name'][U(0x8e)](g))['slice'](0x0,m)['map'](O=>({'id':O['code']||O['id'],'text':O['name']||O['text']}));return{'search':g,'limit':m,'count':P['length'],'time':Date[U(0x8f)]()-Z,'data':P};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function updateResourceRelation(R,t){const {resource:X,id:g,relation:m,relationId:Z,data:z,user:l}=R;return t['resource']['updateRelation']({'name':X,'id':g,'relation':m,'relationId':Z,'data':z,'user':l});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateResource(
|
|
1
|
+
export async function updateResource(R,t){var X=q;return t['resource']['update']({'name':R[X(0x159)],'id':R['id'],'data':R[X(0x15a)],'user':R['user']});}function q(R,t){R=R-0x159;var X=G();var g=X[R];return g;}function G(){var g=['resource','patch'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(){const l=['get','resource','admin','type','user','permission',':update','length','fileName','File\x20name\x20is\x20required','put','query'];G=function(){return l;};return G();}function q(R,t){R=R-0xc3;const X=G();let g=X[R];return g;}import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(R,t){const z=q,X=t['resource'][z(0xc3)](R[z(0xc4)]);if(X['access']===z(0xc5)&&R['user']?.[z(0xc6)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(R['user']?.['type']!=='admin'&&!R[z(0xc7)]?.['permissions']?.['includes']((X[z(0xc8)]??X['name'])+z(0xc9)))throw new ForbiddenError('Missing\x20permission:\x20'+(X[z(0xc8)]??X['name'])+z(0xc9));if(!Buffer['isBuffer'](R['file'])||R['file'][z(0xca)]===0x0)throw new ValidationError('File\x20is\x20required');const g=R[z(0xcb)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!g)throw new ValidationError(z(0xcc));const m='files/'+R['resource']+'/'+String(R['id'])+'/'+g;await t['file'][z(0xcd)](m,R['file']);if(!await t['file']['exists'](m))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const Z=await t['pg'][z(0xce)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[R['resource'],String(R['id']),m,R['file']['length']]);return Z['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';function q(R,t){R=R-0x97;const X=G();let g=X[R];return g;}import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';function G(){const P=['get','dictionaryName','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','system:dictionaries','dictionaryItems','params','fcore','system:access','system','system:settings','/api/system/settings','body','user','type','send','/api/system/audit','/api/system/list','List\x20APIs','admin'];G=function(){return P;};return G();}import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{setAccess}from'./services/set-access.js';import{systemSchemas}from'./schema.js';const u=R=>R['user'];export function systemRoutes(R,t=new Map()){return async X=>{const y=q;X[y(0x97)]('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[y(0x98)]}},async m=>({'items':await getDictionary({...m['params'],'user':u(m)},R)})),X['post']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':'Update\x20platform\x20dictionary','description':y(0x99),'access':'user','permissions':[y(0x9a)],'params':systemSchemas['dictionaryName'],'body':systemSchemas[y(0x9b)]}},async m=>updateDictionary({...m[y(0x9c)],...m['body'],'user':u(m)},R));const g=async m=>getAccess({...m['params'],'user':u(m)},R);X['get']('/api/access/:type/:id',{'schema':{'tags':[y(0x9d),'system'],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget']}},g),X['post']('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[y(0x9e)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async m=>setAccess({...m[y(0x9c)],...m['body'],'user':u(m)},R)),X[y(0x97)]('/api/system/settings',{'schema':{'tags':[y(0x9d),y(0x9f)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[y(0xa0)]}},async m=>getSystemSettings({...m[y(0x9c)],'user':u(m)},R)),X['post'](y(0xa1),{'schema':{'tags':[y(0x9d),'system'],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async m=>updateSystemSettings({...m[y(0x9c)],'patch':m[y(0xa2)],'user':u(m)},R)),X['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':y(0xa3),'permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(m,Z)=>{const h=y,{contentType:z,body:l}=await getSystemLog({...m['query'],'user':u(m)},R);return Z[h(0xa4)](z)[h(0xa5)](l);}),X[y(0x97)](y(0xa6),{'schema':{'tags':['fcore',y(0x9f)],'summary':'Get\x20audit\x20log','description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':'user','permissions':['system:audit']}},async m=>getAuditLog({...m['query'],'user':u(m)},R)),X[y(0x97)]('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':y(0xa3),'permissions':['system:check']}},async m=>checkSystem({'user':u(m)},R)),X['get'](y(0xa7),{'schema':{'tags':['fcore','system'],'summary':y(0xa8),'description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':y(0xa9),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async m=>getApiList({'user':u(m),'apiRoutes':t,...m['query']},R));};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R=q;import{Type}from'@sinclair/typebox';function G(){const t=['Object','Optional','Literal','user','Array','String','Record'];G=function(){return t;};return G();}function q(R,t){R=R-0x196;const X=G();let g=X[R];return g;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type[R(0x196)]({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type['Union']([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type[R(0x197)](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type[R(0x198)](R(0x199)),Type['Literal']('role')]),'id':identifier}),'access':Type['Object']({'access':Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type[R(0x19a)](Type[R(0x19b)]({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})}))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type['Union']([Type['Literal']('short'),Type[R(0x198)]('extended')]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type[R(0x19c)](Type['String']({'minLength':0x1}),Type['Unknown']()),'logger':Type['Object']({'path':Type[R(0x197)](Type[R(0x19b)]({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(){const Z=['SELECT\x201','redis','status'];G=function(){return Z;};return G();}function q(R,t){R=R-0xd6;const X=G();let g=X[R];return g;}export async function checkSystem(R,t){const m=q,[X,g]=await Promise['allSettled']([t['pg']['query'](m(0xd6)),t[m(0xd7)]['ping']()]);return{'status':X['status']==='fulfilled'&&g['status']==='fulfilled'?'ok':'degraded','pg':X[m(0xd8)],'redis':g['status']};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getAccess(
|
|
1
|
+
export async function getAccess(R,t){const X=R['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',g=await t['pg']['query'](X,[R['id']]);return{'access':g['rows']};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0xb4;const X=G();let g=X[R];return g;}export async function getApiList(R,t){const l=q,X=[...R['apiRoutes']['values']()]['sort']((g,m)=>(g['endpoint']+'\x20'+g['method'])[l(0xb4)](m['endpoint']+'\x20'+m[l(0xb5)]));if(R['format']!==l(0xb6))return X;return X['map'](({method:g,endpoint:m,access:Z,permissions:z})=>g+'\x20'+m);}function G(){const y=['localeCompare','method','short'];G=function(){return y;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getAuditLog(
|
|
1
|
+
function q(R,t){R=R-0xd8;const X=G();let g=X[R];return g;}export async function getAuditLog(R,t){const Z=q,X=Math['min'](Math['max'](R[Z(0xd8)]??0x32,0x1),0xc8),g=Math['max']((R[Z(0xd9)]??0x1)-0x1,0x0)*X,m=await t['pg']['query']('SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[X,g]);return{'rows':m['rows'],'page':R[Z(0xd9)]??0x1,'limit':X};}function G(){const z=['limit','page'];G=function(){return z;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(){var g=['get'];G=function(){return g;};return G();}function q(R,t){R=R-0x131;var X=G();var g=X[R];return g;}export async function getDictionary(R,t){var X=q;return t['dictionary'][X(0x131)](R['name']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function q(R,t){R=R-0x66;const X=G();let g=X[R];return g;}const O=q;import R from'node:fs/promises';import t from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=t['resolve'](process[O(0x66)](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(X,g){const U=O,m=normalizePath(X['path']),Z=t['resolve'](LOGS_ROOT,m);if(Z!==LOGS_ROOT&&!Z['startsWith'](LOGS_ROOT+t['sep']))throw new ValidationError(U(0x67));const z=await R['stat'](Z)[U(0x68)](()=>null);if(!z)throw new NotFoundError(U(0x69));if(z['isDirectory']()){const y=await R['readdir'](Z,{'withFileTypes':!![]}),h=await Promise['all'](y['map'](async P=>{const e=U,E=await R[e(0x6a)](t['join'](Z,P[e(0x6b)]));return{'name':P[e(0x6b)],'path':m?m+'/'+P['name']:P['name'],'type':P['isDirectory']()?'directory':'file','size':P['isDirectory']()?undefined:E['size'],'modified':E[e(0x6c)]['toISOString']()};}));h['sort']((P,E)=>P['name']['localeCompare'](E['name']));if(m){const P=m[U(0x6d)]('/')[U(0x6e)](0x0,-0x1)[U(0x6f)]('/');h['unshift']({'name':'..','path':P,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(m,h)};}const l=await tailFile(Z,TAIL_LINES);return{'contentType':U(0x70),'body':l[U(0x6f)]('\x0a')};}function renderDirectory(X,g){const n=O,m=g['map'](z=>{const H=q,l='?path='+encodeURIComponent(z['path']),y=z['type']==='directory'?z[H(0x6b)]+'/':z[H(0x6b)];return'<li><a\x20href=\x22'+l+'\x22>'+escapeHtml(y)+'</a></li>';})['join']('\x0a'),Z=escapeHtml('logs/'+X);return n(0x71)+Z+'</title></head>\x0a<body>\x0a<h1>'+Z+n(0x72)+m+n(0x73);}function escapeHtml(X){return X['replace'](/&/g,'&')['replace'](/</g,'<')['replace'](/>/g,'>')['replace'](/"/g,'"');}function normalizePath(X){const S=O,g=(X??'')[S(0x74)](/\\/g,'/')[S(0x74)](/^\/+|\/+$/g,'');if(g['split']('/')[S(0x75)](m=>m==='..'))throw new ValidationError('Invalid\x20log\x20path');return g;}function G(){const Q=['cwd','Invalid\x20log\x20path','catch','Log\x20path\x20not\x20found','stat','name','mtime','split','slice','join','text/plain;\x20charset=utf-8','<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>','</h1>\x0a<ul>\x0a','\x0a</ul>\x0a</body>\x0a</html>','replace','some'];G=function(){return Q;};return G();}async function tailFile(X,g){const c=O,m=await R['open'](X,'r');try{const {size:Z}=await m[c(0x6a)](),z=0x40*0x400;let l=Z,y=Buffer['alloc'](0x0),h=0x0;while(l>0x0&&h<=g){const E=Math['min'](z,l);l-=E;const C=Buffer['alloc'](E);await m['read'](C,0x0,E,l),y=Buffer['concat']([C,y]),h+=countNewlines(C);}const P=y['toString']('utf8')['split']('\x0a')['filter'](L=>L['length']>0x0);return P[c(0x6e)](-g)['reverse']();}finally{await m['close']();}}function countNewlines(X){let g=0x0;for(const m of X){if(m===0xa)g++;}return g;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getSystemSettings(R,t){const X=await t['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 X['rows']['reduce']((g,m)=>{const Z=String(m['key'])['split']('.');let z=g;for(const l of Z['slice'](0x0,-0x1)){z[l]??={},z=z[l];}return z[Z['at'](-0x1)]=m['value'],g;},{});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listDictionaries(
|
|
1
|
+
export async function listDictionaries(R,t){return t['dictionary']['list']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function q(R,t){R=R-0xa2;const X=G();let g=X[R];return g;}function G(){const z=['connect','type','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','query','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL','user','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','ROLLBACK'];G=function(){return z;};return G();}import{getAccess}from'./get-access.js';export async function setAccess(R,t){const Z=q,X=await t['pg'][Z(0xa2)]();try{await X['query']('BEGIN');R[Z(0xa3)]==='user'?await X['query'](Z(0xa4),[R['id']]):await X[Z(0xa5)](Z(0xa6),[R['id']]);for(const g of R['access']){R['type']===Z(0xa7)?await X['query'](Z(0xa8),[g[Z(0xa9)],g['actions'],R['id'],R['user']['id'],R['user']['id']]):await X['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)',[g['resource'],g['actions'],R['id'],R['user']['id'],R['user']['id']]);}await X['query']('COMMIT');}catch(m){await X['query'](Z(0xaa));throw m;}finally{X['release']();}return getAccess(R,t);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
export async function updateDictionary(R,t){var X=q;return await t['dictionary'][X(0x15e)](R['name'],R['items']),{'success':!![]};}function q(R,t){R=R-0x15e;var X=G();var g=X[R];return g;}function G(){var g=['put'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function G(){const Z=['length','stringify'];G=function(){return Z;};return G();}import{ValidationError}from'../../../errors.js';function q(R,t){R=R-0xe1;const X=G();let g=X[R];return g;}export async function updateSystemSettings(R,t){const m=q;if(!Object['keys'](R['patch'])[m(0xe1)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [X,g]of Object['entries'](R['patch'])){if(!X['trim']()||X['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+X);await t['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',[X,JSON[m(0xe2)](g),R['user']['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../errors.js';
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';export function requireAdmin(R,t){var X=q;if(!R)throw new ForbiddenError('User\x20required');if(R['type']!=='admin')throw new ForbiddenError(X(0x1d3));if(R['type']!==X(0x1d4)&&t&&!R['permissions']?.['includes'](t))throw new ForbiddenError('Missing\x20permission:\x20'+t);}function q(R,t){R=R-0x1d3;var X=G();var g=X[R];return g;}function G(){var g=['Admin\x20access\x20required','admin'];G=function(){return g;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const safeUser=
|
|
1
|
+
function q(R,t){R=R-0x187;const X=G();let g=X[R];return g;}function G(){const Z=['toLowerCase'];G=function(){return Z;};return G();}export const safeUser=R=>{const m=q,t=['password','salt','secret','credentials'];return Object['fromEntries'](Object['entries'](R)['filter'](([X])=>!t['some'](g=>X[m(0x187)]()['includes'](g))));};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';export function unsupported(
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';function q(R,t){R=R-0x162;var X=G();var g=X[R];return g;}export function unsupported(R){var t=q;throw new UnsupportedError(R+t(0x162));}function G(){var X=['\x20requires\x20a\x20project/provider\x20implementation'];G=function(){return X;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(R){const t=writeAudit(R);return{'write':t};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function G(){const L=['object','entries','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\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20','then','rows','has','audit_log','empty\x20pg','resourceId','ipAddress','metadata','changes','field'];G=function(){return L;};return G();}function q(R,t){R=R-0x1de;const X=G();let g=X[R];return g;}const secretPattern=/password|token|secret|credential|salt/i;function clean(R){const h=q;if(Array['isArray'](R))return R['map'](clean);if(R&&typeof R===h(0x1de))return Object['fromEntries'](Object[h(0x1df)](R)['map'](([t,X])=>[t,secretPattern['test'](t)?'[REDACTED]':clean(X)]));return R;}export function writeAudit(R){let t,X;async function g(){const P=q;if(!R['pg'])return![];if(t!==undefined)return t;return X??=R['pg'][P(0x1e0)](P(0x1e1))[P(0x1e2)](m=>{const E=P,Z=new Set(m[E(0x1e3)]['map'](z=>z['table_name']));return t=Z[E(0x1e4)](E(0x1e5))&&Z['has']('audit_log_data'),!t&&R['logger']['warn']({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...Z]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),t;})['catch'](m=>{return t=![],R['logger']['warn']({'err':m},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),X;}return async function m(Z){const C=q;if(!await g())return R['logger']['info']({'auditFallback':!![],'event':clean({...Z,'changes':Z['changes']?.['map'](y=>({...y,'oldValue':clean(y['oldValue']),'newValue':clean(y['newValue'])}))})},'audit'),0x0;if(!R['pg'])throw new Error(C(0x1e6));const z=await R['pg'][C(0x1e0)]('\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',[Z['userId']??null,Z['module'],Z['resource'],Z['resourceId']==null?null:String(Z[C(0x1e7)]),Z['fields']??null,Z['action'],Z['requestId']??null,Z[C(0x1e8)]??null,clean(Z[C(0x1e9)]??{})]),l=z['rows'][0x0]['id'];for(const y of Z[C(0x1ea)]??[]){if(secretPattern['test'](y['field']))continue;await R['pg']['query']('\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',[l,y[C(0x1eb)],JSON['stringify'](clean(y['oldValue'])),JSON['stringify'](clean(y['newValue']))]);}return l;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x1d6;const X=G();let g=X[R];return g;}export async function getUserPermissions(R,t){const m=q,X=await t['pg']['query'](m(0x1d6),[R]);return X['rows'][m(0x1d7)](g=>g['permission']);}function G(){const Z=['\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','map'];G=function(){return Z;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./auth.types.js';import{randomBytes,scrypt as
|
|
1
|
+
export*from'./auth.types.js';import{randomBytes,scrypt as R,timingSafeEqual}from'node:crypto';import{promisify}from'node:util';function G(){const e=['hex','scrypt','from','auth','cookieOptions','initialize','registerUserDeserializer','user'];G=function(){return e;};return G();}const scrypt=promisify(R);import t from'@fastify/cookie';import X from'@fastify/session';import{Authenticator}from'@fastify/passport';import g from'fastify-session-redis-store';function q(R,t){R=R-0x1e3;const X=G();let g=X[R];return g;}import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(m){const C=q,Z=randomBytes(0x10),z=await scrypt(m,Z,0x40);return'scrypt$'+Z['toString'](C(0x1e3))+'$'+z['toString'](C(0x1e3));}export async function verifyPassword(m,Z){const L=q,[z,l,y]=Z?.['split']('$')||[];if(z!==L(0x1e4)||!l||!y)return![];const h=Buffer[L(0x1e5)](l,L(0x1e3)),P=Buffer['from'](y,'hex'),E=await scrypt(m,h,P['length']);return timingSafeEqual(E,P);}export async function createSessionStore(m,Z){const O=q,{config:z,redis:l}=Z;if(!z||!l){console['warn']('Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await m['register'](t,{'parseOptions':z['auth']['cookieOptions']}),await m['register'](X,{'secret':z[O(0x1e6)]['secret'],'cookieName':z[O(0x1e6)]['cookieName'],'cookie':z[O(0x1e6)][O(0x1e7)],'store':new g({'prefix':z[O(0x1e6)]['cookieName']+':'+(z['pg']?.['database']||'db')+':','client':l})}),await m['register'](fastifyPassport[O(0x1e8)]()),await m['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async y=>({'user':y})),fastifyPassport[O(0x1e9)](async y=>{const U=O,h=y?.[U(0x1ea)]||y;return h?.['id']&&(h['permissions']=await getUserPermissions(h['id'],Z)),h;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(){const E=['user.login','query','info','auth/warn'];G=function(){return E;};return G();}function q(R,t){R=R-0x67;const X=G();let g=X[R];return g;}import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';export async function verifyUser({user:R,password:t,ip:X},{pg:g,logger:m}){const P=q;if(!R||R==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!t||t==='')throw new BadRequestError('not\x20enough\x20params:\x20password');m['metrics'](P(0x67));const Z='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',z=await g[P(0x68)](Z,[R])['then'](y=>y['rows']?.[0x0]);if(!z){const y='user\x20not\x20found';m[P(0x69)]({'file':P(0x6a),'error':y,'user':R,'ip':X});throw new BadRequestError(y);}const l=await verifyPassword(t,z['password_hash']);if(!l){const h='Wrong\x20password';m['info']({'file':'auth/warn','error':h,'user':R,'ip':X});throw new BadRequestError(h);}return delete z['password_hash'],z;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function G(){const K=['empty\x20pg','Invalid\x20dictionary\x20name:\x20','items','Dictionary\x20already\x20registered:\x20','query','rows','length','database','Dictionary\x20not\x20found:\x20','checked','connect','\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','custom','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','code','set','static','get','delete','has'];G=function(){return K;};return G();}function q(R,t){R=R-0x1ac;const X=G();let g=X[R];return g;}import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:R,dictionaries:dictionaries=[]}){const t=new Map(),X=new Map();let g,m;async function Z(){const o=q;if(g!==undefined)return g;if(!R)throw new Error(o(0x1ac));return m??=R['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')['then'](O=>{const U=O['rows'][0x0]?.['table_name'];g=U==='dictionaries'?U:null;}),await m,g;}function z(O){const a=q;if(!dictionaryName['test'](O))throw new ValidationError(a(0x1ad)+O);}function l(O){const J=q;for(const U of Array['isArray'](O)?O:[O]){z(U['code']);if(!Array['isArray'](U[J(0x1ae)]))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+U['code']);if(t['has'](U['code']))throw new ConflictError(J(0x1af)+U['code']);t['set'](U['code'],{...U,'source':'static'});}}function y(O){return t['has'](O);}async function h(O){const F=q;z(O);const U=t['get'](O);if(U&&U['checked'])return U['items'];const e=await Z();if(!e)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const H=await R?.[F(0x1b0)]('\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',[O]);if(H?.[F(0x1b1)]?.[F(0x1b2)]){const n=H?.[F(0x1b1)];return t['set'](O,{'code':O,'name':O,'items':n,'source':F(0x1b3),'checked':!![]}),n;}if(!U?.['items'])throw new NotFoundError(F(0x1b4)+O);return U[F(0x1b5)]=!![],U['items'];}async function P(O,U){const Y=q;z(O);if(!Array['isArray'](U))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const e=await Z();if(!e)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!R)throw new Error('empty\x20pg');const H=await R[Y(0x1b6)]();try{await H['query']('BEGIN');const n=await H['query'](Y(0x1b7),[O,O,'fcore',Y(0x1b8),!![]]),S=n[Y(0x1b1)][0x0]['id'];await H[Y(0x1b0)](Y(0x1b9),[S]);for(const c of U){await H['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',[S,c[Y(0x1ba)],c['name'],c['parentId']??null]);}await H['query']('COMMIT');}catch(Q){await H['query']('ROLLBACK');throw Q;}finally{H['release']();}t[Y(0x1bb)](O,{'items':U,'code':O,'source':Y(0x1bc),'checked':!![]}),X['set'](O,(X[Y(0x1bd)](O)??0x0)+0x1);}function E(O){const A=q;return z(O),X['set'](O,(X[A(0x1bd)](O)??0x0)+0x1),t[A(0x1be)](O);}function C(O){const M=q;return X[M(0x1bd)](O)??0x0;}async function L(){const d=q,O=[...t['values']()]['map'](({code:H,name:n,source:S})=>({'code':H,'name':n??H,'source':S})),U=await Z();if(!U)return O;if(!R)throw new Error(d(0x1ac));const e=await R['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 H of e[d(0x1b1)]){!t[d(0x1bf)](H[d(0x1ba)])&&O['push'](H);}return O;}return l(dictionaries),{'register':l,'get':h,'put':P,'clear':E,'revision':C,'list':L,'has':y};}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import
|
|
1
|
+
import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';function q(R,t){R=R-0x1d4;const X=G();let g=X[R];return g;}import R from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function G(){const c=['startsWith','Invalid\x20file\x20path','replace','function','push','from','randomBytes','us-east-1','accessKey','bucket','Body','name','tokenTtl','Invalid\x20file\x20token','createHmac','length'];G=function(){return c;};return G();}function keyFor(t,X){const E=q;if(!X||X[E(0x1d4)]('/')||X['includes']('..'))throw new ValidationError(E(0x1d5));const g=X['replace'](/\\/g,'/')[E(0x1d6)](/^\/+/,''),m=(t??'')['replace'](/^\/+|\/+$/g,'');return m?m+'/'+g:g;}async function bodyToBuffer(t){const C=q;if(!t)return Buffer['alloc'](0x0);const X=t;if(typeof X['transformToByteArray']===C(0x1d7))return Buffer['from'](await X['transformToByteArray']());const g=[];for await(const m of t){g[C(0x1d8)](Buffer[C(0x1d9)](m));}return Buffer['concat'](g);}export function createFileS3(t){const L=q,X=t['tokenSecret']??process.env.FILE_TOKEN_SECRET??R[L(0x1da)](0x20)['toString']('hex'),g=new S3Client({'endpoint':t['endpoint'],'region':t['region']??L(0x1db),'forcePathStyle':t['forcePathStyle']??!![],'credentials':t['accessKeyId']||t[L(0x1dc)]?{'accessKeyId':t['accessKeyId']??t['accessKey'],'secretAccessKey':t['secretAccessKey']??t['secretKey']}:undefined}),m=Z=>keyFor(t['folder'],Z);return{async 'put'(Z,z){const O=L;await g['send'](new PutObjectCommand({'Bucket':t[O(0x1dd)],'Key':m(Z),'Body':z}));},async 'get'(Z){const U=L,z=await g['send'](new GetObjectCommand({'Bucket':t['bucket'],'Key':m(Z)}));return bodyToBuffer(z[U(0x1de)]);},async 'exists'(Z){const e=L;try{return await g['send'](new HeadObjectCommand({'Bucket':t[e(0x1dd)],'Key':m(Z)})),!![];}catch(z){const l=z;if(l['$metadata']?.['httpStatusCode']===0x194||l[e(0x1df)]==='NotFound')return![];throw z;}},async 'delete'(Z){const H=L;await g['send'](new DeleteObjectCommand({'Bucket':t[H(0x1dd)],'Key':m(Z)}));},'create'(Z,z=t[L(0x1e0)]??0xe10){const n=L,l=Buffer[n(0x1d9)](Z)['toString']('base64url'),y=R['createHmac']('sha256',X)['update'](l)['digest']('base64url');return l+'.'+y;},'verify'(Z){const S=L,[z,l]=Z['split']('.');if(!z||!l)throw new UnauthorizedError(S(0x1e1));const y=R[S(0x1e2)]('sha256',X)['update'](z)['digest'](),h=Buffer['from'](l,'base64url');if(y['length']!==h[S(0x1e3)]||!R['timingSafeEqual'](y,h))throw new UnauthorizedError('Invalid\x20file\x20token');const P=Buffer[S(0x1d9)](z,'base64url')['toString']('utf8');return P;}};}
|
package/dist/plugins/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x75;const X=G();let g=X[R];return g;}const Z=q;import{SignJWT,jwtVerify}from'jose';const secret=new TextEncoder()[Z(0x75)](process.env.AUTH_JWT_SECRET);function G(){const y=['encode','setProtectedHeader','message'];G=function(){return y;};return G();}export async function jwtSignToken(R){const z=Z;if(!process.env.AUTH_JWT_SECRET)return;const {id:t,type:X,permissions:g}=R,m=await new SignJWT({'id':t,'type':X,'permissions':g})[z(0x76)]({'alg':'HS256'})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return m;}export async function jwtVerifyToken(R){const t=await jwtVerify(R,secret,{'algorithms':['HS256']})['catch'](X=>{const l=q;console['log'](X[l(0x77)]);});return t?.['payload'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import R from'pino';function q(R,t){R=R-0xe6;const X=G();let g=X[R];return g;}export function createLogger(){const l=q,t=R[l(0xe6)]({'target':'./transport.js'}),X=R({'level':'info','timestamp':R['stdTimeFunctions']['isoTime'],'base':{'service':l(0xe7)},'redact':{'paths':[l(0xe8),'password','token',l(0xe9),'refreshToken'],'censor':'[REDACTED]'}},t),g={};function m(Z,z){if(Z===undefined)return{...g};g[Z]=(g[Z]??0x0)+(z??0x1);}return Object['assign'](X,{'close':async()=>t[l(0xea)](),'metrics':m,'file':()=>X['info']['bind'](X)});}function G(){const y=['transport','app','req.headers.authorization','accessToken','end'];G=function(){return y;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import R from'node:fs';import t from'node:path';function q(R,t){R=R-0x162;const X=G();let g=X[R];return g;}import X from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const l=q;return new Date()['toISOString']()[l(0x162)](0x0,0xa);}function createStream(g,m){const y=q,Z=t['resolve']('logs',g);return R[y(0x163)](Z,{'recursive':!![]}),R['createWriteStream'](t[y(0x164)](Z,m+y(0x165)),{'flags':'a'});}function getStream(g){const h=q,m=getDate(),Z=streams['get'](g);if(Z&&Z[h(0x166)]===m)return Z[h(0x167)];Z?.['stream']['end']();const z=createStream(g,m);return streams['set'](g,{'date':m,'stream':z}),z;}function G(){const C=['slice','mkdirSync','join','.log','date','stream','values','clear','level','file'];G=function(){return C;};return G();}function closeStreams(){const P=q;for(const {stream:g}of streams[P(0x168)]()){g['end']();}streams[P(0x169)]();}export default async function loggerTransport(){return X(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(g){const E=q;for await(const m of g){const Z=LEVELS[m[E(0x16a)]];if(!Z)continue;const z=getStream(m[E(0x16b)]||Z);delete m['file'],z['write'](JSON['stringify'](m)+'\x0a');}}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import R from'pg';function q(R,t){R=R-0xc3;const X=G();let g=X[R];return g;}const {Pool}=R;export function createDatabase(t){const E=q,X=new Pool(t),g=X['query']['bind'](X);function m(Z,z){const l=new Error();return Error['captureStackTrace']?.(l,m),g(Z,z)['catch'](y=>{const h=y;h['sql']=Z,h['callerStack']=l['stack'];throw h;});}return X[E(0xc3)]=m,X['transaction']=async function(Z){const C=E,z=new Error();Error[C(0xc4)]?.(z,X['transaction']);const l=await X['connect']();try{await l[C(0xc3)]('BEGIN');const y=await Z(l);return await l['query']('COMMIT'),y;}catch(h){await l['query']('ROLLBACK');const P=h;P[C(0xc5)]=z['stack'];throw P;}finally{l[C(0xc6)]();}},X;}function G(){const L=['query','captureStackTrace','callerStack','release'];G=function(){return L;};return G();}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x1c0;const X=G();let g=X[R];return g;}import{Redis}from'ioredis';export function createRedis(R){const l=q,t=new Redis(R);return{'get':X=>t['get'](X),'set':(X,g,m,Z)=>{const z=q;if(Z)return t[z(0x1c0)](X,g,'EX',Z);if(typeof m==='number')return t['set'](X,g,'EX',m);return t['set'](X,g);},'del':X=>t['del'](X),'delete':X=>t[l(0x1c1)](X),'close':()=>t[l(0x1c2)](),'ping':()=>t['ping'](),'hincrby':(X,g,m)=>t[l(0x1c3)](X,g,m),'incrby':(X,g)=>t['incrby'](X,g)};}function G(){const y=['set','del','quit','hincrby'];G=function(){return y;};return G();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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';
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';function q(R,t){R=R-0x108;const X=G();let g=X[R];return g;}function G(){const C=['get','list','bind'];G=function(){return C;};return G();}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(R){const E=q,t=new ResourceRegistry(),X=createFind(R,t),g=createFindOne(R,t),m=createCreate(R,t),Z=createUpdate(R,t),z=createRemove(R,t),l=createFindRelation(R,t),y=createCreateRelation(R,t),h=createUpdateRelation(R,t),P=createDeleteRelation(R,t);return{'register':t['register']['bind'](t),'has':t['has']['bind'](t),'get':t[E(0x108)]['bind'](t),'list':t[E(0x109)][E(0x10a)](t),'find':X,'findOne':g,'create':m,'update':Z,'delete':z,'findRelation':l,'createRelation':y,'updateRelation':h,'deleteRelation':P};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(R,t){R=R-0x1a4;const X=G();let g=X[R];return g;}const Z=q;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(R){const g=q;return R[g(0x1a4)]('.')['length']<=0x2&&R['split']('.')['every'](t=>ident['test'](t));}export class ResourceRegistry{['resources']=new Map();['register'](R){const m=q;for(const t of Array['isArray'](R)?R:[R]){this['validate'](t);if(this['resources']['has'](t['name']))throw new ConflictError(m(0x1a5)+t[m(0x1a6)]);this['resources']['set'](t['name'],t);}}[Z(0x1a7)](R){return this['resources']['has'](R);}[Z(0x1a8)](R){const t=this['resources']['get'](R);if(!t)throw new NotFoundError('Resource\x20not\x20registered:\x20'+R);return t;}[Z(0x1a9)](){const z=Z;return[...this[z(0x1aa)][z(0x1ab)]()];}['validate'](R){const l=Z;if(R['version']!==0x1||!ident['test'](R['name'])||!validQualified(R['table'])||!ident['test'](R['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+R[l(0x1a6)]);for(const [t,X]of Object[l(0x1ac)](R['fields'])){if(!ident['test'](t)||!ident['test'](X[l(0x1ad)]??t))throw new ValidationError('Invalid\x20resource\x20field:\x20'+t);}}}function G(){const y=['split','Resource\x20already\x20registered:\x20','name','has','get','list','resources','values','entries','column'];G=function(){return y;};return G();}
|