UNPKG

aki-angular-secure-config

Version:

The `aki-angular-secure-config` is a new npm package developed to address a security vulnerability in Angular applications. This package ensures that sensitive configuration data in `config.json` is protected from being inspected or extracted via browser

1 lines 13.7 kB
function _0x180b(_0x191761,_0x4f400b){const _0x3c84e6=_0x3c84();return _0x180b=function(_0x180b4b,_0x1f023e){_0x180b4b=_0x180b4b-0x1bb;let _0xad1364=_0x3c84e6[_0x180b4b];return _0xad1364;},_0x180b(_0x191761,_0x4f400b);}const _0xccc40a=_0x180b;(function(_0x1b96f5,_0x17d94b){const _0x10e420=_0x180b,_0x5de949=_0x1b96f5();while(!![]){try{const _0x336d3a=parseInt(_0x10e420(0x1e3))/0x1*(-parseInt(_0x10e420(0x1ea))/0x2)+parseInt(_0x10e420(0x1dd))/0x3+parseInt(_0x10e420(0x1da))/0x4+-parseInt(_0x10e420(0x1db))/0x5+-parseInt(_0x10e420(0x209))/0x6+-parseInt(_0x10e420(0x203))/0x7+parseInt(_0x10e420(0x1e9))/0x8;if(_0x336d3a===_0x17d94b)break;else _0x5de949['push'](_0x5de949['shift']());}catch(_0x12994f){_0x5de949['push'](_0x5de949['shift']());}}}(_0x3c84,0xddd27));import _0x31faa2 from'fs';import _0x5b6a89 from'path';function _0x3c84(){const _0x1e5c9c=['nginx.conf','env.js\x20configuration\x20already\x20exists\x20in\x20angular.json.','outputPath','Error:\x20angular.json\x20not\x20found.','mkdirSync','aki-angular-secure-config','main.ts','utf8','Welcome\x20to\x20Thiqah\x20Angular\x20Secure\x20Config\x20...','join','rm\x20-f\x20package-lock.json\x20&&\x20yarn\x20install\x20&&\x20yarn\x20add\x20aki-resources\x20&&\x20yarn\x20add\x20crypto-js\x20&&\x20yarn\x20add\x20--dev\x20javascript-obfuscator','writeFileSync','url','--npmrc-pat','const\x20buildDir\x20=\x20path.join(__dirname,\x20\x27','scripts','build','encrypt-config.js','5397994RaeqKi','vendorChunk','package.json','.npmrc','Error\x20installing\x20dependencies:\x20','fail','909054TvxcWd','\x20\x20<script\x20src=\x22env.js\x22></script>\x0a','dist','stringify','npm\x20root\x20-g','.dockerignore','rm\x20-f\x20yarn.lock\x20&&\x20npm\x20install\x20&&\x20npm\x20install\x20aki-resources\x20&&\x20npm\x20install\x20crypto-js\x20&&\x20npm\x20install\x20--save-dev\x20javascript-obfuscator','prestart','replace','resources','shared','parse','COPY\x20--from=build\x20/app/','architect','Error:\x20</head>\x20tag\x20not\x20found\x20in\x20src/index.html.','some','options','\x20/usr/share/nginx/html','--config-file-name','entries','info','trim','npmrc-template','push','configurations','namedChunks','app-config.ts','existsSync','message','All\x20files\x20downloaded\x20successfully.','Error:\x20','includes','production','location\x20~*\x20/','--include-dockerfile','readFileSync','slice','obfuscate.js','env.js','cwd','succeed','Added\x20prestart\x20script\x20to\x20package.json.','Dockerfile','\x27);','COPY\x20--from=build\x20/app/dist\x20/usr/share/nginx/html','\x20has\x20been\x20downloaded.','argv','config.json','buildOptimizer','extractLicenses','all','prestart\x20script\x20already\x20exists\x20in\x20package.json.','outputHashing','dirname','2066716VyuFyE','7102375TeikYr','--use-yarn','4468608hGrkCn','configuration','projects','src','indexOf','Added\x20env.js\x20configuration\x20to\x20build.assests\x20at\x20angular.json','3075NJXMeH','angular.json','encrypt-config.js\x20not\x20found.','Error:\x20src/index.html\x20not\x20found.','Initializing\x20...','toString','15941752jfDolO','486mxZEoO','values','sourceMap','assets','Failed\x20to\x20download\x20','start','Error:\x20package.json\x20not\x20found.'];_0x3c84=function(){return _0x1e5c9c;};return _0x3c84();}import{exec,execSync}from'child_process';import{fileURLToPath}from'url';import _0x16dfd1 from'ora';const __filename=fileURLToPath(import.meta[_0xccc40a(0x1fd)]),__dirname=_0x5b6a89[_0xccc40a(0x1d9)](__filename),filesToDownloadWithoutDocker=[_0xccc40a(0x1f7),'app-config.ts',_0xccc40a(0x21f),_0xccc40a(0x202),_0xccc40a(0x1c9)],filesToDownloadDocker=[...filesToDownloadWithoutDocker,'entrypoint.sh',_0xccc40a(0x1ce),_0xccc40a(0x20e),_0xccc40a(0x1f1)],downloadFile=async(_0x1aa971,_0x16bbc2)=>{const _0x2d89d9=_0xccc40a,_0xe1b72f=execSync(_0x2d89d9(0x20d))[_0x2d89d9(0x1e8)]()[_0x2d89d9(0x21e)](),_0x3e3666=_0x5b6a89[_0x2d89d9(0x1fa)](_0xe1b72f,_0x2d89d9(0x1f6),_0x2d89d9(0x20b),_0x2d89d9(0x212),_0x1aa971);let _0x2b1ce6=_0x5b6a89[_0x2d89d9(0x1fa)](process[_0x2d89d9(0x1cb)](),_0x1aa971);if(_0x1aa971===_0x2d89d9(0x1f7))_0x2b1ce6=_0x5b6a89[_0x2d89d9(0x1fa)](process['cwd'](),_0x2d89d9(0x1e0),_0x1aa971);_0x1aa971===_0x2d89d9(0x1be)&&(_0x2b1ce6=_0x5b6a89[_0x2d89d9(0x1fa)](process[_0x2d89d9(0x1cb)](),_0x2d89d9(0x1e0),_0x2d89d9(0x213),'models',_0x1aa971),_0x31faa2[_0x2d89d9(0x1f5)](_0x5b6a89[_0x2d89d9(0x1d9)](_0x2b1ce6),{'recursive':!![]}));_0x1aa971===_0x2d89d9(0x21f)&&(_0x2b1ce6=_0x5b6a89['join'](process[_0x2d89d9(0x1cb)](),_0x2d89d9(0x206)));try{_0x31faa2['copyFileSync'](_0x3e3666,_0x2b1ce6),_0x16bbc2[_0x2d89d9(0x1cc)]((_0x1aa971===_0x2d89d9(0x21f)?_0x2d89d9(0x206):_0x1aa971)+_0x2d89d9(0x1d1));if(_0x1aa971==='npmrc-template'||_0x1aa971===_0x2d89d9(0x1ce)||_0x1aa971==='obfuscate.js'){const _0x522bd1=getOutputPathFromAngularJson();if(_0x522bd1){if(_0x1aa971===_0x2d89d9(0x21f))updateNpmrc(_0x2b1ce6,_0x16bbc2);if(_0x1aa971===_0x2d89d9(0x1ce))updateDockerFile(_0x2b1ce6,_0x522bd1,_0x16bbc2);if(_0x1aa971===_0x2d89d9(0x1c9))updateObfuscateFile(_0x2b1ce6,_0x522bd1,_0x16bbc2);}}}catch(_0x41e5ff){_0x16bbc2[_0x2d89d9(0x208)](_0x2d89d9(0x1ee)+_0x3e3666+':\x20'+_0x41e5ff[_0x2d89d9(0x1c0)]);throw new Error(_0x2d89d9(0x1ee)+_0x3e3666+':\x20'+_0x41e5ff['message']);}},updateNpmrc=(_0x560db1,_0x351752)=>{const _0x356059=_0xccc40a,_0x4d8fbd=process[_0x356059(0x1d2)]['indexOf']('--npmrc-pat'),_0x2da328=_0x4d8fbd!==-0x1&&process[_0x356059(0x1d2)][_0x4d8fbd+0x1]?process[_0x356059(0x1d2)][_0x4d8fbd+0x1]:null,_0x5d9aae=process[_0x356059(0x1d2)][_0x356059(0x1c3)](_0x356059(0x1dc)),_0x6ebc09=_0x5d9aae?'https://registry.yarnpkg.com/':'https://registry.npmjs.org/';let _0x467601=_0x31faa2[_0x356059(0x1c7)](_0x560db1,_0x356059(0x1f8));_0x467601=_0x467601['replace'](/NPMRC_PAT/g,_0x2da328),_0x467601=_0x467601[_0x356059(0x211)](/NPM_YARN_REGISTRY_URL/g,_0x6ebc09),_0x31faa2[_0x356059(0x1fc)](_0x560db1,_0x467601,_0x356059(0x1f8)),_0x351752[_0x356059(0x1cc)]('.npmrc\x20and\x20dockerfile\x20have\x20been\x20updated\x20with\x20PAT');},installDependencies=async(_0x4db0bb,_0x528cb2)=>{const _0x40a2d6=_0xccc40a,_0x846e90=_0x4db0bb?_0x40a2d6(0x1fb):_0x40a2d6(0x20f);return new Promise((_0x2269ab,_0xe74ec6)=>{exec(_0x846e90,(_0x5c23c8,_0x1db8a9,_0x2d3730)=>{const _0xd3526e=_0x180b;if(_0x5c23c8)return _0x528cb2[_0xd3526e(0x208)](_0xd3526e(0x207)+_0x5c23c8[_0xd3526e(0x1c0)]),_0xe74ec6(_0x5c23c8);_0x528cb2[_0xd3526e(0x1cc)]('Dependencies\x20installed\x20successfully.'),_0x2269ab();});});},updateIndexHtml=_0x545e3e=>{const _0x359ecf=_0xccc40a,_0x30150a=_0x5b6a89[_0x359ecf(0x1fa)](process[_0x359ecf(0x1cb)](),_0x359ecf(0x1e0),'index.html'),_0x12784b=_0x359ecf(0x20a);if(_0x31faa2['existsSync'](_0x30150a)){let _0x48f9fe=_0x31faa2[_0x359ecf(0x1c7)](_0x30150a,_0x359ecf(0x1f8));if(!_0x48f9fe[_0x359ecf(0x1c3)](_0x12784b)){const _0xb125e9=_0x48f9fe['indexOf']('</head>');_0xb125e9!==-0x1?(_0x48f9fe=_0x48f9fe[_0x359ecf(0x1c8)](0x0,_0xb125e9)+_0x12784b+_0x48f9fe[_0x359ecf(0x1c8)](_0xb125e9),_0x31faa2[_0x359ecf(0x1fc)](_0x30150a,_0x48f9fe,_0x359ecf(0x1f8)),_0x545e3e[_0x359ecf(0x1cc)]('Added\x20env.js\x20script\x20tag\x20at\x20src/index.html.'),updateAngularJson(_0x545e3e)):_0x545e3e['fail'](_0x359ecf(0x217));}else _0x545e3e[_0x359ecf(0x21d)]('src/index.html\x20already\x20contains\x20env.js\x20script\x20tag.');}else _0x545e3e[_0x359ecf(0x208)](_0x359ecf(0x1e6));},updateAngularJson=_0xbb47a2=>{const _0xbb982f=_0xccc40a,_0x488824=_0x5b6a89[_0xbb982f(0x1fa)](process['cwd'](),_0xbb982f(0x1e4));if(_0x31faa2[_0xbb982f(0x1bf)](_0x488824)){let _0x1e7919=JSON['parse'](_0x31faa2[_0xbb982f(0x1c7)](_0x488824,'utf8'));for(const _0x32699d of Object[_0xbb982f(0x1eb)](_0x1e7919[_0xbb982f(0x1df)])){for(const [_0x82f3d3,_0xef611a]of Object[_0xbb982f(0x21c)](_0x32699d[_0xbb982f(0x216)])){if(_0x82f3d3===_0xbb982f(0x201)&&_0xef611a[_0xbb982f(0x1bc)]&&_0xef611a[_0xbb982f(0x1bc)][_0xbb982f(0x1c4)]){const _0x2d8adc=_0xef611a[_0xbb982f(0x1bc)][_0xbb982f(0x1c4)];_0x2d8adc[_0xbb982f(0x1d4)]=!![],_0x2d8adc['optimization']=!![],_0x2d8adc[_0xbb982f(0x204)]=![],_0x2d8adc[_0xbb982f(0x1d5)]=!![],_0x2d8adc[_0xbb982f(0x1ec)]=![],_0x2d8adc[_0xbb982f(0x1bd)]=![];if(!_0x2d8adc['outputHashing'])_0x2d8adc[_0xbb982f(0x1d8)]=_0xbb982f(0x1d6);_0xbb47a2['succeed']('Added\x20build\x20optimization\x20to\x20configurations.production\x20at\x20angular.json.');}if(_0x82f3d3===_0xbb982f(0x201)&&_0xef611a[_0xbb982f(0x219)]&&Array['isArray'](_0xef611a[_0xbb982f(0x219)][_0xbb982f(0x1ed)])){const _0x4467f8={'glob':'env.js','input':'src/assets','output':'/'},_0x282e80=_0xef611a[_0xbb982f(0x219)]['assets'][_0xbb982f(0x218)](_0x739713=>_0x739713['glob']===_0xbb982f(0x1ca));!_0x282e80?(_0xef611a[_0xbb982f(0x219)][_0xbb982f(0x1ed)][_0xbb982f(0x1bb)](_0x4467f8),_0xbb47a2[_0xbb982f(0x1cc)](_0xbb982f(0x1e2))):_0xbb47a2['info'](_0xbb982f(0x1f2));}}}_0x31faa2[_0xbb982f(0x1fc)](_0x488824,JSON[_0xbb982f(0x20c)](_0x1e7919,null,0x2),_0xbb982f(0x1f8));}else _0xbb47a2[_0xbb982f(0x208)](_0xbb982f(0x1f4));},updatePackageJson=_0x127034=>{const _0x1e5c37=_0xccc40a,_0x400689=_0x5b6a89['join'](process[_0x1e5c37(0x1cb)](),_0x1e5c37(0x205));if(_0x31faa2['existsSync'](_0x400689)){let _0x366c2c=JSON[_0x1e5c37(0x214)](_0x31faa2[_0x1e5c37(0x1c7)](_0x400689,_0x1e5c37(0x1f8)));!_0x366c2c[_0x1e5c37(0x200)]&&(_0x366c2c[_0x1e5c37(0x200)]={}),!_0x366c2c[_0x1e5c37(0x200)][_0x1e5c37(0x210)]?(_0x366c2c[_0x1e5c37(0x200)]['prestart']='node\x20encrypt-config.js',_0x127034[_0x1e5c37(0x1cc)](_0x1e5c37(0x1cd))):_0x127034['info'](_0x1e5c37(0x1d7)),_0x31faa2[_0x1e5c37(0x1fc)](_0x400689,JSON[_0x1e5c37(0x20c)](_0x366c2c,null,0x2),_0x1e5c37(0x1f8));}else _0x127034[_0x1e5c37(0x208)](_0x1e5c37(0x1f0));},getOutputPathFromAngularJson=()=>{const _0x449bcb=_0xccc40a,_0x4a5546=_0x5b6a89[_0x449bcb(0x1fa)](process[_0x449bcb(0x1cb)](),'angular.json');if(_0x31faa2[_0x449bcb(0x1bf)](_0x4a5546)){let _0x1f3d10=JSON[_0x449bcb(0x214)](_0x31faa2['readFileSync'](_0x4a5546,'utf8'));for(const _0xf2e8c9 of Object[_0x449bcb(0x1eb)](_0x1f3d10['projects'])){if(_0xf2e8c9[_0x449bcb(0x216)]&&_0xf2e8c9[_0x449bcb(0x216)][_0x449bcb(0x201)]&&_0xf2e8c9['architect'][_0x449bcb(0x201)]['options']&&_0xf2e8c9[_0x449bcb(0x216)]['build']['options'][_0x449bcb(0x1f3)])return _0xf2e8c9[_0x449bcb(0x216)]['build'][_0x449bcb(0x219)]['outputPath'];}}else console['error']('Error:\x20angular.json\x20not\x20found.');return null;},updateObfuscateFile=(_0x355ebb,_0x364df9,_0x429af9)=>{const _0x61bff0=_0xccc40a,_0x37bc11=_0x31faa2[_0x61bff0(0x1c7)](_0x355ebb,'utf8'),_0x45a096=_0x37bc11[_0x61bff0(0x211)](/const buildDir = path\.join\(__dirname, 'dist'\);/,_0x61bff0(0x1ff)+_0x364df9+_0x61bff0(0x1cf));_0x31faa2[_0x61bff0(0x1fc)](_0x355ebb,_0x45a096,_0x61bff0(0x1f8));},updateDockerFile=(_0x32d95b,_0xbc20aa,_0x6a2e99)=>{const _0x361764=_0xccc40a,_0x9f5d43=process[_0x361764(0x1d2)][_0x361764(0x1e1)](_0x361764(0x1fe)),_0xa2b329=_0x9f5d43!==-0x1&&process[_0x361764(0x1d2)][_0x9f5d43+0x1]?process[_0x361764(0x1d2)][_0x9f5d43+0x1]:null,_0x4f3a71=_0x31faa2[_0x361764(0x1c7)](_0x32d95b,_0x361764(0x1f8)),_0x154cd6=_0x4f3a71['replace'](/NPMRC_PAT/g,_0xa2b329)['replace'](_0x361764(0x1d0),_0x361764(0x215)+_0xbc20aa+_0x361764(0x21a));_0x31faa2[_0x361764(0x1fc)](_0x32d95b,_0x154cd6,_0x361764(0x1f8));},createConfigJson=(_0x400422,_0x1634a6)=>{const _0x22defd=_0xccc40a,_0x13f248=_0x5b6a89[_0x22defd(0x1fa)](process[_0x22defd(0x1cb)](),'src',_0x22defd(0x1ed),_0x22defd(0x1de)),_0x1c3566=_0x5b6a89['join'](_0x13f248,_0x400422);!_0x31faa2[_0x22defd(0x1bf)](_0x13f248)&&_0x31faa2[_0x22defd(0x1f5)](_0x13f248,{'recursive':!![]});const _0x579685={'production':![]};_0x31faa2[_0x22defd(0x1fc)](_0x1c3566,JSON[_0x22defd(0x20c)](_0x579685,null,0x2),_0x22defd(0x1f8)),_0x1634a6[_0x22defd(0x1cc)]('Created\x20../assets/configuration/'+_0x400422+'.');},updateNginxConf=(_0x4691e0,_0x460fc7)=>{const _0x8e72e=_0xccc40a,_0x20084f=_0x5b6a89[_0x8e72e(0x1fa)](process['cwd'](),'nginx.conf');if(_0x31faa2[_0x8e72e(0x1bf)](_0x20084f)){let _0x4168ee=_0x31faa2[_0x8e72e(0x1c7)](_0x20084f,_0x8e72e(0x1f8));_0x4168ee=_0x4168ee['replace'](/location ~\* \/config\.json/,_0x8e72e(0x1c5)+_0x4691e0),_0x31faa2[_0x8e72e(0x1fc)](_0x20084f,_0x4168ee,_0x8e72e(0x1f8));}},updateEncryptConfigJs=(_0x3adb85,_0x33bb24)=>{const _0x16374e=_0xccc40a,_0x3648bc=_0x5b6a89[_0x16374e(0x1fa)](process[_0x16374e(0x1cb)](),'encrypt-config.js');if(_0x31faa2[_0x16374e(0x1bf)](_0x3648bc)){let _0x2df911=_0x31faa2['readFileSync'](_0x3648bc,_0x16374e(0x1f8));_0x2df911=_0x2df911[_0x16374e(0x211)](/const configFileName = 'config\.json';/,'const\x20configFileName\x20=\x20\x27'+_0x3adb85+'\x27;'),_0x31faa2['writeFileSync'](_0x3648bc,_0x2df911,_0x16374e(0x1f8));}else _0x33bb24['fail'](_0x16374e(0x1e5));};((async()=>{const _0x5753ff=_0xccc40a,_0x2c4a80=_0x16dfd1(_0x5753ff(0x1f9))[_0x5753ff(0x1ef)]();_0x2c4a80[_0x5753ff(0x1ef)](_0x5753ff(0x1e7));try{const _0xb3c391=process[_0x5753ff(0x1d2)][_0x5753ff(0x1c3)]('--use-yarn'),_0x119aea=process[_0x5753ff(0x1d2)][_0x5753ff(0x1c3)](_0x5753ff(0x1c6));let _0x133b47=_0x5753ff(0x1d3);const _0xe6407=process[_0x5753ff(0x1d2)]['indexOf'](_0x5753ff(0x21b));_0xe6407!==-0x1&&process[_0x5753ff(0x1d2)][_0xe6407+0x1]&&(_0x133b47=process[_0x5753ff(0x1d2)][_0xe6407+0x1]);const _0x1e10ae=_0x119aea?filesToDownloadDocker:filesToDownloadWithoutDocker;for(const _0x5fc6d2 of _0x1e10ae){await downloadFile(_0x5fc6d2,_0x2c4a80);}_0x2c4a80[_0x5753ff(0x1cc)](_0x5753ff(0x1c1)),await installDependencies(_0xb3c391,_0x2c4a80),updatePackageJson(_0x2c4a80),updateIndexHtml(_0x2c4a80),createConfigJson(_0x133b47,_0x2c4a80),updateNginxConf(_0x133b47,_0x2c4a80),updateEncryptConfigJs(_0x133b47,_0x2c4a80),_0x2c4a80[_0x5753ff(0x1cc)]('All\x20tasks\x20completed\x20successfully.');}catch(_0x1ce3a0){_0x2c4a80[_0x5753ff(0x208)](_0x5753ff(0x1c2)+_0x1ce3a0[_0x5753ff(0x1c0)]);}})());