@opengis/fcore 0.0.28 → 0.0.29

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.
Files changed (102) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.js +1 -1
  5. package/dist/fcore.js +1 -1
  6. package/dist/migrations/cli.js +1 -1
  7. package/dist/migrations/runner.js +1 -1
  8. package/dist/modules/auth/adduser-cli.js +1 -1
  9. package/dist/modules/auth/passwd-cli.js +1 -1
  10. package/dist/modules/auth/permission-cli.js +1 -1
  11. package/dist/modules/auth/route.js +1 -1
  12. package/dist/modules/auth/schema.js +1 -1
  13. package/dist/modules/auth/services/change-password.js +1 -1
  14. package/dist/modules/auth/services/get-current-user.js +1 -1
  15. package/dist/modules/auth/services/registration.js +1 -1
  16. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  17. package/dist/modules/file/mime.js +1 -1
  18. package/dist/modules/file/route.js +1 -1
  19. package/dist/modules/file/schema.js +1 -1
  20. package/dist/modules/file/services/get-file.js +1 -1
  21. package/dist/modules/file/services/resize-file.js +1 -1
  22. package/dist/modules/file/services/upload-file.js +1 -1
  23. package/dist/modules/resource/route.js +1 -1
  24. package/dist/modules/resource/schema.js +1 -1
  25. package/dist/modules/resource/services/add-note.js +1 -1
  26. package/dist/modules/resource/services/add-resource-file.js +1 -1
  27. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  28. package/dist/modules/resource/services/create-resource.js +1 -1
  29. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/delete-resource.js +1 -1
  31. package/dist/modules/resource/services/export-resource.js +1 -1
  32. package/dist/modules/resource/services/generate-resource-code.js +1 -1
  33. package/dist/modules/resource/services/get-resource-schema.js +1 -1
  34. package/dist/modules/resource/services/get-resource.js +1 -1
  35. package/dist/modules/resource/services/list-resource-as-user.js +1 -1
  36. package/dist/modules/resource/services/list-resource-list.js +1 -1
  37. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  38. package/dist/modules/resource/services/list-resources.js +1 -1
  39. package/dist/modules/resource/services/search-resource.js +1 -1
  40. package/dist/modules/resource/services/suggest-resource.js +1 -1
  41. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  42. package/dist/modules/resource/services/update-resource.js +1 -1
  43. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  44. package/dist/modules/system/route.js +1 -1
  45. package/dist/modules/system/schema.js +1 -1
  46. package/dist/modules/system/services/check-system.js +1 -1
  47. package/dist/modules/system/services/get-access.js +1 -1
  48. package/dist/modules/system/services/get-api-list.js +1 -1
  49. package/dist/modules/system/services/get-audit-log.js +1 -1
  50. package/dist/modules/system/services/get-dictionary.js +1 -1
  51. package/dist/modules/system/services/get-resource-access.js +1 -1
  52. package/dist/modules/system/services/get-resource-scopes.js +1 -1
  53. package/dist/modules/system/services/get-system-log.js +1 -1
  54. package/dist/modules/system/services/get-system-settings.js +1 -1
  55. package/dist/modules/system/services/list-dictionaries.js +1 -1
  56. package/dist/modules/system/services/set-access.js +1 -1
  57. package/dist/modules/system/services/set-resource-access.js +1 -1
  58. package/dist/modules/system/services/set-resource-scopes.js +1 -1
  59. package/dist/modules/system/services/update-dictionary.js +1 -1
  60. package/dist/modules/system/services/update-system-settings.js +1 -1
  61. package/dist/modules/utils/require-admin.js +1 -1
  62. package/dist/modules/utils/safe-user.js +1 -1
  63. package/dist/modules/utils/unsupported.js +1 -1
  64. package/dist/plugins/audit/audit.js +1 -1
  65. package/dist/plugins/audit/services/write-audit.js +1 -1
  66. package/dist/plugins/auth/get-user-permissions.js +1 -1
  67. package/dist/plugins/auth/index.js +1 -1
  68. package/dist/plugins/auth/verifyUser.js +1 -1
  69. package/dist/plugins/dictionary.js +1 -1
  70. package/dist/plugins/file.js +1 -1
  71. package/dist/plugins/jwt.js +1 -1
  72. package/dist/plugins/logger/index.js +1 -1
  73. package/dist/plugins/logger/transport.js +1 -1
  74. package/dist/plugins/pg.js +1 -1
  75. package/dist/plugins/redis.js +1 -1
  76. package/dist/plugins/resource/resource.js +1 -1
  77. package/dist/plugins/resource/resource.registry.js +1 -1
  78. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  79. package/dist/plugins/resource/services/add-file-token.js +1 -1
  80. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  81. package/dist/plugins/resource/services/create-relation.js +1 -1
  82. package/dist/plugins/resource/services/create.js +1 -1
  83. package/dist/plugins/resource/services/delete-relation.js +1 -1
  84. package/dist/plugins/resource/services/delete.js +1 -1
  85. package/dist/plugins/resource/services/find-one.js +1 -1
  86. package/dist/plugins/resource/services/find-relation.js +1 -1
  87. package/dist/plugins/resource/services/find.js +1 -1
  88. package/dist/plugins/resource/services/get-table-columns.js +1 -1
  89. package/dist/plugins/resource/services/update-relation.js +1 -1
  90. package/dist/plugins/resource/services/update.js +1 -1
  91. package/dist/plugins/resource/utils/auto-index.js +1 -1
  92. package/dist/plugins/resource/utils/fields.js +1 -1
  93. package/dist/plugins/resource/utils/filters.js +1 -1
  94. package/dist/plugins/resource/utils/permissions.js +1 -1
  95. package/dist/plugins/resource/utils/scope.js +1 -1
  96. package/dist/plugins/resource/utils/sort.js +1 -1
  97. package/dist/plugins/resource/utils/sql.js +1 -1
  98. package/dist/plugins/resource/utils/summary.js +1 -1
  99. package/dist/shared/getIP.js +1 -1
  100. package/migrations/20260903140000_settings_nulls_not_distinct.sql +1 -1
  101. package/migrations/20260905120000_add_user_foreign_keys.sql +15 -0
  102. package/package.json +1 -1
@@ -1 +1 @@
1
- function f(p,Z){p=p-0xf0;const A=s();let I=A[p];return I;}function s(){const K=['geometry','string','add','name','fields','read','resource','get','type','array','title'];s=function(){return K;};return s();}function variableType(p){const E=f;switch(p){case'number':case'integer':return'number';case'boolean':return'boolean';case'json':case E(0xf0):case'geom':return'object';default:return E(0xf1);}}function buildVariables(p,Z,A='',I=new Set()){const a=f,j=new Set(I)[a(0xf2)](p[a(0xf3)]),D=[];for(const [o,R]of Object['entries'](p[a(0xf4)])){if(R[a(0xf5)]===![]||R['readable']===![])continue;D['push']({'key':o,'path':A?A+'.'+o:o,'type':variableType(R['type'])});}for(const [B,H]of Object['entries'](p['relations']??{})){if(!H['resource']||!Z[a(0xf6)]['has'](H['resource']))continue;const e=Z['resource'][a(0xf7)](H['resource']),g=A?A+'.'+B:B,N=H[a(0xf8)]==='many',h={'key':B,'path':g,'type':N?a(0xf9):'object','resource':H['resource'],'variables':j['has'](e['name'])?[]:buildVariables(e,Z,g,j)};D['push'](h);}return D;}export function getResourceSchema(p,Z){const X=f,A=Z[X(0xf6)]['get'](p['resource']);return{'resource':A['name'],...A['title']?{'title':A[X(0xfa)]}:{},'variables':buildVariables(A,Z)};}
1
+ function O(){const Y=['integer','number','boolean','object','add','read','type','relations','resource','has','push'];O=function(){return Y;};return O();}function variableType(S){const i=c;switch(S){case'number':case i(0x1d0):return i(0x1d1);case i(0x1d2):return'boolean';case'json':case'geometry':case'geom':return i(0x1d3);default:return'string';}}function c(S,Z){S=S-0x1d0;const h=O();let U=h[S];return U;}function buildVariables(S,Z,h='',U=new Set()){const l=c,D=new Set(U)[l(0x1d4)](S['name']),u=[];for(const [e,q]of Object['entries'](S['fields'])){if(q[l(0x1d5)]===![]||q['readable']===![])continue;u['push']({'key':e,'path':h?h+'.'+e:e,'type':variableType(q[l(0x1d6)])});}for(const [x,n]of Object['entries'](S[l(0x1d7)]??{})){if(!n[l(0x1d8)]||!Z['resource']['has'](n[l(0x1d8)]))continue;const N=Z['resource']['get'](n[l(0x1d8)]),o=h?h+'.'+x:x,j=n[l(0x1d6)]==='many',X={'key':x,'path':o,'type':j?'array':'object','resource':n['resource'],'variables':D[l(0x1d9)](N['name'])?[]:buildVariables(N,Z,o,D)};u[l(0x1da)](X);}return u;}export function getResourceSchema(S,Z){const b=c,h=Z['resource']['get'](S[b(0x1d8)]);return{'resource':h['name'],...h['title']?{'title':h['title']}:{},'variables':buildVariables(h,Z)};}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x10f;var A=s();var I=A[p];return I;}function s(){var I=['findOne','resource'];s=function(){return I;};return s();}export async function getResource(p,Z){var A=f;return Z['resource'][A(0x10f)]({'name':p[A(0x110)],'id':p['id'],'query':{'include':p['include']},'user':p['user']});}
1
+ function O(){var U=['findOne','resource','include','user'];O=function(){return U;};return O();}function c(S,Z){S=S-0x1a5;var h=O();var U=h[S];return U;}export async function getResource(S,Z){var h=c;return Z['resource'][h(0x1a5)]({'name':S[h(0x1a6)],'id':S['id'],'query':{'include':S[h(0x1a7)]},'user':S[h(0x1a8)]});}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';function s(){const B=['query','user','User\x20not\x20found:\x20','scope','resource'];s=function(){return B;};return s();}function f(p,Z){p=p-0x15f;const A=s();let I=A[p];return I;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';export async function listResourceAsUser(p,Z){const R=f;if(p['requester']?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const A=await Z['pg'][R(0x15f)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[p[R(0x160)]]),I=A['rows'][0x0];if(!I)throw new NotFoundError(R(0x161)+p['user']);const j={'id':I['uid'],'type':I['type'],'permissions':await getUserPermissions(I['uid'],Z)},[D,o]=await Promise['all']([Z['resource']['find']({'name':p['resource'],'query':{'filter':parseFilterQuery(p),'sort':p['sort'],'search':p['search'],'include':p['include'],'scope':p[R(0x162)],'limit':p['limit'],'offset':p['offset']??(p['page']?Math['max'](Number(p['page'])-0x1,0x0):0x0)*Number(p['limit']??0x14)},'user':j}),getUserResourceScopes(j['id'],p[R(0x163)],Z['pg'])]);return{...D,'scopes':o};}
1
+ import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function c(S,Z){S=S-0x13f;const h=O();let U=h[S];return U;}import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';function O(){const x=['type','uid','find','search','page','max','resource'];O=function(){return x;};return O();}export async function listResourceAsUser(S,Z){const q=c;if(S['requester']?.[q(0x13f)]!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const h=await Z['pg']['query']('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[S['user']]),U=h['rows'][0x0];if(!U)throw new NotFoundError('User\x20not\x20found:\x20'+S['user']);const D={'id':U[q(0x140)],'type':U['type'],'permissions':await getUserPermissions(U['uid'],Z)},[u,e]=await Promise['all']([Z['resource'][q(0x141)]({'name':S['resource'],'query':{'filter':parseFilterQuery(S),'sort':S['sort'],'search':S[q(0x142)],'include':S['include'],'scope':S['scope'],'limit':S['limit'],'offset':S['offset']??(S[q(0x143)]?Math[q(0x144)](Number(S['page'])-0x1,0x0):0x0)*Number(S['limit']??0x14)},'user':D}),getUserResourceScopes(D['id'],S[q(0x145)],Z['pg'])]);return{...u,'scopes':e};}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x79;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(p,Z){const a=f;if(Z!==p['key']&&!p['fields'][Z])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+Z);const A=p[a(0x79)][Z]?.[a(0x7a)]??Z;return A['split']('.')['map'](I=>quoteIdentifier(I))[a(0x7b)]('.');}function displayExpression(p){const X=f,Z=p[X(0x7c)];if(!Z||Array['isArray'](Z)&&Z[X(0x7d)]===0x0)throw new ValidationError(X(0x7e)+p['name']);if(Array['isArray'](Z))return X(0x7f)+Z[X(0x80)](D=>X(0x81)+columnExpression(p,D)+X(0x82))['join'](',\x20')+')';const A=[],I=/\{([^{}]+)\}/g;let j=0x0;for(const D of Z['matchAll'](I)){const o=D[X(0x83)]??0x0,R=D[0x1];if(!R)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);o>j&&A['push']('\x27'+Z[X(0x84)](j,o)['replace'](/'/g,'\x27\x27')+'\x27'),A['push']('COALESCE('+columnExpression(p,R)+'::text,\x20\x27\x27)'),j=o+D[0x0]['length'];}j<Z['length']&&A[X(0x85)]('\x27'+Z[X(0x84)](j)['replace'](/'/g,'\x27\x27')+'\x27');if(A[X(0x7d)]===0x0)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);return'concat('+A['join'](',\x20')+')';}export async function listResourceList(p,Z){const K=f,A=Date['now'](),I=Z['resource']['get'](p['resource']);assertOperation(I,K(0x86),p['user']);const j=p['search']??'',D=Math['min'](Math['max'](Number(p['limit']??0x14),0x1),0xc8),o=I['searchable']??Object['entries'](I[K(0x79)])['filter'](([,h])=>h['searchable'])[K(0x80)](([h])=>h);if(j&&o[K(0x7d)]===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+I['name']);const R=displayExpression(I),B=[],H=[];if(I['where'])B[K(0x85)]('('+I['where']+')');if(j){const h=o[K(0x80)](E=>columnExpression(I,E)+K(0x87));B['push']('('+h[K(0x7b)]('\x20OR\x20')+')'),H['push']('%'+j+'%');}H[K(0x85)](D);const e=B[K(0x7d)]?'WHERE\x20'+B['join'](K(0x88)):'',g=I['joins']?.['map'](E=>E[K(0x89)])[K(0x7b)]('\x20')??'',N=await Z['pg']['query']('SELECT\x20'+quoteIdentifier(I[K(0x8a)])+'\x20AS\x20id,\x20'+R+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(I[K(0x8b)])+'\x20t\x20'+g+K(0x8c)+e+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+H['length'],H);return{'search':j,'limit':D,'count':N[K(0x8d)][K(0x7d)],'time':Date['now']()-A,'data':N[K(0x8d)]};}function s(){const Q=['fields','column','join','display','length','Resource\x20has\x20no\x20display\x20fields:\x20','concat_ws(\x27\x20\x27,\x20','map','COALESCE(','::text,\x20\x27\x27)','index','slice','push','read','::text\x20ILIKE\x20$1','\x20AND\x20','sql','key','table','\x0a\x20\x20\x20\x20\x20','rows'];s=function(){return Q;};return s();}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(S,Z){const l=c;if(Z!==S['key']&&!S[l(0x110)][Z])throw new ValidationError(l(0x111)+Z);const h=S[l(0x110)][Z]?.['column']??Z;return h['split']('.')['map'](U=>quoteIdentifier(U))['join']('.');}function displayExpression(S){const b=c,Z=S['display'];if(!Z||Array[b(0x112)](Z)&&Z[b(0x113)]===0x0)throw new ValidationError(b(0x114)+S[b(0x115)]);if(Array[b(0x112)](Z))return b(0x116)+Z['map'](u=>'COALESCE('+columnExpression(S,u)+b(0x117))['join'](',\x20')+')';const h=[],U=/\{([^{}]+)\}/g;let D=0x0;for(const u of Z['matchAll'](U)){const e=u['index']??0x0,q=u[0x1];if(!q)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+S['name']);e>D&&h['push']('\x27'+Z[b(0x118)](D,e)['replace'](/'/g,'\x27\x27')+'\x27'),h['push'](b(0x119)+columnExpression(S,q)+'::text,\x20\x27\x27)'),D=e+u[0x0]['length'];}D<Z['length']&&h['push']('\x27'+Z['slice'](D)['replace'](/'/g,'\x27\x27')+'\x27');if(h['length']===0x0)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+S['name']);return'concat('+h['join'](',\x20')+')';}function c(S,Z){S=S-0x110;const h=O();let U=h[S];return U;}export async function listResourceList(S,Z){const Y=c,h=Date['now'](),U=Z['resource'][Y(0x11a)](S['resource']);assertOperation(U,'read',S['user']);const D=S[Y(0x11b)]??'',u=Math['min'](Math[Y(0x11c)](Number(S['limit']??0x14),0x1),0xc8),e=U['searchable']??Object['entries'](U[Y(0x110)])[Y(0x11d)](([,X])=>X[Y(0x11e)])[Y(0x11f)](([X])=>X);if(D&&e['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+U['name']);const q=displayExpression(U),x=[],n=[];if(U['where'])x[Y(0x120)]('('+U['where']+')');if(D){const X=e['map'](i=>columnExpression(U,i)+'::text\x20ILIKE\x20$1');x[Y(0x120)]('('+X['join'](Y(0x121))+')'),n['push']('%'+D+'%');}n['push'](u);const N=x['length']?'WHERE\x20'+x['join'](Y(0x122)):'',o=U['joins']?.[Y(0x11f)](i=>i['sql'])['join']('\x20')??'',j=await Z['pg']['query']('SELECT\x20'+quoteIdentifier(U[Y(0x123)])+'\x20AS\x20id,\x20'+q+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(U['table'])+'\x20t\x20'+o+'\x0a\x20\x20\x20\x20\x20'+N+Y(0x124)+n['length'],n);return{'search':D,'limit':u,'count':j['rows']['length'],'time':Date[Y(0x125)]()-h,'data':j['rows']};}function O(){const r=['fields','Unknown\x20display/search\x20field:\x20','isArray','length','Resource\x20has\x20no\x20display\x20fields:\x20','name','concat_ws(\x27\x20\x27,\x20','::text,\x20\x27\x27)','slice','COALESCE(','get','search','max','filter','searchable','map','push','\x20OR\x20','\x20AND\x20','key','\x0a\x20\x20\x20\x20\x20LIMIT\x20$','now'];O=function(){return r;};return O();}
@@ -1 +1 @@
1
- export async function listResourceRelation(p,Z){const {resource:A,id:I,relation:j,query:D,user:o}=p;return Z['resource']['findRelation']({'name':A,'id':I,'relation':j,'query':D,'user':o});}
1
+ export async function listResourceRelation(S,Z){const {resource:h,id:U,relation:D,query:u,user:e}=S;return Z['resource']['findRelation']({'name':h,'id':U,'relation':D,'query':u,'user':e});}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(p,Z){p=p-0x13a;const A=s();let I=A[p];return I;}function s(){const j=['user','resource','sort','search','scope','offset','page','limit'];s=function(){return j;};return s();}export async function listResources(p,Z){const I=f,A=p[I(0x13a)];return Z['resource']['find']({'name':p[I(0x13b)],'query':{'filter':parseFilterQuery(p),'sort':p[I(0x13c)],'search':p[I(0x13d)],'include':p['include'],'scope':p[I(0x13e)],'limit':p['limit'],'offset':p[I(0x13f)]??(p[I(0x140)]?Math['max'](p['page']-0x1,0x0):0x0)*(p[I(0x141)]??0x14)},'user':A});}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function c(S,Z){S=S-0x120;const h=O();let U=h[S];return U;}export async function listResources(S,Z){const U=c,h=S[U(0x120)];return Z['resource']['find']({'name':S['resource'],'query':{'filter':parseFilterQuery(S),'sort':S['sort'],'search':S['search'],'include':S['include'],'scope':S['scope'],'limit':S['limit'],'offset':S['offset']??(S[U(0x121)]?Math['max'](S['page']-0x1,0x0):0x0)*(S['limit']??0x14)},'user':h});}function O(){const D=['user','page'];O=function(){return D;};return O();}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function s(){var I=['user'];s=function(){return I;};return s();}function f(p,Z){p=p-0x1cc;var A=s();var I=A[p];return I;}export async function searchResource(p,Z){var A=f;return Z['resource']['find']({'name':p['resource'],'query':{...p,'filter':parseFilterQuery(p)},'user':p[A(0x1cc)]});}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function c(S,Z){S=S-0x1d8;var h=O();var U=h[S];return U;}export async function searchResource(S,Z){var h=c;return Z['resource']['find']({'name':S['resource'],'query':{...S,'filter':parseFilterQuery(S)},'user':S[h(0x1d8)]});}function O(){var U=['user'];O=function(){return U;};return O();}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x15b;const A=s();let I=A[p];return I;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function s(){const X=['resource','search','min','dictionary','lookup','value','text','\x20as\x20id,\x20','\x20as\x20text\x20FROM\x20','\x20WHERE\x20lower(','then','startsWith','slice','name','length'];s=function(){return X;};return s();}export async function suggestResource(p,Z){const a=f,A=Z['resource']['get'](p[a(0x15b)]),I=String(p[a(0x15c)]??p['q']??'')['toLowerCase'](),j=Math[a(0x15d)](Math['max'](Number(p['limit']??0x14),0x1),0xc8),D=Date['now'](),o=A['fields'][p['field']],R=o?.[a(0x15e)],B=o?.[a(0x15f)]?.['table'];if(B){const g=o[a(0x15f)]?.['text']??'name',N=o['lookup']?.[a(0x160)]??'id';autoIndex(B,g,a(0x161),Z['pg']);const h=await Z['pg']['query']('SELECT\x20'+N+a(0x162)+g+a(0x163)+B+a(0x164)+g+')\x20~\x20$1\x20LIMIT\x20$2',[''+I['toLowerCase'](),j])[a(0x165)](E=>E['rows']);return{'limit':j,'count':h['length'],'search':I,'time':Date['now']()-D,'data':h};}if(!R)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+p['field']);const H=await Z['dictionary']['get'](R),e=H['filter'](E=>!I||E['code'][a(0x166)](I)||E['name']['startsWith'](I))[a(0x167)](0x0,j)['map'](E=>({'id':E['code']||E['id'],'text':E[a(0x168)]||E['text']}));return{'search':I,'limit':j,'count':e[a(0x169)],'time':Date['now']()-D,'data':e};}
1
+ function c(S,Z){S=S-0x178;const h=O();let U=h[S];return U;}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(S,Z){const l=c,h=Z[l(0x178)]['get'](S['resource']),U=String(S['search']??S['q']??'')[l(0x179)](),D=Math[l(0x17a)](Math['max'](Number(S[l(0x17b)]??0x14),0x1),0xc8),u=Date[l(0x17c)](),e=h['fields'][S[l(0x17d)]],q=e?.['dictionary'],x=e?.[l(0x17e)]?.['table'];if(x){const o=e['lookup']?.['text']??'name',j=e[l(0x17e)]?.['value']??'id';autoIndex(x,o,'text',Z['pg']);const X=await Z['pg']['query']('SELECT\x20'+j+'\x20as\x20id,\x20'+o+l(0x17f)+x+'\x20WHERE\x20lower('+o+l(0x180),[''+U['toLowerCase'](),D])['then'](i=>i['rows']);return{'limit':D,'count':X['length'],'search':U,'time':Date['now']()-u,'data':X};}if(!q)throw new ValidationError(l(0x181)+S[l(0x17d)]);const n=await Z['dictionary']['get'](q),N=n['filter'](i=>!U||i['code'][l(0x182)](U)||i['name']['startsWith'](U))['slice'](0x0,D)['map'](i=>({'id':i['code']||i['id'],'text':i[l(0x183)]||i['text']}));return{'search':U,'limit':D,'count':N['length'],'time':Date[l(0x17c)]()-u,'data':N};}function O(){const b=['resource','toLowerCase','min','limit','now','field','lookup','\x20as\x20text\x20FROM\x20',')\x20~\x20$1\x20LIMIT\x20$2','Field\x20has\x20no\x20lookup\x20dictionary:\x20','startsWith','name'];O=function(){return b;};return O();}
@@ -1 +1 @@
1
- export async function updateResourceRelation(p,Z){const {resource:A,id:I,relation:j,relationId:D,data:o,user:R}=p;return Z['resource']['updateRelation']({'name':A,'id':I,'relation':j,'relationId':D,'data':o,'user':R});}
1
+ export async function updateResourceRelation(S,Z){const {resource:h,id:U,relation:D,relationId:u,data:e,user:q}=S;return Z['resource']['updateRelation']({'name':h,'id':U,'relation':D,'relationId':u,'data':e,'user':q});}
@@ -1 +1 @@
1
- export async function updateResource(p,Z){var A=f;return Z[A(0x8e)]['update']({'name':p[A(0x8e)],'id':p['id'],'data':p[A(0x8f)],'user':p['user']});}function f(p,Z){p=p-0x8e;var A=s();var I=A[p];return I;}function s(){var I=['resource','patch'];s=function(){return I;};return s();}
1
+ function c(S,Z){S=S-0x1db;var h=O();var U=h[S];return U;}export async function updateResource(S,Z){var h=c;return Z[h(0x1db)][h(0x1dc)]({'name':S[h(0x1db)],'id':S['id'],'data':S[h(0x1dd)],'user':S[h(0x1de)]});}function O(){var U=['resource','update','patch','user'];O=function(){return U;};return O();}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x1d3;const A=s();let I=A[p];return I;}function s(){const R=['resource','type','user','permission','name','replace','File\x20name\x20is\x20required','files/'];s=function(){return R;};return s();}export async function uploadResourceFile(p,Z){const o=f,A=Z[o(0x1d3)]['get'](p[o(0x1d3)]);if(A['access']==='admin'&&p['user']?.[o(0x1d4)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p[o(0x1d5)]?.['type']!=='admin'&&!p['user']?.['permissions']?.['includes']((A[o(0x1d6)]??A[o(0x1d7)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(A['permission']??A['name'])+':update');if(!Buffer['isBuffer'](p['file'])||p['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const I=p['fileName'][o(0x1d8)](/[^A-Za-z0-9._-]/g,'_');if(!I)throw new ValidationError(o(0x1d9));const j=o(0x1da)+p['resource']+'/'+String(p['id'])+'/'+I;await Z['file']['put'](j,p['file']);if(!await Z['file']['exists'](j))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const D=await Z['pg']['query']('\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',[p['resource'],String(p['id']),j,p['file']['length']]);return D['rows'][0x0];}
1
+ function O(){const q=['get','admin','type','user','isBuffer','File\x20is\x20required','fileName','File\x20name\x20is\x20required','files/','put','file','Uploaded\x20file\x20not\x20found','rows'];O=function(){return q;};return O();}function c(S,Z){S=S-0x114;const h=O();let U=h[S];return U;}import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(S,Z){const e=c,h=Z['resource'][e(0x114)](S['resource']);if(h['access']===e(0x115)&&S['user']?.[e(0x116)]!==e(0x115))throw new ForbiddenError('Admin\x20access\x20required');if(S['user']?.['type']!==e(0x115)&&!S[e(0x117)]?.['permissions']?.['includes']((h['permission']??h['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(h['permission']??h['name'])+':update');if(!Buffer[e(0x118)](S['file'])||S['file']['length']===0x0)throw new ValidationError(e(0x119));const U=S[e(0x11a)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!U)throw new ValidationError(e(0x11b));const D=e(0x11c)+S['resource']+'/'+String(S['id'])+'/'+U;await Z['file'][e(0x11d)](D,S[e(0x11e)]);if(!await Z['file']['exists'](D))throw new NotFoundError(e(0x11f));const u=await Z['pg']['query']('\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',[S['resource'],String(S['id']),D,S['file']['length']]);return u[e(0x120)][0x0];}
@@ -1 +1 @@
1
- const B=f;import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';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 f(p,Z){p=p-0xde;const A=s();let I=A[p];return I;}import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';function s(){const g=['user','Get\x20platform\x20dictionary','dictionaryName','/api/dictionary/:name','system','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','system:dictionaries','params','/api/access/scope/:resource','fcore','Set\x20resource\x20access\x20scopes','Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','admin','get','Get\x20user\x20access\x20for\x20a\x20resource','Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','resourceAccess','Get\x20access\x20rules','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','post','Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','system:access','system:settings','/api/system/settings','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','system:logs','logger','query','send','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','List\x20APIs'];s=function(){return g;};return s();}import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=p=>p[B(0xde)];export function systemRoutes(p,Z=new Map()){return async A=>{const H=f;A['get']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':H(0xdf),'description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[H(0xe0)]}},async j=>({'items':await getDictionary({...j['params'],'user':u(j)},p)})),A['post'](H(0xe1),{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xe3),'description':H(0xe4),'access':'user','permissions':[H(0xe5)],'params':systemSchemas['dictionaryName'],'body':systemSchemas['dictionaryItems']}},async j=>updateDictionary({...j['params'],...j['body'],'user':u(j)},p));const I=async j=>getAccess({...j[H(0xe6)],'user':u(j)},p);A['get'](H(0xe7),{'schema':{'tags':['fcore',H(0xe2)],'summary':'Get\x20resource\x20access\x20scopes','description':'Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['resourceScope']}},async j=>getResourceScopes(j['params'],p)),A['post']('/api/access/scope/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':H(0xe9),'description':H(0xea),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async j=>setResourceScopes({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/resource/:resource',{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xed),'description':H(0xee),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async j=>getResourceAccess(j['params'],p)),A['post']('/api/access/resource/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':H(0xef),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams'],'body':systemSchemas[H(0xf0)]}},async j=>setResourceAccess({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':H(0xf1),'description':H(0xf2),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget']}},I),A[H(0xf3)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':H(0xf4),'access':'admin','permissions':[H(0xf5)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async j=>setAccess({...j['params'],...j['body'],'user':u(j)},p)),A['get']('/api/system/settings',{'schema':{'tags':[H(0xe8),H(0xe2)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[H(0xf6)]}},async j=>getSystemSettings({...j[H(0xe6)],'user':u(j)},p)),A['post'](H(0xf7),{'schema':{'tags':['fcore','system'],'summary':H(0xf8),'description':H(0xf9),'access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async j=>updateSystemSettings({...j['params'],'patch':j['body'],'user':u(j)},p)),A['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':[H(0xfa)],'querystring':systemSchemas[H(0xfb)]}},async(j,D)=>{const e=H,{contentType:o,body:R}=await getSystemLog({...j[e(0xfc)],'user':u(j)},p);return D['type'](o)[e(0xfd)](R);}),A[H(0xec)]('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':H(0xfe),'access':'user','permissions':[H(0xff)]}},async j=>getAuditLog({...j['query'],'user':u(j)},p)),A[H(0xec)]('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async j=>checkSystem({'user':u(j)},p)),A['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':H(0x100),'description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':H(0xeb),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async j=>getApiList({'user':u(j),'apiRoutes':Z,...j['query']},p));};}
1
+ import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';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';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';function O(){const N=['/api/dictionary/:name','fcore','user','dictionaryName','params','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','dictionaryItems','body','resourceScope','system','/api/access/resource/:resource','admin','system:access','post','Set\x20user\x20access\x20for\x20a\x20resource','/api/access/:type/:id','Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','system:settings','Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','/api/system/audit','get','Checks\x20the\x20availability\x20of\x20system\x20dependencies.','/api/system/list'];O=function(){return N;};return O();}import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';function c(S,Z){S=S-0x75;const h=O();let U=h[S];return U;}import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=S=>S['user'];export function systemRoutes(S,Z=new Map()){return async h=>{const n=c;h['get'](n(0x75),{'schema':{'tags':[n(0x76),'system'],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':n(0x77),'permissions':['system:dictionaries'],'params':systemSchemas[n(0x78)]}},async D=>({'items':await getDictionary({...D[n(0x79)],'user':u(D)},S)})),h['post']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':'Update\x20platform\x20dictionary','description':n(0x7a),'access':'user','permissions':['system:dictionaries'],'params':systemSchemas['dictionaryName'],'body':systemSchemas[n(0x7b)]}},async D=>updateDictionary({...D['params'],...D[n(0x7c)],'user':u(D)},S));const U=async D=>getAccess({...D['params'],'user':u(D)},S);h['get']('/api/access/scope/:resource',{'schema':{'tags':[n(0x76),'system'],'summary':'Get\x20resource\x20access\x20scopes','description':'Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas[n(0x7d)]}},async D=>getResourceScopes(D[n(0x79)],S)),h['post']('/api/access/scope/:resource',{'schema':{'tags':['fcore',n(0x7e)],'summary':'Set\x20resource\x20access\x20scopes','description':'Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','access':'admin','permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async D=>setResourceScopes({...D[n(0x79)],...D['body'],'user':u(D)},S)),h['get'](n(0x7f),{'schema':{'tags':[n(0x76),n(0x7e)],'summary':'Get\x20user\x20access\x20for\x20a\x20resource','description':'Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':n(0x80),'permissions':[n(0x81)],'params':systemSchemas['accessResourceParams']}},async D=>getResourceAccess(D['params'],S)),h[n(0x82)]('/api/access/resource/:resource',{'schema':{'tags':['fcore',n(0x7e)],'summary':n(0x83),'description':'Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams'],'body':systemSchemas['resourceAccess']}},async D=>setResourceAccess({...D['params'],...D['body'],'user':u(D)},S)),h['get']('/api/access/:type/:id',{'schema':{'tags':['fcore',n(0x7e)],'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']}},U),h['post'](n(0x84),{'schema':{'tags':[n(0x76),n(0x7e)],'summary':'Set\x20access\x20rules','description':n(0x85),'access':n(0x80),'permissions':['system:access'],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async D=>setAccess({...D[n(0x79)],...D[n(0x7c)],'user':u(D)},S)),h['get']('/api/system/settings',{'schema':{'tags':['fcore',n(0x7e)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':['system:settings']}},async D=>getSystemSettings({...D[n(0x79)],'user':u(D)},S)),h[n(0x82)]('/api/system/settings',{'schema':{'tags':['fcore',n(0x7e)],'summary':n(0x86),'description':n(0x87),'access':'admin','permissions':[n(0x88)],'body':systemSchemas['settings']}},async D=>updateSystemSettings({...D['params'],'patch':D['body'],'user':u(D)},S)),h['get']('/api/system/logger',{'schema':{'tags':['fcore',n(0x7e)],'summary':'Get\x20system\x20log','description':n(0x89),'access':n(0x77),'permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(D,e)=>{const {contentType:q,body:x}=await getSystemLog({...D['query'],'user':u(D)},S);return e['type'](q)['send'](x);}),h['get'](n(0x8a),{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':'user','permissions':['system:audit']}},async D=>getAuditLog({...D['query'],'user':u(D)},S)),h[n(0x8b)]('/api/system/check',{'schema':{'tags':['fcore',n(0x7e)],'summary':'Check\x20system\x20health','description':n(0x8c),'access':n(0x77),'permissions':['system:check']}},async D=>checkSystem({'user':u(D)},S)),h['get'](n(0x8d),{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas['apiListQuery']}},async D=>getApiList({'user':u(D),'apiRoutes':Z,...D['query']},S));};}
@@ -1 +1 @@
1
- const p=f;import{Type}from'@sinclair/typebox';export const identifier=Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}function s(){const Z=['String','Object','Number','Union','Literal','user','role','Optional','Array','Unknown','^[A-Za-z0-9_.\x5c-/]*$'];s=function(){return Z;};return s();}export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type[p(0x1a1)]({'id':Type['Optional'](Type['Union']([Type[p(0x1a0)](),Type[p(0x1a2)]()])),'code':Type[p(0x1a0)]({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type[p(0x1a3)]([Type[p(0x1a4)](p(0x1a5)),Type['Literal'](p(0x1a6))]),'id':identifier}),'accessResourceParams':Type['Object']({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type['Object']({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type[p(0x1a3)]([Type['Array'](Type['Unknown']()),Type['String'](),Type[p(0x1a2)](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type['Object']({'users':Type[p(0x1a7)](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type[p(0x1a8)](Type['Object']({'role_id':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type['Optional'](Type[p(0x1a8)](identifier)),'permissions':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type[p(0x1a3)]([Type[p(0x1a4)]('short'),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type[p(0x1a0)]({'minLength':0x1}),Type[p(0x1a9)]()),'logger':Type[p(0x1a1)]({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':p(0x1aa)}))})};
1
+ function c(S,Z){S=S-0x7f;const h=O();let U=h[S];return U;}const S=c;import{Type}from'@sinclair/typebox';function O(){const Z=['String','Object','Optional','Union','Number','Unknown','Null','Array','short','Record','^[A-Za-z0-9_.\x5c-/]*$'];O=function(){return Z;};return O();}export const identifier=Type[S(0x7f)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type[S(0x80)]({'items':Type['Array'](Type['Object']({'id':Type[S(0x81)](Type[S(0x82)]([Type['String'](),Type[S(0x83)]()])),'code':Type['String']({'minLength':0x1}),'name':Type[S(0x7f)]({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type[S(0x82)]([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'accessResourceParams':Type[S(0x80)]({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type[S(0x80)]({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type[S(0x82)]([Type['Array'](Type[S(0x84)]()),Type[S(0x7f)](),Type['Number'](),Type['Boolean'](),Type[S(0x85)]()]))}),'resourceAccess':Type['Object']({'users':Type['Optional'](Type[S(0x86)](Type[S(0x80)]({'uid':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type[S(0x81)](Type['Array'](Type[S(0x80)]({'role_id':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type['Optional'](Type['Array'](identifier)),'permissions':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type[S(0x86)](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type[S(0x82)]([Type['Literal'](S(0x87)),Type['Literal']('extended')]))}),'settingsEntity':Type[S(0x80)]({'entity':Type[S(0x81)](identifier)}),'settings':Type[S(0x88)](Type[S(0x7f)]({'minLength':0x1}),Type[S(0x84)]()),'logger':Type[S(0x80)]({'path':Type[S(0x81)](Type['String']({'maxLength':0x100,'pattern':S(0x89)}))})};
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x1c6;const A=s();let I=A[p];return I;}export async function checkSystem(p,Z){const j=f,[A,I]=await Promise['allSettled']([Z['pg']['query']('SELECT\x201'),Z[j(0x1c6)][j(0x1c7)]()]);return{'status':A['status']==='fulfilled'&&I['status']==='fulfilled'?'ok':'degraded','pg':A['status'],'redis':I['status']};}function s(){const D=['redis','ping'];s=function(){return D;};return s();}
1
+ export async function checkSystem(S,Z){const D=c,[h,U]=await Promise['allSettled']([Z['pg']['query']('SELECT\x201'),Z['redis']['ping']()]);return{'status':h[D(0x1b4)]==='fulfilled'&&U['status']==='fulfilled'?'ok':'degraded','pg':h[D(0x1b4)],'redis':U[D(0x1b4)]};}function c(S,Z){S=S-0x1b4;const h=O();let U=h[S];return U;}function O(){const u=['status'];O=function(){return u;};return O();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}export async function getAccess(p,Z){const o=f,A=p['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',I=await Z['pg']['query'](A,[p['id']]),j=[...new Set(I['rows'][o(0x1a0)](D=>D['resource'])[o(0x1a1)](D=>D!==null))];return{'access':I['rows'],'resources':j};}function s(){const R=['map','filter'];s=function(){return R;};return s();}
1
+ export async function getAccess(S,Z){const e=c,h=S['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':e(0x103),U=await Z['pg'][e(0x104)](h,[S['id']]),D=[...new Set(U[e(0x105)]['map'](u=>u['resource'])['filter'](u=>u!==null))];return{'access':U['rows'],'resources':D};}function c(S,Z){S=S-0x103;const h=O();let U=h[S];return U;}function O(){const q=['\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','query','rows'];O=function(){return q;};return O();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x66;const A=s();let I=A[p];return I;}export async function getApiList(p,Z){const R=f,A=[...p[R(0x66)][R(0x67)]()][R(0x68)]((I,j)=>(I['endpoint']+'\x20'+I[R(0x69)])['localeCompare'](j['endpoint']+'\x20'+j['method']));if(p['format']!=='short')return A;return A['map'](({method:I,endpoint:j,access:D,permissions:o})=>I+'\x20'+j);}function s(){const B=['apiRoutes','values','sort','method'];s=function(){return B;};return s();}
1
+ export async function getApiList(S,Z){const q=c,h=[...S['apiRoutes']['values']()]['sort']((U,D)=>(U['endpoint']+'\x20'+U[q(0x106)])['localeCompare'](D['endpoint']+'\x20'+D['method']));if(S[q(0x107)]!=='short')return h;return h['map'](({method:U,endpoint:D,access:u,permissions:e})=>U+'\x20'+D);}function c(S,Z){S=S-0x106;const h=O();let U=h[S];return U;}function O(){const x=['method','format'];O=function(){return x;};return O();}
@@ -1 +1 @@
1
- export async function getAuditLog(p,Z){const D=f,A=Math[D(0xd7)](Math[D(0xd8)](p['limit']??0x32,0x1),0xc8),I=Math['max']((p['page']??0x1)-0x1,0x0)*A,j=await Z['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[A,I]);return{'rows':j['rows'],'page':p['page']??0x1,'limit':A};}function f(p,Z){p=p-0xd7;const A=s();let I=A[p];return I;}function s(){const o=['min','max'];s=function(){return o;};return s();}
1
+ function O(){const e=['max'];O=function(){return e;};return O();}function c(S,Z){S=S-0xda;const h=O();let U=h[S];return U;}export async function getAuditLog(S,Z){const u=c,h=Math['min'](Math[u(0xda)](S['limit']??0x32,0x1),0xc8),U=Math['max']((S['page']??0x1)-0x1,0x0)*h,D=await Z['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[h,U]);return{'rows':D['rows'],'page':S['page']??0x1,'limit':h};}
@@ -1 +1 @@
1
- export async function getDictionary(p,Z){return Z['dictionary']['get'](p['name']);}
1
+ function c(S,Z){S=S-0x1c1;var h=O();var U=h[S];return U;}function O(){var U=['dictionary'];O=function(){return U;};return O();}export async function getDictionary(S,Z){var h=c;return Z[h(0x1c1)]['get'](S['name']);}
@@ -1 +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();}
1
+ export async function getResourceAccess(S,Z){const Y=c,[h,U,D]=await Promise['all']([Z['pg']['query']('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',[S['resource']]),Z['pg']['query'](Y(0x197),[S['resource']]),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',[S['resource']])]),u=new Map(),e=new Map();for(const n of D[Y(0x198)]){if(n['user_id']!==null){const N=u['get'](n['user_id'])??{};N[n[Y(0x199)]]=n[Y(0x19a)],u['set'](n[Y(0x19b)],N);}else{if(n['role_id']!==null){const o=e['get'](n[Y(0x19c)])??{};o[n['scope']]=n[Y(0x19a)],e[Y(0x19d)](n['role_id'],o);}}}const q=h[Y(0x198)][Y(0x19e)](j=>({...j,...u['has'](j[Y(0x19f)])?{'scopes':u['get'](j['uid'])}:{}}));for(const [j,X]of u){!q[Y(0x1a0)](i=>i['uid']===j)&&q['push']({'type':Y(0x1a1),'uid':j,'actions':[],'scopes':X});}const x=U[Y(0x198)]['map'](i=>({...i,...e[Y(0x1a2)](i['role_id'])?{'scopes':e['get'](i['role_id'])}:{}}));for(const [i,l]of e){!x[Y(0x1a0)](b=>b[Y(0x19c)]===i)&&x['push']({'type':'role','role_id':i,'name':null,'actions':[],'users_count':0x0,'scopes':l});}return{'resource':S[Y(0x1a3)],'users':q,'roles':x};}function c(S,Z){S=S-0x197;const h=O();let U=h[S];return U;}function O(){const r=['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','rows','scope','value','user_id','role_id','set','map','uid','some','user','has','resource'];O=function(){return r;};return O();}
@@ -1 +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
+ export async function getResourceScopes(S,Z){const n=c,{rows:h}=await Z['pg'][n(0x15b)](n(0x15c),[S['resource']]),U=new Map(),D=new Map();for(const u of h){if(u[n(0x15d)]!==null){const e=u['user_id']+':'+(u['role_id']??''),q=U['get'](e)??{'user_id':u[n(0x15d)],'role_id':u['role_id'],'scopes':{}};q['scopes'][u[n(0x15e)]]=u['value'],U[n(0x15f)](e,q);continue;}if(u['role_id']!==null){const x=D[n(0x160)](u['role_id'])??{'role_id':u['role_id'],'scopes':{}};x['scopes'][u[n(0x15e)]]=u[n(0x161)],D['set'](u['role_id'],x);}}return{'resource':S['resource'],'users':[...U['values']()],'roles':[...D[n(0x162)]()]};}function c(S,Z){S=S-0x15b;const h=O();let U=h[S];return U;}function O(){const N=['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','user_id','scope','set','get','value','values'];O=function(){return N;};return O();}
@@ -1 +1 @@
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,'&amp;')[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','&lt;','&gt;','&quot;','open','slice'];s=function(){return O;};return s();}
1
+ const i=c;import S from'node:fs/promises';import Z from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=Z['resolve'](process[i(0x1f0)](),'logs'),TAIL_LINES=0x64;function c(S,Z){S=S-0x1f0;const h=O();let U=h[S];return U;}function O(){const k=['cwd','Invalid\x20log\x20path','all','directory','sort','name','split','join','unshift','?path=','logs/','replace','&lt;','&gt;','&quot;','open','alloc','min','utf8','length'];O=function(){return k;};return O();}export async function getSystemLog(h,U){const l=i,D=normalizePath(h['path']),u=Z['resolve'](LOGS_ROOT,D);if(u!==LOGS_ROOT&&!u['startsWith'](LOGS_ROOT+Z['sep']))throw new ValidationError(l(0x1f1));const e=await S['stat'](u)['catch'](()=>null);if(!e)throw new NotFoundError('Log\x20path\x20not\x20found');if(e['isDirectory']()){const x=await S['readdir'](u,{'withFileTypes':!![]}),n=await Promise[l(0x1f2)](x['map'](async N=>{const b=l,o=await S['stat'](Z['join'](u,N['name']));return{'name':N['name'],'path':D?D+'/'+N['name']:N['name'],'type':N['isDirectory']()?b(0x1f3):'file','size':N['isDirectory']()?undefined:o['size'],'modified':o['mtime']['toISOString']()};}));n[l(0x1f4)]((N,o)=>N[l(0x1f5)]['localeCompare'](o['name']));if(D){const N=D[l(0x1f6)]('/')['slice'](0x0,-0x1)[l(0x1f7)]('/');n[l(0x1f8)]({'name':'..','path':N,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(D,n)};}const q=await tailFile(u,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':q['join']('\x0a')};}function renderDirectory(h,U){const r=i,D=U['map'](e=>{const Y=c,q=Y(0x1f9)+encodeURIComponent(e['path']),x=e['type']===Y(0x1f3)?e['name']+'/':e['name'];return'<li><a\x20href=\x22'+q+'\x22>'+escapeHtml(x)+'</a></li>';})['join']('\x0a'),u=escapeHtml(r(0x1fa)+h);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+u+'</title></head>\x0a<body>\x0a<h1>'+u+'</h1>\x0a<ul>\x0a'+D+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(h){const E=i;return h[E(0x1fb)](/&/g,'&amp;')['replace'](/</g,E(0x1fc))['replace'](/>/g,E(0x1fd))['replace'](/"/g,E(0x1fe));}function normalizePath(h){const L=i,U=(h??'')['replace'](/\\/g,'/')[L(0x1fb)](/^\/+|\/+$/g,'');if(U['split']('/')['some'](D=>D==='..'))throw new ValidationError(L(0x1f1));return U;}async function tailFile(h,U){const V=i,D=await S[V(0x1ff)](h,'r');try{const {size:u}=await D['stat'](),e=0x40*0x400;let q=u,x=Buffer[V(0x200)](0x0),n=0x0;while(q>0x0&&n<=U){const o=Math[V(0x201)](e,q);q-=o;const j=Buffer['alloc'](o);await D['read'](j,0x0,o,q),x=Buffer['concat']([j,x]),n+=countNewlines(j);}const N=x['toString'](V(0x202))[V(0x1f6)]('\x0a')['filter'](X=>X[V(0x203)]>0x0);return N['slice'](-U)['reverse']();}finally{await D['close']();}}function countNewlines(h){let U=0x0;for(const D of h){if(D===0xa)U++;}return U;}
@@ -1 +1 @@
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
+ export async function getSystemSettings(S,Z){const x=c,h=await Z['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 h['rows'][x(0x8f)]((U,D)=>{const n=x,u=String(D['key'])['split']('.');let e=U;for(const q of u[n(0x90)](0x0,-0x1)){e[q]??={},e=e[q];}return e[u['at'](-0x1)]=D['value'],U;},{});}function c(S,Z){S=S-0x8f;const h=O();let U=h[S];return U;}function O(){const N=['reduce','slice'];O=function(){return N;};return O();}
@@ -1 +1 @@
1
- export async function listDictionaries(p,Z){return Z['dictionary']['list']();}
1
+ export async function listDictionaries(S,Z){return Z['dictionary']['list']();}
@@ -1 +1 @@
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);}
1
+ function c(S,Z){S=S-0xfe;const h=O();let U=h[S];return U;}const N=c;import{getAccess}from'./get-access.js';const CRUD_ACTIONS=[N(0xfe),'update',N(0xff),'delete'];function O(){const X=['read','create','add','BEGIN','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','user','permissions','resource','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','ROLLBACK'];O=function(){return X;};return O();}function permissionsToAccess(S){const o=N,Z=new Map();for(const h of S){const [U,D]=h['split'](':');if(!U)continue;const u=D==='edit'?'update':D,e=Z['get'](U)??new Set();for(const q of u?[u]:CRUD_ACTIONS)e[o(0x100)](q);Z['set'](U,e);}return[...Z]['map'](([x,n])=>({'resource':x,'actions':[...n]}));}export async function setAccess(S,Z){const j=N,h=await Z['pg']['connect']();try{await h['query'](j(0x101));if(S['type']==='user'){await h['query'](j(0x102),[S['id']]);if(S['roles']!==undefined){await h['query']('DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1',[S['id']]);for(const D of S['roles']){await h['query']('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)',[S['id'],D,S[j(0x103)]['id'],S['user']['id']]);}}}else await h['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[S['id']]);const U=S[j(0x104)]?permissionsToAccess(S[j(0x104)]):S['access']??[];for(const u of U){S['type']==='user'?await h['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)',[u[j(0x105)],u[j(0x106)],S['id'],S['user']['id'],S['user']['id']]):await h['query'](j(0x107),[u[j(0x105)],u['actions'],S['id'],S['user']['id'],S['user']['id']]);}await h['query']('COMMIT');}catch(e){await h['query'](j(0x108));throw e;}finally{h['release']();}return getAccess(S,Z);}
@@ -1 +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);}
1
+ import{ValidationError}from'../../../errors.js';function c(S,Z){S=S-0xb2;const h=O();let U=h[S];return U;}import{getResourceAccess}from'./get-resource-access.js';function O(){const o=['users','roles','At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided','Duplicate\x20user\x20in\x20access\x20list:\x20','role_id','query','resource','length','uid','user','COMMIT'];O=function(){return o;};return O();}export async function setResourceAccess(S,Z){const N=c;if(S[N(0xb2)]===undefined&&S[N(0xb3)]===undefined)throw new ValidationError(N(0xb4));const h=new Set();for(const u of S['users']??[]){if(h['has'](u['uid']))throw new ValidationError(N(0xb5)+u['uid']);h['add'](u['uid']);}const U=new Set();for(const e of S['roles']??[]){if(U['has'](e[N(0xb6)]))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+e[N(0xb6)]);U['add'](e['role_id']);}const D=await Z['pg']['connect']();try{await D[N(0xb7)]('BEGIN');if(S['users']!==undefined){await D['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[S[N(0xb8)]]);for(const q of S['users']){if(q['actions'][N(0xb9)]===0x0)continue;await D[N(0xb7)]('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)',[S[N(0xb8)],q['actions'],q[N(0xba)],S[N(0xbb)]['id']]);}}if(S['roles']!==undefined){await D[N(0xb7)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[S[N(0xb8)]]);for(const x of S['roles']){if(x['actions'][N(0xb9)]===0x0)continue;await D[N(0xb7)]('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)',[S['resource'],x['actions'],x['role_id'],S['user']['id']]);}}await D[N(0xb7)](N(0xbc));}catch(n){await D['query']('ROLLBACK');throw n;}finally{D['release']();}return getResourceAccess({'resource':S['resource']},Z);}
@@ -1 +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
+ function O(){const q=['user_id','Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id','keys','scopes','At\x20least\x20one\x20scope\x20must\x20be\x20provided','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','entries','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)','user','release'];O=function(){return q;};return O();}import{ValidationError}from'../../../errors.js';import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';import{getResourceScopes}from'./get-resource-scopes.js';function c(S,Z){S=S-0x18e;const h=O();let U=h[S];return U;}export async function setResourceScopes(S,Z){const e=c;if(Boolean(S[e(0x18e)])===Boolean(S['role_id']))throw new ValidationError(e(0x18f));if(Object[e(0x190)](S[e(0x191)])['length']===0x0)throw new ValidationError(e(0x192));const h=await Z['pg']['connect']();try{await h[e(0x193)]('BEGIN'),await h[e(0x193)](e(0x194),[S['resource'],S['role_id']??null,S['user_id']??null]);for(const [U,D]of Object[e(0x195)](S['scopes'])){await h['query'](e(0x196),[S['resource'],S['role_id']??null,S['user_id']??null,U,JSON['stringify'](D),S[e(0x197)]['id']]);}await h['query']('COMMIT');}catch(u){await h['query']('ROLLBACK');throw u;}finally{h[e(0x198)]();}return clearResourceScopeCache(),getResourceScopes({'resource':S['resource']},Z);}
@@ -1 +1 @@
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
+ function c(S,Z){S=S-0x1df;var h=O();var U=h[S];return U;}function O(){var U=['put','items'];O=function(){return U;};return O();}export async function updateDictionary(S,Z){var h=c;return await Z['dictionary'][h(0x1df)](S['name'],S[h(0x1e0)]),{'success':!![]};}
@@ -1 +1 @@
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
+ function c(S,Z){S=S-0x8a;const h=O();let U=h[S];return U;}import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(S,Z){const D=c;if(!Object['keys'](S['patch'])['length'])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [h,U]of Object[D(0x8a)](S['patch'])){if(!h[D(0x8b)]()||h[D(0x8c)]('..'))throw new ValidationError(D(0x8d)+h);await Z['pg'][D(0x8e)]('\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',[h,JSON[D(0x8f)](U),S['user']['id']]);}return{'success':!![]};}function O(){const u=['entries','trim','includes','Invalid\x20setting\x20key:\x20','query','stringify'];O=function(){return u;};return O();}
@@ -1 +1 @@
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
+ import{ForbiddenError}from'../../errors.js';function O(){var U=['type','includes','Missing\x20permission:\x20'];O=function(){return U;};return O();}function c(S,Z){S=S-0xc6;var h=O();var U=h[S];return U;}export function requireAdmin(S,Z){var h=c;if(!S)throw new ForbiddenError('User\x20required');if(S['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(S[h(0xc6)]!=='admin'&&Z&&!S['permissions']?.[h(0xc7)](Z))throw new ForbiddenError(h(0xc8)+Z);}
@@ -1 +1 @@
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
+ function c(S,Z){S=S-0x19c;const h=O();let U=h[S];return U;}function O(){const u=['salt','some','includes'];O=function(){return u;};return O();}export const safeUser=S=>{const D=c,Z=['password',D(0x19c),'secret','credentials'];return Object['fromEntries'](Object['entries'](S)['filter'](([h])=>!Z[D(0x19d)](U=>h['toLowerCase']()[D(0x19e)](U))));};
@@ -1 +1 @@
1
- import{UnsupportedError}from'../../errors.js';export function unsupported(p){throw new UnsupportedError(p+'\x20requires\x20a\x20project/provider\x20implementation');}
1
+ import{UnsupportedError}from'../../errors.js';export function unsupported(S){throw new UnsupportedError(S+'\x20requires\x20a\x20project/provider\x20implementation');}
@@ -1 +1 @@
1
- import{writeAudit}from'./services/write-audit.js';export function createAudit(p){const Z=writeAudit(p);return{'write':Z};}
1
+ import{writeAudit}from'./services/write-audit.js';export function createAudit(S){const Z=writeAudit(S);return{'write':Z};}
@@ -1 +1 @@
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
+ function c(S,Z){S=S-0x131;const h=O();let U=h[S];return U;}const secretPattern=/password|token|secret|credential|salt/i;function clean(S){const n=c;if(Array['isArray'](S))return S[n(0x131)](clean);if(S&&typeof S==='object')return Object['fromEntries'](Object['entries'](S)[n(0x131)](([Z,h])=>[Z,secretPattern['test'](Z)?n(0x132):clean(h)]));return S;}function O(){const i=['map','[REDACTED]','query','then','audit_log_data','admin.audit_log','admin.audit_log_data','warn','Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled','info','changes','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20','userId','module','resource','action','requestId','rows','\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','stringify'];O=function(){return i;};return O();}export function writeAudit(S){let Z,h;async function U(){const N=c;if(!S['pg'])return![];if(Z!==undefined)return Z;return h??=S['pg'][N(0x133)]('\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')[N(0x134)](D=>{const o=N,u=new Set(D['rows']['map'](e=>e['table_name']));return Z=u['has']('audit_log')&&u['has'](o(0x135)),!Z&&S['logger']['warn']({'expectedTables':[o(0x136),o(0x137)],'foundTables':[...u]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),Z;})['catch'](D=>{const j=N;return Z=![],S['logger'][j(0x138)]({'err':D},j(0x139)),![];}),h;}return async function D(u){const X=c;if(!await U())return S['logger'][X(0x13a)]({'auditFallback':!![],'event':clean({...u,'changes':u[X(0x13b)]?.['map'](x=>({...x,'oldValue':clean(x['oldValue']),'newValue':clean(x['newValue'])}))})},'audit'),0x0;if(!S['pg'])throw new Error('empty\x20pg');const e=await S['pg']['query'](X(0x13c),[u[X(0x13d)]??null,u[X(0x13e)],u[X(0x13f)],u['resourceId']==null?null:String(u['resourceId']),u['fields']??null,u[X(0x140)],u[X(0x141)]??null,u['ipAddress']??null,clean(u['metadata']??{})]),q=e[X(0x142)][0x0]['id'];for(const x of u['changes']??[]){if(secretPattern['test'](x['field']))continue;await S['pg'][X(0x133)](X(0x143),[q,x['field'],JSON['stringify'](clean(x['oldValue'])),JSON[X(0x144)](clean(x['newValue']))]);}return q;};}
@@ -1 +1 @@
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
+ export async function getUserPermissions(S,Z){const D=c,h=await Z['pg']['query'](D(0x161),[S]);return h[D(0x162)]['map'](U=>U['permission']);}function c(S,Z){S=S-0x161;const h=O();let U=h[S];return U;}function O(){const u=['\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','rows'];O=function(){return u;};return O();}
@@ -1 +1 @@
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
+ function O(){const E=['path','get','fileFor','destroy','code','toString','split','from','register','storagePath','auth','cookieName','cookieOptions','registerUserDeserializer'];O=function(){return E;};return O();}function c(S,Z){S=S-0x185;const h=O();let U=h[S];return U;}const X=c;export*from'./auth.types.js';import{randomBytes,scrypt as S,timingSafeEqual}from'node:crypto';import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';import{join,resolve}from'node:path';import{promisify}from'node:util';const scrypt=promisify(S);import Z from'@fastify/cookie';import h from'@fastify/session';import{Authenticator}from'@fastify/passport';import U from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();class FileSessionStore{['path'];constructor(D){const j=c;this['path']=D,void mkdir(this[j(0x185)],{'recursive':!![]});}['fileFor'](D){return join(this['path'],D+'.json');}async[X(0x186)](D,u){try{const e=await readFile(this['fileFor'](D),'utf8');u(null,JSON['parse'](e));}catch(q){const x=q;if(x['code']==='ENOENT'){u(null,undefined);return;}u(x,undefined);}}async['set'](D,u,e){const i=X;try{await mkdir(this['path'],{'recursive':!![]}),await writeFile(this[i(0x187)](D),JSON['stringify'](u),'utf8'),e();}catch(q){e(q);}}async[X(0x188)](D,u){try{await unlink(this['fileFor'](D))['catch'](e=>{const l=c;if(e[l(0x189)]!=='ENOENT')throw e;}),u();}catch(e){u(e);}}}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(D){const b=X,u=randomBytes(0x10),e=await scrypt(D,u,0x40);return'scrypt$'+u[b(0x18a)]('hex')+'$'+e['toString']('hex');}export async function verifyPassword(D,u){const Y=X,[e,q,x]=u?.[Y(0x18b)]('$')||[];if(e!=='scrypt'||!q||!x)return![];const n=Buffer[Y(0x18c)](q,'hex'),N=Buffer[Y(0x18c)](x,'hex'),o=await scrypt(D,n,N['length']);return timingSafeEqual(o,N);}export async function createSessionStore(D,u){const r=X,{config:e,redis:q}=u;if(!e){console['warn']('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await D[r(0x18d)](Z,{'parseOptions':e['auth']['cookieOptions']});const x=e['redis']['host']?new U({'prefix':e['auth']['cookieName']+':'+(e['pg']?.['database']||'db')+':','client':q}):new FileSessionStore(resolve(e[r(0x18e)]??'./storage','sessions'));await D['register'](h,{'secret':e[r(0x18f)]['secret'],'cookieName':e[r(0x18f)][r(0x190)],'cookie':e['auth'][r(0x191)],'store':x}),await D['register'](fastifyPassport['initialize']()),await D['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async n=>({'user':n})),fastifyPassport[r(0x192)](async n=>{const N=n?.['user']||n;return N?.['id']&&(N['permissions']=await getUserPermissions(N['id'],u)),N;});}
@@ -1 +1 @@
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
+ import{BadRequestError}from'../../errors.js';function O(){const o=['rows','user\x20not\x20found','info','query'];O=function(){return o;};return O();}function c(S,Z){S=S-0x10e;const h=O();let U=h[S];return U;}import{verifyPassword}from'./index.js';export async function verifyUser({user:S,password:Z,ip:h},{pg:U,logger:D}){const N=c;if(!S||S==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!Z||Z==='')throw new BadRequestError('not\x20enough\x20params:\x20password');D['metrics']('user.login');const u='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',e=await U['query'](u,[S])['then'](x=>x[N(0x10e)]?.[0x0]);if(!e){const x=N(0x10f);D[N(0x110)]({'file':'auth/warn','error':x,'user':S,'ip':h});throw new BadRequestError(x);}const q=await verifyPassword(Z,e['password_hash']);if(!q){const n='Wrong\x20password';D['info']({'file':'auth/warn','error':n,'user':S,'ip':h});throw new BadRequestError(n);}return U[N(0x111)]('update\x20admin.users\x20set\x20last_activity_date\x20=\x20now()\x20where\x20uid\x20=\x20$1',[e['id']]),delete e['password_hash'],e;}