cliodot 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +81 -0
- package/dist/AuthAppClient.d.ts +1 -0
- package/dist/AuthAppClient.d.ts.map +1 -1
- package/dist/AuthAppClient.js +199 -1
- package/dist/CommercialAppClient.d.ts +178 -0
- package/dist/CommercialAppClient.d.ts.map +1 -0
- package/dist/CommercialAppClient.js +576 -0
- package/dist/ConnectorBuilder.js +104 -1
- package/dist/Events.d.ts +2 -0
- package/dist/Events.d.ts.map +1 -1
- package/dist/Events.js +325 -1
- package/dist/Flosync.js +296 -1
- package/dist/FlosyncClient.js +429 -1
- package/dist/FunctionBuilder.js +65 -1
- package/dist/IdentityAppClient.d.ts +23 -0
- package/dist/IdentityAppClient.d.ts.map +1 -0
- package/dist/IdentityAppClient.js +197 -0
- package/dist/MemoryAppClient.d.ts +28 -0
- package/dist/MemoryAppClient.d.ts.map +1 -0
- package/dist/MemoryAppClient.js +149 -0
- package/dist/MemoryClient.d.ts +8 -0
- package/dist/MemoryClient.d.ts.map +1 -0
- package/dist/MemoryClient.js +20 -0
- package/dist/OAuthAppClient.d.ts +1 -0
- package/dist/OAuthAppClient.d.ts.map +1 -1
- package/dist/OAuthAppClient.js +269 -1
- package/dist/ProviderServicesClient.d.ts +24 -0
- package/dist/ProviderServicesClient.d.ts.map +1 -0
- package/dist/ProviderServicesClient.js +158 -0
- package/dist/Surface.d.ts +2 -0
- package/dist/Surface.d.ts.map +1 -1
- package/dist/Surface.js +255 -1
- package/dist/ValidatorBuilder.js +24 -1
- package/dist/Webhooks.d.ts +20 -0
- package/dist/Webhooks.d.ts.map +1 -0
- package/dist/Webhooks.js +61 -0
- package/dist/WorkflowBuilder.js +279 -1
- package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
- package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/CommercialAppClient.test.js +217 -0
- package/dist/__tests__/Events.test.js +191 -1
- package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
- package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
- package/dist/__tests__/IdentityAppClient.test.js +232 -0
- package/dist/__tests__/OAuthAppClient.test.js +300 -1
- package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
- package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
- package/dist/__tests__/ProviderServicesClient.test.js +131 -0
- package/dist/__tests__/Surface.test.js +150 -1
- package/dist/__tests__/errors.test.js +54 -1
- package/dist/__tests__/function.test.js +58 -1
- package/dist/__tests__/helpers.d.ts +5 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/__tests__/helpers.js +10 -0
- package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
- package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
- package/dist/__tests__/localhost-lookup.test.js +26 -0
- package/dist/__tests__/parse-api-error.test.js +26 -1
- package/dist/__tests__/runner.test.js +156 -1
- package/dist/connectors/builtin.js +354 -1
- package/dist/connectors/registry.js +300 -1
- package/dist/decorators/build.js +105 -1
- package/dist/decorators/connector.js +56 -1
- package/dist/decorators/index.js +34 -1
- package/dist/decorators/metadata.js +338 -1
- package/dist/decorators/steps.js +220 -1
- package/dist/decorators/workflow.js +52 -1
- package/dist/errors.js +76 -1
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
- package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
- package/dist/http/__tests__/cliodot-result.test.js +57 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
- package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
- package/dist/http/__tests__/events-instance-id.test.js +45 -0
- package/dist/http/cliodot-request.d.ts +35 -0
- package/dist/http/cliodot-request.d.ts.map +1 -0
- package/dist/http/cliodot-request.js +105 -0
- package/dist/http/cliodot-result.d.ts +40 -0
- package/dist/http/cliodot-result.d.ts.map +1 -0
- package/dist/http/cliodot-result.js +139 -0
- package/dist/http/create-client.d.ts +3 -0
- package/dist/http/create-client.d.ts.map +1 -0
- package/dist/http/create-client.js +14 -0
- package/dist/http/events-instance-id.d.ts +11 -0
- package/dist/http/events-instance-id.d.ts.map +1 -0
- package/dist/http/events-instance-id.js +86 -0
- package/dist/http/localhost-lookup.d.ts +12 -0
- package/dist/http/localhost-lookup.d.ts.map +1 -0
- package/dist/http/localhost-lookup.js +67 -0
- package/dist/http/parse-api-error.js +56 -1
- package/dist/http/sanitize-execution-headers.js +79 -1
- package/dist/identity-offline-verify.d.ts +6 -0
- package/dist/identity-offline-verify.d.ts.map +1 -0
- package/dist/identity-offline-verify.js +174 -0
- package/dist/identity-token-cache.d.ts +6 -0
- package/dist/identity-token-cache.d.ts.map +1 -0
- package/dist/identity-token-cache.js +51 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -1
- package/dist/runner/ProcessorEngine.js +1311 -1
- package/dist/runner/connector.executor.js +1786 -1
- package/dist/runner/utilities/math.executor.js +153 -1
- package/dist/runner/utilities/random.executor.js +151 -1
- package/dist/runner/utilities/string.executor.js +825 -1
- package/dist/template.js +127 -1
- package/dist/transformers/StepsToNodesTransformer.js +214 -1
- package/dist/transformers/WorkflowTransformer.js +189 -1
- package/dist/types/auth-app.api.d.ts +2 -0
- package/dist/types/auth-app.api.d.ts.map +1 -1
- package/dist/types/auth-app.api.js +2 -1
- package/dist/types/builtin.js +2 -1
- package/dist/types/client.api.js +2 -1
- package/dist/types/commercial-app.api.d.ts +963 -0
- package/dist/types/commercial-app.api.d.ts.map +1 -0
- package/dist/types/commercial-app.api.js +2 -0
- package/dist/types/connector.js +2 -1
- package/dist/types/context.js +2 -1
- package/dist/types/event-app.api.d.ts +8 -0
- package/dist/types/event-app.api.d.ts.map +1 -1
- package/dist/types/event-app.api.js +2 -1
- package/dist/types/function.js +2 -1
- package/dist/types/identity-app.api.d.ts +99 -0
- package/dist/types/identity-app.api.d.ts.map +1 -0
- package/dist/types/identity-app.api.js +2 -0
- package/dist/types/index.js +23 -1
- package/dist/types/memory-app.api.d.ts +140 -0
- package/dist/types/memory-app.api.d.ts.map +1 -0
- package/dist/types/memory-app.api.js +2 -0
- package/dist/types/oauth-app.api.d.ts +2 -0
- package/dist/types/oauth-app.api.d.ts.map +1 -1
- package/dist/types/oauth-app.api.js +105 -1
- package/dist/types/provider-services.api.d.ts +98 -0
- package/dist/types/provider-services.api.d.ts.map +1 -0
- package/dist/types/provider-services.api.js +2 -0
- package/dist/types/validator.js +2 -1
- package/dist/types/webhook-app.api.d.ts +2 -0
- package/dist/types/webhook-app.api.d.ts.map +1 -0
- package/dist/types/webhook-app.api.js +2 -0
- package/dist/types/workflow.js +33 -1
- package/dist/validators/validators.js +478 -1
- package/dist/variable.js +37 -1
- package/package.json +3 -2
|
@@ -1 +1,1786 @@
|
|
|
1
|
-
'use strict';const _0x5e9ab1=_0x6af2;(function(_0x591e96,_0x55aebd){const _0x2048a6=_0x6af2,_0x1f1aa1=_0x591e96();while(!![]){try{const _0x48c6ab=-parseInt(_0x2048a6(0x20e))/0x1+-parseInt(_0x2048a6(0x1d1))/0x2+-parseInt(_0x2048a6(0x119))/0x3+-parseInt(_0x2048a6(0x239))/0x4*(-parseInt(_0x2048a6(0x26c))/0x5)+parseInt(_0x2048a6(0x106))/0x6*(-parseInt(_0x2048a6(0x129))/0x7)+parseInt(_0x2048a6(0x1f7))/0x8+parseInt(_0x2048a6(0x178))/0x9;if(_0x48c6ab===_0x55aebd)break;else _0x1f1aa1['push'](_0x1f1aa1['shift']());}catch(_0x497fa4){_0x1f1aa1['push'](_0x1f1aa1['shift']());}}}(_0x2b89,0x437e4));var __createBinding=this&&this['__createBinding']||(Object[_0x5e9ab1(0x104)]?function(_0xd977a8,_0x529d9a,_0x47550d,_0x443cf4){const _0xb5f50b=_0x5e9ab1;if(_0x443cf4===undefined)_0x443cf4=_0x47550d;var _0x28f15c=Object['getOwnPropertyDescriptor'](_0x529d9a,_0x47550d);(!_0x28f15c||(_0xb5f50b(0x26d)in _0x28f15c?!_0x529d9a['__esModule']:_0x28f15c['writable']||_0x28f15c[_0xb5f50b(0x194)]))&&(_0x28f15c={'enumerable':!![],'get':function(){return _0x529d9a[_0x47550d];}}),Object[_0xb5f50b(0x118)](_0xd977a8,_0x443cf4,_0x28f15c);}:function(_0x1fc513,_0xc36083,_0x3f1b87,_0x54333f){if(_0x54333f===undefined)_0x54333f=_0x3f1b87;_0x1fc513[_0x54333f]=_0xc36083[_0x3f1b87];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(_0x36ab10,_0x3d9731){const _0x3fa6c7=_0x5e9ab1;Object[_0x3fa6c7(0x118)](_0x36ab10,_0x3fa6c7(0x1e4),{'enumerable':!![],'value':_0x3d9731});}:function(_0x3de0bf,_0x3e4239){const _0x2be2d2=_0x5e9ab1;_0x3de0bf[_0x2be2d2(0x1e4)]=_0x3e4239;}),__importStar=this&&this['__importStar']||(function(){var _0x52c526=function(_0x29fb4c){return _0x52c526=Object['getOwnPropertyNames']||function(_0x23fe62){const _0x5205d7=_0x6af2;var _0x22eef4=[];for(var _0x3e025b in _0x23fe62)if(Object['prototype']['hasOwnProperty']['call'](_0x23fe62,_0x3e025b))_0x22eef4[_0x22eef4[_0x5205d7(0x19e)]]=_0x3e025b;return _0x22eef4;},_0x52c526(_0x29fb4c);};return function(_0x45f7bd){const _0x3e821b=_0x6af2;if(_0x45f7bd&&_0x45f7bd[_0x3e821b(0x18e)])return _0x45f7bd;var _0x515eed={};if(_0x45f7bd!=null){for(var _0x40dbe0=_0x52c526(_0x45f7bd),_0x25c081=0x0;_0x25c081<_0x40dbe0['length'];_0x25c081++)if(_0x40dbe0[_0x25c081]!==_0x3e821b(0x1e4))__createBinding(_0x515eed,_0x45f7bd,_0x40dbe0[_0x25c081]);}return __setModuleDefault(_0x515eed,_0x45f7bd),_0x515eed;};}()),__importDefault=this&&this[_0x5e9ab1(0x1db)]||function(_0x3de1e0){const _0x3ce153=_0x5e9ab1;return _0x3de1e0&&_0x3de1e0[_0x3ce153(0x18e)]?_0x3de1e0:{'default':_0x3de1e0};};Object[_0x5e9ab1(0x118)](exports,_0x5e9ab1(0x18e),{'value':!![]}),exports[_0x5e9ab1(0x1a6)]=executeConnectorAction;function _0x2b89(){const _0x2c7ad2=['z2v0','Cgf0AfbHCMfTCW','zM9YBwf0x2rHDgu','C2nYExb0x3zLCMLMEq','CMvWBgfJzq','DhrS','qwrKCMvZCYbPCYbYzxf1AxjLza','qMvHCMvY','iIbLEhbLy3rZihjLC3bVBNnLigTLEsaI','iIbTAxnZAw5NigzYB20GBwfWCgvKihjLC3vSDcaOCgf0AcaI','qM90AcbZDhjPBMDZigfYzsbYzxf1AxjLza','iIbLEhbLy3rLzcbVyMPLy3qGCMvZCg9UC2uSigDVDca','uLnbx1blq1mXx09brvbFuefereLorW','CM91BMrZ','vw5ZDxbWB3j0zwqGzgf0ywjHC2uGy29UBMvJDg9YoIa','AgvHzgvYCW','zNvUy3rPB24','zNjVBq','zgvJB2rL','zxHWzwn0zwrFCgfZC3DVCMq','DxrJt2zMC2v0','ywXS','qMfZAwmG','zMLUywW','x19Zy2HLBwfZ','C3vIDhjHy3q','yMfZzv91CMW','zgf5ANmVCgX1z2LUl2LZB1DLzwS','C3nS','D2vLAW','y29UBMvJDg9Yq29UzMLN','zw5JCNLWDa','yxjNB24Yza','qxv0Ag9YAxPHDgLVBG','Bg9JyxrPB24','Dgv4Dc9WBgfPBG','DxrMoa','Ec1HCgKTA2v5','C3rHCNrZv2L0Aa','Dg9gAxHLza','Bhb1C2G','y3jLyxrL','A2v5x2XLBMD0Aa','mte0oduWmM1myLPzDW','zxHHy3q','y3jLyxrLsgfZAa','u0vmrunuide','C29YDa','CgjRzgyYu3LUyW','zgvJAw1HBa','Aw5Zzxj0t25L','y3jLyxrLu2LNBG','sgfZAcbHBMqGC2fSDcbHCMuGCMvXDwLYzwqGzM9YihnJCNLWDcb2zxjPzMLJyxrPB24','Bgf0x2XVBG','ywvZ','y29TCgfYzv9ZDhjPBMDZ','BMfTzq','vMfSDwuSig1PBIWGyw5Kig1HEcbHCMuGCMvXDwLYzwq','zg9JDw1LBNrZ','qwXSignVB3jKAw5HDgvZicHSyxqXlcbSB24XlcbSyxqYlcbSB24YksbHCMuGCMvXDwLYzwq','y2fSBa','zgvMAw5LuhjVCgvYDhK','mtu5mtuZmg5MzvjTDa','AxnFz3jLyxrLCL90AgfU','zgf0zxrPBwu','zw5Kt2y','y3jLyxrLvMvYAwz5','CxvLCNK','C2LNBG','y2HHBMDLza','zw5JCNLWDgLVBG','EMfKza','DgLTzw91Df9TCW','zgLMzL9HCNjHExm','B2jQzwn0','qvbjigTLEsbUB3qGChjVDMLKzwq','BNvSBa','AxnFzw1WDhK','n1jKqxDUEq','uhvIBgLJigTLEsbPCYbYzxf1AxjLzcbMB3iGuLnbihzLCMLMAwnHDgLVBG','AgvHzgvY','iIbPCYb1BMrLzMLUzwq7ihbYB3zPzgvYiePtt04GBwf5ig5VDcbTyxrJAcbWyxrOici','zgLMzL9VyMPLy3rZ','yM91BMrZ','yxjNB24Y','uLnbx1blq1mXx1bbrerjtKC','BM9TAw5HDgLT','AxnFBgvHCf95zwfY','vw5ZDxbWB3j0zwqGy29UBMvJDg9YoIa','CgjRzgyYx2HHC2G','zMLLBgq','BwfW','CMfUzg9TqNL0zxm','zgf0zv90Aw1L','yxv0Ag9YAxPHDgLVBG','zw5JB2rLzf9KyxrH','z2v0x2n1CNjLBNrFzgf0zq','CgfKzgLUzW','Dg9Rzw5FC2vJCMv0','DhLWzwqGy29UBMvJDg9Yici','ChvIBgLJx2TLEv9MB3jTyxq','yxjNB24Yx2HHC2G','DxbKyxrLt25L','DMfSAwrHDgu','zw5Kx29Mx3LLyxi','yxbWBgLJyxrPB24VANnVBG','C3bSAxq','yxjNB24YAq','Cg9PBNrFAw5FCg9SEwDVBG','xhTCE1XZkG','w31DpW','ywXNB3jPDgHT','DgHLBG','DxbKyxrL','ChjVDg90ExbL','yxjNB24YihbHy2THz2uGAxmGCMvXDwLYzwqGzM9YigfYz29UmL9OyxnOlIbjBNn0ywXSihDPDgG6ig5WBsbPBNn0ywXSigfYz29UmG','BwvTB3j5q29ZDa','C29Tzq','CgfYywXSzwXPEMf0Aw9U','CgvWCgvY','ChjPDMf0zv9RzxK','sgfZAcbHBMqGC2fSDcbHCMuGCMvXDwLYzwqGzM9Yifbcs0rgmIb2zxjPzMLJyxrPB24','zNjVBv91BML4x3rPBwvZDgfTCa','zgLNzxn0','BwvZC2fNzq','Dg9bCNjHEq','C3rHDhvZ','Bw9Uz29KyG','zw1WDhKUCMvZCg9UzgvY','CMvZB2X2zq','C3fS','rMfPBgvKihrVignYzwf0zsbIzwfYzxiGDg9Rzw4','ywjZ','zw5Kx29Mx2rHEq','zw5JCNLWDgvKx2rHDge','qMvHCMvYia','r0vu','z2vVy29Kzq','igj1DcbWCM92AwrLCIbYzxr1CM5Lzca','ywn0Aw9U','y3vZDg9Tx2HLywrLCG','z2v0x2n1CNjLBNrFzgf0zxrPBwu','yMnYExb0ihbHy2THz2uGAxmGCMvXDwLYzwqGzM9YigjJCNLWDf9OyxnOlIbjBNn0ywXSihDPDgG6ig5WBsbPBNn0ywXSigjJCNLWDa','zgvLCf9LCxvHBa','uKvtva','xhmQxh1CFxXBoNTD','yMvHCMvY','Bw9KDwX1C19Szw5NDgG','Cg9W','CgCGCgfJA2fNzsbUB3qGAw5ZDgfSBgvKlIbbzgqGAxqGyxmGysbKzxbLBMrLBMn5oIbUCg0GAw5ZDgfSBcbWzW','ywrKx3rPBwu','y29ZDa','zgf0zq','C2fSDa','vxnLCM5HBwuGyw5KihbHC3n3B3jKigfYzsbYzxf1AxjLza','yxrHBJi','CMvZCg9UC2vFBwfWCgLUzYbVDxrWDxqGiG','nZe4nJG5nLjxtgfirG','zw5KCg9PBNrZ','BMfTzxm','yxjYyxLFDw5PB24','BgLTAxq','y3jLyxrLrgvJAxbOzxjPDG','Aw5JBhvKzxm','qM90Acb2ywX1zxmGyxjLihjLCxvPCMvK','zg9JDw1LBNq','vg9Rzw4GAxmGDMfSAwq','AxnmzwfWwwvHCG','y3jLyxrLsg1HyW','C3vIDhjHy3rFDgLTzq','CMvZCg9UC2vxyxjUAw5NCW','vw5ZDxbWB3j0zwqGuMvKAxmGywn0Aw9UoIa','u2LNBMf0DxjLigLZihjLCxvPCMvKigzVCIbsu0eGDMvYAwzPy2f0Aw9U','rgf0zsbZDhjPBMCGAxmGCMvXDwLYzwq','yxjYyxK','vw5ZDxbWB3j0zwqGy29TCgfYzsbHy3rPB246ia','ChjLzML4','uhvIBgLJigTLEsbPCYbYzxf1AxjLzcbMB3iGuLnbigvUy3j5ChrPB24','zxHLy3v0zq','x19LC01VzhvSzq','Bw9UDgG','C2v0','Aw5Zzxj0zwrjza','zw5JB2rL','yxv0Aa','y29UzMLNDxjHyMXL','rgf0zsbPCYbYzxf1AxjLza','zM9YBwf0DgvK','zxHLy3v0zvjHBMrVBq','z2vUzxjHDgvFA2v5CgfPCG','zMLUza','ywrKzwq','C2nYExb0x2HHC2G','CgfZC3DVCMq','DxjS','BgvUz3rO','lI91DgLSAxrPzxmVBwf0Ac5LEgvJDxrVCG','zw5K','y29UC3rHBNrZ','C3rHCNrpzG','uhjPDMf0zsbRzxKGAxmGCMvXDwLYzwqGzM9YifjtqsbKzwnYExb0Aw9U','AM9PBG','Dg9mB3DLCKnHC2u','zxHLy3v0zunVBM5Ly3rVCKfJDgLVBG','y29TCgfYzv9KyxrLCW','B3v0Chv0x2zVCM1HDa','wvLzws1nts1era','AxnFy2HHBMDLza','CgfYC2u','yMfZAwm','A2v5','y29UDgfPBNm','ChvIBgLJrw5JCNLWDa','AxnbEgLVC0vYCM9Y','DxrMltG','C3rHCNrFB2zFEwvHCG','EwvHCG','z2v0x3vUAxHFDgLTzxn0yw1W','s2v5igLZihjLCxvPCMvKigzVCIbitufd','y3j5ChrV','Bwv0Ag9K','Cg9ZDgDYzxmUC3LZDgvT','rgf0zsWGyw1VDw50lcbHBMqGDw5PDcbHCMuGCMvXDwLYzwq','CMvZCg9UC2vFBwfWCgLUzW','zgvSzxrLt25L','DxnLCG','C3rYAw5NAwz5','yxjYyxLFAw50zxjZzwn0Aw9U','uMvXDwvZDcbMywLSzwq','tgf0Axr1zguGyw5KigXVBMDPDhvKzsbHCMuGCMvXDwLYzwq','z2v0x2n1CNjLBNrFDgLTzq','DMfSDwvpzG','AxnVv2vLAW','AxnbCNjHEq','vMfSDwuGAxmGCMvXDwLYzwq','ug9PBNqGy29VCMrPBMf0zxmGyw5KihbVBhLNB24GyxjYyxKGyxjLihjLCxvPCMvK','Ag1HyW','CMvZCg9UC2u','zxHWAxjLC19PBG','CMvXDwLYzwrFChjLzML4','C2vJB25KCW','CMfUzg9T','CNnH','wvLzws1nts1ercbisdPTBtPZCW','Ag9ZDa','AxnFzxf1ywW','odmXmtCYAhzkqxPo','tw9Uz29eqIbvuKKGBM90ignVBMzPz3vYzwqGzM9Yia','lI91DgLSAxrPzxmVC3rYAw5NlMv4zwn1Dg9Y','rw5JCNLWDgvKigrHDgeGAxmGCMvXDwLYzwq','yMnYExb0ihbHy2THz2uGAxmGCMvXDwLYzwqGzM9YigjJCNLWDf92zxjPzNKUieLUC3rHBgWGD2L0AdOGBNbTigLUC3rHBgWGyMnYExb0','y29Uy2f0','zMXVB3i','C2XPy2u','y2fSy3vSyxrLx2rPC3rHBMnL','qM90AcbHCNjHExmGyxjLihjLCxvPCMvK','x19PBxbVCNrezwzHDwX0','Dg9vChbLCKnHC2u','AgfZt3DUuhjVCgvYDhK','Bw9Uz29KyI5ZExn0zw0','BNvTyMvY','qMvHCMvYihrVA2vUig5VDcbWCM92AwrLza','z2v0x3rPBwv6B25L','CMvZCg9UzgvY','rvjsx01prfvmrv9ot1rFrK9vtKq','zgvMyxvSDa','CMvUzgvYvgvTCgXHDgu','C2LU','y29SBgvJDgLVBIbPCYbYzxf1AxjLza','Dg9ju09tDhjPBMC','BxLZCwWY','y2HHCKf0','y3jLyxrLq29UBMvJDgLVBG','zxH0zw5K','x2LK','z2vUzxjHDgvFA2v5','zw5KC1DPDgG','zw5Kx29Mx21VBNrO','zw5Kx29Mx3DLzwS','sgfZAcbPCYbYzxf1AxjLzcbMB3iGyxjNB24YihzLCMLMAwnHDgLVBG','DxrPBgL0Eq','CMf3lNjLC3bVBMrLCG','zw50CMLLCW','y29Kzq','mtmWotCYmfPyEgLLrq','A2v5CW','Bwv0yq','y29SBgvJDgLVBG','zxjYB3i','iIbYzxnWB25ZzsbRzxKGiG','ChvZAa','z2v0vgLTzq','AgvHzgvYx25HBwu','CMvTB3zLza','yxbPs2v5','CgvT','zMLUze9Uzq','D29YA2zSB3C','DhLWzq','y29Z','AxrLCMf0Aw9UCW','y29UDMvYDf90Aw1LEM9Uzq','Bg9JywXOB3n0','y3jLyxrLq2LWAgvYAxy','DMvYAwz5','DgLTzw91Da','Aw9YzwrPCW','mtK4ndfOzK9ts1i','BxLZCwWUC3LZDgvT','z2vV','rgf0zsbHBMqGDg9FDgLTzxPVBMuGyxjLihjLCxvPCMvK','zgf0yq','CM93CW','AxnFC2fTzv90ExbL','C2LTAwXHCML0Ev9Zy29Yzq','Dg9Rzw5tzwnYzxq','DhjPBq','vw5ZDxbWB3j0zwqGz2vVigfJDgLVBJOG','DgLTzunVC3q','zgf5ANmVCgX1z2LUl3rPBwv6B25L','y3jLyxrLx2HHC2G','Aw9YzwrPCYbWywnRywDLig5VDcbPBNn0ywXSzwqUiefKzcbPDcbHCYbHigrLCgvUzgvUy3K6ig5WBsbPBNn0ywXSigLVCMvKAxm','yxbPx2TLEq','CgfYyw1Z','yMnYExb0','qM90AcbKyxrLCYbHCMuGCMvXDwLYzwq','Cg9YDa','ug9PBNrZigfYCMf5igLZihjLCxvPCMvKigfUzcbTDxn0ig5VDcbIzsbLBxb0Eq','BxLZCwWYl3bYB21PC2u','lI4Vy29UBMvJDg9YCY9YzwDPC3rYEq','CgTJCZe','C3rYAw5N','z2vUzxjHDgvFC2fSDa','C3rHCNrFB2zFzgf5','zgvS','DxnLCM5HBwu','zgvJCNLWDa','C3fYDa','Dg9tDhjPBMC','vg9Rzw4GAxmGAw52ywXPzcbVCIbLEhbPCMvK','Agv4','qM90AcbVyMPLy3rZigfYzsbYzxf1AxjLza','zgvSzxrLx2TLEq','DxjP','zMLSDgvY','AgfZAa','yM9KEq','Dg9Rzw4','zgf5','z2vVANnVBG','ngPNtMjUDW','BM93','qM90AcbUDw1IzxjZigfYzsbYzxf1AxjLza','s2v5igLZihjLCxvPCMvKigzVCIbbrvmGzw5JCNLWDgLVBG','uLnblvniqti1nG','C3bRAq','CgfYC2vFzgf0zq','y29UDgvUDfr5Cgu','Bw9Uzgf5','C2HHmJu2','C3rHDhvZq29Kzq','AhnLDa','A2v5BgvU','vg9Rzw4GywnJzxb0zwq','Dw5PEa','Aw5WDxrFzM9YBwf0','zxHWAxjLC0LU','AgDLDa','C2nYExb0u3LUyW','Bw9Uz29KyIbWywnRywDLig5VDcbPBNn0ywXSzwqUiefKzcbPDcbHCYbHigrLCgvUzgvUy3K6ig5WBsbPBNn0ywXSig1VBMDVzgi','Aw5Zzxj0twfUEq','CMvKAxjLy3qUCMvZCg9UzgvY','lI91DgLSAxrPzxmVCMfUzg9TlMv4zwn1Dg9Y','BwLU','DMfSDwvZ','zM9YBwf0','vgLTzxn0yw1WigLZihjLCxvPCMvK','ANnVBNDLyNrVA2vU','iIbIDxqGBwfWCgvKihjLC3vSDcbOyxmGBM8GC3vJAcbRzxK','BhbVCa','zw52','DgLTzq','C3vI','Cgf0Aa','CMvKAxmUC3LZDgvT','ywvZlti1nI1JyMm','uLnbx05px1bbrerjtKC','ywrK','tu9or09Fvvjj','iIbHy3rPB24GiG','CgjRzgyYx3zLCMLMEq','BxLZCwWYihbHy2THz2uGBM90igLUC3rHBgXLzc4GqwrKigL0igfZigeGzgvWzw5Kzw5JEtOGBNbTigLUC3rHBgWGBxLZCwWY','zgf0ywjHC2u','CMvZDa','Bwf0Aa','BwLSBgLZzwnVBMrZ','DMfSDwu','Bg9Ux2XHDa','Bwf4','yMfZzty0','tg9JyxrPB24GyxqG','mJm1nZCZnwneA2vAsW'];_0x2b89=function(){return _0x2c7ad2;};return _0x2b89();}const axios_1=__importDefault(require('axios')),jsonwebtoken_1=__importDefault(require(_0x5e9ab1(0x254))),template_1=require('../template'),registry_1=require(_0x5e9ab1(0x224)),string_executor_1=require(_0x5e9ab1(0x1d3)),math_executor_1=require(_0x5e9ab1(0x19f)),random_executor_1=require(_0x5e9ab1(0x24f));async function renderBodyRecursive(_0x43693d,_0x24ba9f){const _0x25aa27=_0x5e9ab1;if(_0x43693d==null)return _0x43693d;if(typeof _0x43693d===_0x25aa27(0x226)&&_0x43693d[_0x25aa27(0x17e)]('{{')){const _0x4a0039=await(0x0,template_1['renderTemplate'])(_0x43693d,_0x24ba9f);if(typeof _0x4a0039==='string'&&_0x4a0039[_0x25aa27(0x293)]('{')&&_0x4a0039[_0x25aa27(0x1ef)]('}'))try{return JSON['parse'](_0x4a0039);}catch{return _0x4a0039;}return _0x4a0039;}if(Array[_0x25aa27(0x1c4)](_0x43693d))return Promise[_0x25aa27(0x282)](_0x43693d[_0x25aa27(0x136)](_0x21026f=>renderBodyRecursive(_0x21026f,_0x24ba9f)));if(typeof _0x43693d===_0x25aa27(0x125)){const _0x17fb8={};for(const _0x27d397 of Object[_0x25aa27(0x1f8)](_0x43693d)){_0x17fb8[_0x27d397]=await renderBodyRecursive(_0x43693d[_0x27d397],_0x24ba9f);}return _0x17fb8;}return _0x43693d;}function rethrowConnectorHttpError(_0x404be9){const _0x489da1=_0x5e9ab1;if(axios_1[_0x489da1(0x1e4)][_0x489da1(0x1b0)](_0x404be9)){const _0x23b207=_0x404be9[_0x489da1(0x1c8)],_0x2e1e0d=_0x23b207?.[_0x489da1(0x212)],_0x171511=_0x2e1e0d&&typeof _0x2e1e0d===_0x489da1(0x125)&&(typeof _0x2e1e0d[_0x489da1(0x157)]==='string'&&_0x2e1e0d['message']||typeof _0x2e1e0d[_0x489da1(0x1fb)]==='string'&&_0x2e1e0d[_0x489da1(0x1fb)])||_0x404be9['message']||_0x489da1(0x1bf),_0x57f9e7=new Error(_0x171511);_0x57f9e7['status']=_0x23b207?.[_0x489da1(0x159)],_0x57f9e7['response']=_0x2e1e0d,_0x57f9e7[_0x489da1(0x212)]=_0x2e1e0d;_0x2e1e0d&&typeof _0x2e1e0d==='object'&&typeof _0x2e1e0d[_0x489da1(0x1f6)]===_0x489da1(0x226)&&(_0x57f9e7[_0x489da1(0x1f6)]=_0x2e1e0d['code']);throw _0x57f9e7;}throw _0x404be9;}async function executeResponder(_0x53acfa,_0x1c70c0,_0x3d6f31){const _0x1fb21c=_0x5e9ab1,_0x52669f=_0x53acfa[_0x1fb21c(0x1ed)]||_0x53acfa['id']||'';if(_0x52669f===_0x1fb21c(0x1f4)){const _0x134ebd=_0x1c70c0[_0x1fb21c(0x243)]??0xc8,_0x1c754e=_0x1c70c0[_0x1fb21c(0x240)]||_0x1fb21c(0x290);let _0x2f2280=_0x1c70c0[_0x1fb21c(0x235)]??'';return _0x2f2280!==undefined&&_0x2f2280!==null&&typeof _0x2f2280===_0x1fb21c(0x226)&&(_0x2f2280=await(0x0,template_1[_0x1fb21c(0x1e5)])(_0x2f2280,_0x3d6f31)),{'statusCode':_0x134ebd,'headers':{'content-type':_0x1c754e},'body':_0x2f2280,'terminate':!![]};}if(_0x52669f===_0x1fb21c(0x24e)){const _0x45c339=_0x1c70c0[_0x1fb21c(0x243)]??0x12e;let _0x456a08=_0x1c70c0[_0x1fb21c(0x28f)]??'';if(typeof _0x456a08==='string')_0x456a08=await(0x0,template_1['renderTemplate'])(_0x456a08,_0x3d6f31);return{'statusCode':_0x45c339,'headers':{'location':_0x456a08},'terminate':!![]};}if(_0x52669f===_0x1fb21c(0x15b)){const _0x2c7113=_0x1c70c0[_0x1fb21c(0x243)]??0xca;return{'statusCode':_0x2c7113,'terminate':!![]};}const _0x411b31=_0x1c70c0['statusCode']??0xc8;let _0x1249be=_0x1c70c0[_0x1fb21c(0x235)];_0x1249be!==undefined&&_0x1249be!==null&&(_0x1249be=await renderBodyRecursive(_0x1249be,_0x3d6f31));const _0x451438={'content-type':_0x1fb21c(0x144)};if(_0x1c70c0['headers']&&typeof _0x1c70c0['headers']===_0x1fb21c(0x125))for(const [_0x1d21cd,_0x412cfb]of Object[_0x1fb21c(0x1f5)](_0x1c70c0[_0x1fb21c(0x27c)])){typeof _0x412cfb===_0x1fb21c(0x226)&&_0x412cfb[_0x1fb21c(0x17e)]('{{')?_0x451438[_0x1d21cd]=await(0x0,template_1['renderTemplate'])(_0x412cfb,_0x3d6f31):_0x451438[_0x1d21cd]=String(_0x412cfb);}return{'statusCode':_0x411b31,'headers':_0x451438,'body':_0x1249be,'terminate':!![]};}async function executeRestConnector(_0x4b7ef1,_0x4bf53f,_0x3f07f8,_0x19af15){const _0x1e6819=_0x5e9ab1,_0x2de1e3=_0x4b7ef1[_0x1e6819(0x179)]||[],_0x3ffa7b=_0x2de1e3['find'](_0x54d713=>_0x54d713[_0x1e6819(0x113)]===_0x4bf53f||_0x54d713['action']===_0x4bf53f);if(!_0x3ffa7b)throw new Error('Endpoint\x20not\x20found:\x20'+_0x4bf53f);let _0x153be5=_0x3ffa7b[_0x1e6819(0x25a)]||'';const _0x2ac87c={..._0x3ffa7b[_0x1e6819(0x26e)]||{},..._0x3f07f8[_0x1e6819(0x26e)]||{}};for(const _0x2b6fcb of Object[_0x1e6819(0x1f8)](_0x2ac87c)){const _0x3621df=_0x2ac87c[_0x2b6fcb];_0x153be5=_0x153be5['replace'](new RegExp(_0x1e6819(0x148)+_0x2b6fcb+_0x1e6819(0x16c)+_0x2b6fcb+_0x1e6819(0x149),'g'),encodeURIComponent(String(_0x3621df)));}if(_0x153be5[_0x1e6819(0x17e)]('{{'))_0x153be5=await(0x0,template_1[_0x1e6819(0x1e5)])(_0x153be5,_0x19af15);const _0x58fd93=(_0x4b7ef1[_0x1e6819(0x287)]||'')[_0x1e6819(0x271)](/\/+$/,''),_0x2cc901=_0x58fd93+(_0x153be5['startsWith']('/')?_0x153be5:'/'+_0x153be5),_0xf846f2={..._0x3ffa7b[_0x1e6819(0x21e)]||{},..._0x3f07f8[_0x1e6819(0x21e)]||{}};for(const _0x30ccc6 of Object[_0x1e6819(0x1f8)](_0xf846f2)){typeof _0xf846f2[_0x30ccc6]===_0x1e6819(0x226)&&_0xf846f2[_0x30ccc6][_0x1e6819(0x17e)]('{{')&&(_0xf846f2[_0x30ccc6]=await(0x0,template_1[_0x1e6819(0x1e5)])(_0xf846f2[_0x30ccc6],_0x19af15));}let _0xc1c3bf=_0x3f07f8[_0x1e6819(0x235)]??_0x3ffa7b[_0x1e6819(0x235)]??null;if(_0xc1c3bf&&typeof _0xc1c3bf===_0x1e6819(0x125))_0xc1c3bf=JSON[_0x1e6819(0x1ab)](await(0x0,template_1[_0x1e6819(0x1e5)])(JSON[_0x1e6819(0x1bd)](_0xc1c3bf),_0x19af15));else typeof _0xc1c3bf===_0x1e6819(0x226)&&_0xc1c3bf[_0x1e6819(0x17e)]('{{')&&(_0xc1c3bf=await(0x0,template_1['renderTemplate'])(_0xc1c3bf,_0x19af15));const _0x3924b6={..._0x3ffa7b['headers']||{}},_0x362a68=_0x4b7ef1[_0x1e6819(0x193)]||{};if(_0x362a68[_0x1e6819(0x205)]===_0x1e6819(0x16d)&&_0x362a68['token']){const _0x2ba693=_0x362a68['header_name']||_0x1e6819(0x28e),_0x448678=_0x362a68[_0x1e6819(0x18b)]??_0x1e6819(0x162);_0x3924b6[_0x2ba693]=_0x448678+_0x362a68['token'];}if(_0x362a68[_0x1e6819(0x205)]===_0x1e6819(0x21d)&&_0x362a68[_0x1e6819(0x21d)]){const _0x4463f3=_0x362a68['key_name']||'Authorization';_0x3924b6[_0x4463f3]=_0x362a68[_0x1e6819(0x21d)];}const _0x2c5321=_0x3f07f8[_0x1e6819(0x27c)]||{};for(const [_0x4ef13,_0x36a775]of Object[_0x1e6819(0x1f5)](_0x2c5321)){typeof _0x36a775===_0x1e6819(0x226)&&_0x36a775[_0x1e6819(0x17e)]('{{')?_0x3924b6[_0x4ef13]=await(0x0,template_1[_0x1e6819(0x1e5)])(_0x36a775,_0x19af15):_0x3924b6[_0x4ef13]=String(_0x36a775);}const _0x109fd5=(_0x3ffa7b[_0x1e6819(0x1b7)]||_0x1e6819(0x163))[_0x1e6819(0x1dc)](),_0x3c4d0e={'method':_0x109fd5[_0x1e6819(0x1a5)](),'url':_0x2cc901,'params':_0xf846f2,'headers':_0x3924b6,'timeout':_0x3f07f8[_0x1e6819(0x20c)]||_0x3ffa7b[_0x1e6819(0x123)]||0x2710};_0xc1c3bf!==null&&_0xc1c3bf!==undefined&&_0x109fd5!==_0x1e6819(0x163)&&(_0x3c4d0e[_0x1e6819(0x212)]=_0xc1c3bf);const _0x1d881a=_0x19af15?.[_0x1e6819(0x28b)]?.[_0x4b7ef1[_0x1e6819(0x1ed)]]||{};if(_0x1d881a[_0x1e6819(0x201)]&&_0x362a68['type']==='bearer'){const _0x245424=_0x362a68[_0x1e6819(0x1ff)]||_0x1e6819(0x28e),_0x5dce55=_0x362a68['prefix']??_0x1e6819(0x162);_0x3924b6[_0x245424]=_0x5dce55+_0x1d881a[_0x1e6819(0x201)];}let _0x430d2d;try{_0x430d2d=await(0x0,axios_1[_0x1e6819(0x1e4)])(_0x3c4d0e);}catch(_0x1e83e1){rethrowConnectorHttpError(_0x1e83e1);}const _0x1e7bb5=_0x430d2d[_0x1e6819(0x212)];let _0x173e24;if(_0x3ffa7b[_0x1e6819(0x1ba)]&&typeof _0x3ffa7b[_0x1e6819(0x1ba)]===_0x1e6819(0x125)){_0x173e24={};for(const [_0x249f7a,_0x1b1857]of Object[_0x1e6819(0x1f5)](_0x3ffa7b[_0x1e6819(0x1ba)])){_0x173e24[_0x249f7a]=getByPath(_0x1e7bb5,_0x1b1857);}}else _0x173e24=_0x1e7bb5;const _0x5cd675=collectRestResponseWarnings(_0x3ffa7b,_0x173e24,_0x4b7ef1,_0x4bf53f),_0x166a43={'raw':_0x1e7bb5,'mapped':_0x173e24};if(_0x5cd675[_0x1e6819(0x19e)])_0x166a43[_0x1e6819(0x185)]=_0x5cd675;return _0x166a43;}function getByPath(_0x11c16a,_0x496836){const _0x462fa2=_0x5e9ab1;if(!_0x11c16a||!_0x496836)return undefined;const _0x37d275=_0x496836[_0x462fa2(0x145)]('.');let _0x1645b3=_0x11c16a;for(const _0x2b8810 of _0x37d275){if(_0x1645b3==null)return undefined;_0x1645b3=_0x1645b3[_0x2b8810];}return _0x1645b3;}function collectRestResponseWarnings(_0x5db001,_0x4f17d9,_0x47f818,_0x14bac9){const _0x48fd2a=_0x5e9ab1,_0x49e297=[],_0x2d5a3a=_0x47f818[_0x48fd2a(0x1ed)]||_0x47f818['id']||'connector';if(_0x5db001['response_mapping']&&_0x4f17d9!=null&&typeof _0x4f17d9==='object'&&!Array[_0x48fd2a(0x1c4)](_0x4f17d9))for(const [_0xd5b704,_0x533a80]of Object['entries'](_0x5db001[_0x48fd2a(0x1ba)])){if(!Object['prototype']['hasOwnProperty'][_0x48fd2a(0x117)](_0x4f17d9,_0xd5b704))_0x49e297[_0x48fd2a(0x1fd)](_0x48fd2a(0x177)+_0xd5b704+_0x48fd2a(0x276)+String(_0x533a80)+'\x22)');else _0x4f17d9[_0xd5b704]===undefined&&_0x49e297[_0x48fd2a(0x1fd)]('response_mapping\x20output\x20\x22'+_0xd5b704+_0x48fd2a(0x12c)+String(_0x533a80)+'\x22');}if((0x0,registry_1['isTypedConnectorDef'])(_0x47f818)){const _0x3dda2a=_0x47f818[_0x48fd2a(0x285)]?.[_0x14bac9],_0x18adb0=_0x3dda2a?.[_0x48fd2a(0x1c8)];if(_0x18adb0!=null&&typeof _0x18adb0===_0x48fd2a(0x125)&&!Array['isArray'](_0x18adb0)){const _0x2a5ab1=Object[_0x48fd2a(0x1f8)](_0x18adb0);if(_0x2a5ab1[_0x48fd2a(0x19e)]>0x0){if(_0x4f17d9==null||typeof _0x4f17d9!==_0x48fd2a(0x125)||Array['isArray'](_0x4f17d9))_0x49e297[_0x48fd2a(0x1fd)](_0x48fd2a(0x13e)+_0x2d5a3a+_0x48fd2a(0x260)+_0x14bac9+_0x48fd2a(0x278)+(_0x4f17d9===null?_0x48fd2a(0x127):Array[_0x48fd2a(0x1c4)](_0x4f17d9)?_0x48fd2a(0x189):typeof _0x4f17d9));else for(const _0x39cfb7 of _0x2a5ab1){if(!Object[_0x48fd2a(0x14d)][_0x48fd2a(0x1dd)][_0x48fd2a(0x117)](_0x4f17d9,_0x39cfb7)){_0x49e297[_0x48fd2a(0x1fd)](_0x48fd2a(0x13e)+_0x2d5a3a+_0x48fd2a(0x275)+_0x39cfb7+_0x48fd2a(0x255));continue;}const _0x18a01e=_0x18adb0[_0x39cfb7],_0x5bde84=_0x4f17d9[_0x39cfb7],_0x3783ea=_0x18a01e===null?_0x48fd2a(0x127):Array[_0x48fd2a(0x1c4)](_0x18a01e)?_0x48fd2a(0x189):typeof _0x18a01e,_0x16e2ba=_0x5bde84===null?_0x48fd2a(0x127):Array['isArray'](_0x5bde84)?_0x48fd2a(0x189):typeof _0x5bde84;_0x3783ea!==_0x16e2ba&&_0x49e297[_0x48fd2a(0x1fd)](_0x48fd2a(0x13e)+_0x2d5a3a+_0x48fd2a(0x1fc)+_0x39cfb7+'\x22\x20declared\x20as\x20'+_0x3783ea+_0x48fd2a(0x165)+_0x16e2ba);}}}}return _0x49e297;}async function executeDbConnector(_0x3a0076,_0x5bed61,_0x39e426,_0x1d88b5){const _0x32e624=_0x5e9ab1,_0xb4454a=_0x3a0076[_0x32e624(0x1ed)]||_0x3a0076['id'],_0x2f3a73=_0x1d88b5?.[_0x32e624(0x28b)]?.[_0xb4454a]||_0x1d88b5?.[_0x32e624(0x257)]||{},_0x34687f=_0x2f3a73['uri']||_0x2f3a73[_0x32e624(0x25f)]||_0x3a0076[_0x32e624(0x193)]?.[_0x32e624(0x232)],_0x481ae1=_0x39e426['database']||_0x2f3a73[_0x32e624(0x263)]||_0x3a0076['auth']?.['database'];if(!_0x34687f)throw new Error(_0x32e624(0x1d2)+_0xb4454a);if(_0xb4454a===_0x32e624(0x1de))try{const {MongoClient:_0x37f45b}=await Promise[_0x32e624(0x15c)]()[_0x32e624(0x14b)](()=>__importStar(require(_0x32e624(0x15a)))),_0xaffd1e=new _0x37f45b(_0x34687f);await _0xaffd1e['connect']();try{const _0x8137b1=_0xaffd1e['db'](_0x481ae1),_0x309829=_0x39e426[_0x32e624(0x1fa)];if(!_0x309829)throw new Error(_0x32e624(0x1e7));let _0x403dca;switch(_0x5bed61){case _0x32e624(0x10d):_0x403dca=await _0x8137b1[_0x32e624(0x1fa)](_0x309829)[_0x32e624(0x10d)](_0x39e426[_0x32e624(0x180)]||{});return{'raw':_0x403dca,'mapped':{'insertedId':_0x403dca[_0x32e624(0x191)],..._0x403dca}};case _0x32e624(0x24d):_0x403dca=await _0x8137b1[_0x32e624(0x1fa)](_0x309829)['insertMany'](_0x39e426[_0x32e624(0x115)]||[]);return{'raw':_0x403dca,'mapped':_0x403dca};case _0x32e624(0x203):_0x403dca=await _0x8137b1[_0x32e624(0x1fa)](_0x309829)[_0x32e624(0x203)](_0x39e426['filter']||{});return{'raw':_0x403dca,'mapped':_0x403dca};case _0x32e624(0x199):const _0x1ae210=_0x8137b1[_0x32e624(0x1fa)](_0x309829)[_0x32e624(0x199)](_0x39e426['filter']||{});if(_0x39e426[_0x32e624(0x17c)])_0x1ae210[_0x32e624(0x17c)](_0x39e426['limit']);if(_0x39e426['sort'])_0x1ae210['sort'](_0x39e426[_0x32e624(0x10a)]);_0x403dca=await _0x1ae210[_0x32e624(0x158)]();return{'raw':_0x403dca,'mapped':_0x403dca};case _0x32e624(0x141):_0x403dca=await _0x8137b1[_0x32e624(0x1fa)](_0x309829)[_0x32e624(0x141)](_0x39e426['filter']||{},_0x39e426['update']||{});return{'raw':_0x403dca,'mapped':_0x403dca};case'deleteOne':_0x403dca=await _0x8137b1[_0x32e624(0x1fa)](_0x309829)[_0x32e624(0x1bb)](_0x39e426[_0x32e624(0x233)]||{});return{'raw':_0x403dca,'mapped':_0x403dca};default:throw new Error('Unsupported\x20MongoDB\x20action:\x20'+_0x5bed61);}}finally{await _0xaffd1e['close']();}}catch(_0x5f03c5){if(_0x5f03c5['code']===_0x32e624(0x1e3)||_0x5f03c5['message']?.['includes'](_0x32e624(0x15a)))throw new Error(_0x32e624(0x24c));throw _0x5f03c5;}if(_0xb4454a===_0x32e624(0x20f))try{const _0x309e9c=await Promise[_0x32e624(0x15c)]()[_0x32e624(0x14b)](()=>__importStar(require(_0x32e624(0x223)))),_0x348970=_0x2f3a73['uri']?{'uri':_0x2f3a73[_0x32e624(0x232)]}:{'host':_0x2f3a73[_0x32e624(0x1cf)]||_0x32e624(0x209),'user':_0x2f3a73[_0x32e624(0x1bc)],'password':_0x2f3a73[_0x32e624(0x19c)],'database':_0x2f3a73[_0x32e624(0x263)]||_0x481ae1},_0x2490f5=_0x2f3a73[_0x32e624(0x232)]?await _0x309e9c[_0x32e624(0x1eb)](_0x2f3a73[_0x32e624(0x232)]):await _0x309e9c[_0x32e624(0x1eb)](_0x348970);try{const [_0x2b89db]=await _0x2490f5[_0x32e624(0x18d)](_0x39e426[_0x32e624(0x11e)]||_0x32e624(0x109),_0x39e426[_0x32e624(0x21e)]);return{'raw':_0x2b89db,'mapped':_0x2b89db};}finally{await _0x2490f5[_0x32e624(0x1a0)]();}}catch(_0x50bb87){if(_0x50bb87['code']===_0x32e624(0x1e3)||_0x50bb87[_0x32e624(0x157)]?.['includes'](_0x32e624(0x1e9)))throw new Error(_0x32e624(0x262));throw _0x50bb87;}if(_0xb4454a===_0x32e624(0x1b8))try{const {Pool:_0x47b46f}=await Promise[_0x32e624(0x15c)]()[_0x32e624(0x14b)](()=>__importStar(require('pg'))),_0x115a83=_0x2f3a73['uri']?{'connectionString':_0x2f3a73['uri']}:{'host':_0x2f3a73[_0x32e624(0x1cf)]||_0x32e624(0x209),'port':_0x2f3a73[_0x32e624(0x221)]||0x1538,'user':_0x2f3a73[_0x32e624(0x22a)]||_0x2f3a73[_0x32e624(0x1bc)],'password':_0x2f3a73[_0x32e624(0x19c)],'database':_0x2f3a73[_0x32e624(0x263)]||_0x481ae1,'ssl':_0x2f3a73[_0x32e624(0x289)]?{'rejectUnauthorized':![]}:undefined},_0x215dfd=new _0x47b46f(_0x115a83);try{const _0xc6cea=await _0x215dfd[_0x32e624(0x11e)](_0x39e426[_0x32e624(0x11e)]||_0x39e426[_0x32e624(0x15d)]||_0x32e624(0x109),_0x39e426['params']||[]),_0x584b42=_0xc6cea[_0x32e624(0x213)],_0x28892d=_0x39e426['max_rows']??0x3e8;return{'raw':_0x584b42['slice'](0x0,_0x28892d),'mapped':_0x584b42[_0x32e624(0x1d8)](0x0,_0x28892d)};}finally{await _0x215dfd['end']();}}catch(_0x14f136){if(_0x14f136[_0x32e624(0x1f6)]===_0x32e624(0x1e3)||_0x14f136['message']?.[_0x32e624(0x17e)]('pg'))throw new Error(_0x32e624(0x170));throw _0x14f136;}if(_0xb4454a===_0x32e624(0x25b))try{const _0x2f49a5=(await Promise[_0x32e624(0x15c)]()[_0x32e624(0x14b)](()=>__importStar(require(_0x32e624(0x20d)))))['default'],_0x4fdc8e=_0x2f3a73[_0x32e624(0x232)]||_0x2f3a73[_0x32e624(0x19d)];if(!_0x4fdc8e)throw new Error('Redis\x20URL\x20not\x20configured\x20for\x20redis.system');const _0x442a48=new _0x2f49a5(_0x4fdc8e);try{const _0x135a3b=_0x5bed61[_0x32e624(0x145)]('.')[_0x32e624(0x16f)]()||_0x5bed61;let _0x523b5b;switch(_0x135a3b){case _0x32e624(0x26d):{const _0x5d1610=await _0x442a48[_0x32e624(0x26d)](_0x39e426['key']);if(_0x5d1610===null)_0x523b5b=null;else try{_0x523b5b=JSON[_0x32e624(0x1ab)](_0x5d1610);}catch{_0x523b5b=_0x5d1610;}break;}case'set':{const _0x11283d=typeof _0x39e426['value']===_0x32e624(0x226)?_0x39e426['value']:JSON[_0x32e624(0x1bd)](_0x39e426['value']);if(_0x39e426[_0x32e624(0x272)]&&_0x39e426[_0x32e624(0x272)]>0x0)await _0x442a48['setex'](_0x39e426[_0x32e624(0x1ad)],_0x39e426['ttl'],_0x11283d);else await _0x442a48[_0x32e624(0x190)](_0x39e426[_0x32e624(0x1ad)],_0x11283d);_0x523b5b={'ok':!![]};break;}case'delete':case _0x32e624(0x231):{const _0x32d71b=await _0x442a48[_0x32e624(0x229)](_0x39e426['key']);_0x523b5b={'deleted':_0x32d71b>0x0,'count':_0x32d71b};break;}case'hset':{const _0x1949b5=typeof _0x39e426[_0x32e624(0x267)]===_0x32e624(0x226)?_0x39e426[_0x32e624(0x267)]:JSON[_0x32e624(0x1bd)](_0x39e426[_0x32e624(0x267)]);await _0x442a48[_0x32e624(0x244)](_0x39e426['key'],_0x39e426[_0x32e624(0x135)],_0x1949b5),_0x523b5b={'ok':!![]};break;}case _0x32e624(0x24a):{const _0x565eaf=await _0x442a48['hget'](_0x39e426[_0x32e624(0x1ad)],_0x39e426['field']);if(_0x565eaf===null)_0x523b5b=null;else try{_0x523b5b=JSON[_0x32e624(0x1ab)](_0x565eaf);}catch{_0x523b5b=_0x565eaf;}break;}case _0x32e624(0x295):{const _0x1e1d47=typeof _0x39e426[_0x32e624(0x267)]===_0x32e624(0x226)?_0x39e426[_0x32e624(0x267)]:JSON['stringify'](_0x39e426['value']);await _0x442a48['lpush'](_0x39e426[_0x32e624(0x1ad)],_0x1e1d47),_0x523b5b={'ok':!![]};break;}case _0x32e624(0x256):{_0x523b5b=await _0x442a48[_0x32e624(0x256)](_0x39e426[_0x32e624(0x1ad)]);break;}case _0x32e624(0x122):{await _0x442a48['zadd'](_0x39e426[_0x32e624(0x1ad)],_0x39e426['score'],_0x39e426['member']),_0x523b5b={'ok':!![]};break;}case _0x32e624(0x21b):{const _0x40ad06=_0x39e426[_0x32e624(0x251)]||{};for(const [_0x46a799,_0x1c3318]of Object[_0x32e624(0x1f5)](_0x40ad06)){await _0x442a48['hset'](_0x39e426['key'],_0x46a799,typeof _0x1c3318==='string'?_0x1c3318:JSON['stringify'](_0x1c3318));}_0x523b5b={'ok':!![]};break;}default:throw new Error(_0x32e624(0x186)+_0x135a3b);}return{'raw':_0x523b5b,'mapped':_0x523b5b};}finally{await _0x442a48['quit']();}}catch(_0x452edd){if(_0x452edd[_0x32e624(0x1f6)]===_0x32e624(0x1e3)||_0x452edd['message']?.[_0x32e624(0x17e)]('ioredis'))throw new Error(_0x32e624(0x21c));throw _0x452edd;}throw new Error(_0x32e624(0x27b)+_0xb4454a);}function bearerExpiresAtFromExpiresIn(_0xe1d89d){const _0xbd6de4=_0x5e9ab1;if(typeof _0xe1d89d==='string'){const _0x2b8d81=_0xe1d89d['match'](/^(\d+)([smhd])$/);if(_0x2b8d81){const value=parseInt(_0x2b8d81[0x1],0xa),_0x39aa4c=_0x2b8d81[0x2],_0x12e9df={'s':0x3e8,'m':0x3c*0x3e8,'h':0x3c*0x3c*0x3e8,'d':0x18*0x3c*0x3c*0x3e8};return Date[_0xbd6de4(0x23a)]()+value*(_0x12e9df[_0x39aa4c]||0x3e8);}return null;}if(typeof _0xe1d89d===_0xbd6de4(0x1df))return Date[_0xbd6de4(0x23a)]()+_0xe1d89d*0x3e8;return null;}async function executeAuthConnector(_0x53cefa,_0x35a6dd,_0x19801b,_0x542a98){const _0xc087a9=_0x5e9ab1,_0x47b458=_0x53cefa[_0xc087a9(0x1ed)]?.['split']('.')[0x0]||'bearer',_0x590d07=_0x19801b[_0xc087a9(0x235)]||_0x19801b,_0x3f6c11=_0x542a98[_0xc087a9(0x27c)]?.[_0xc087a9(0x139)]?.['replace'](/^Bearer\s+/i,''),_0x226631=_0x590d07[_0xc087a9(0x236)]??_0x3f6c11??_0x542a98[_0xc087a9(0x236)],_0x5bee2e=_0x35a6dd['split']('.')[_0xc087a9(0x16f)]()||'validate',_0x2f44cc=_0x5bee2e['toLowerCase']();if(_0x47b458==='bearer'){if(_0x2f44cc===_0xc087a9(0x104)){const _0x19c188=_0x590d07[_0xc087a9(0x1ff)]||_0xc087a9(0x28e),_0x114f4b=_0x590d07['prefix']??_0xc087a9(0x162),_0x135046=_0x590d07['token_secret']??_0x590d07['tokenSecret'];if(_0x135046){const _0x504a7d=_0x590d07['payload']??_0x542a98?.['payload']??{},_0x4cb68c=_0x590d07[_0xc087a9(0x1c9)]??_0x590d07[_0xc087a9(0x249)]??_0x542a98?.[_0xc087a9(0x249)]??'1h',_0x206d73={'sub':_0x504a7d?.[_0xc087a9(0x259)]??_0x504a7d?.['id']??_0xc087a9(0x204),'iat':Math[_0xc087a9(0x1d7)](Date['now']()/0x3e8),..._0x504a7d};try{const _0x1bbb2d=typeof _0x4cb68c==='number'?{'expiresIn':_0x4cb68c}:{'expiresIn':String(_0x4cb68c)},_0x3c6757=jsonwebtoken_1[_0xc087a9(0x1e4)][_0xc087a9(0x11f)](_0x206d73,_0x135046,_0x1bbb2d),_0xc7d63=bearerExpiresAtFromExpiresIn(typeof _0x4cb68c===_0xc087a9(0x1df)?_0x4cb68c:String(_0x4cb68c)),_0x54336e=_0xc7d63!=null?new Date(_0xc7d63)[_0xc087a9(0x1e8)]():null;return{'ok':!![],'valid':!![],'token':_0x3c6757,'token_type':_0xc087a9(0x274),'expires_in':_0x4cb68c,'expires_at':_0x54336e,'payload':_0x206d73,'formatted_token':''+_0x114f4b+_0x3c6757,'auth':{'type':_0xc087a9(0x16d),'header_name':_0x19c188,'prefix':_0x114f4b,'value':''+_0x114f4b+_0x3c6757}};}catch(_0x5600a7){return{'ok':![],'valid':![],'error':_0x5600a7?.[_0xc087a9(0x157)]||_0xc087a9(0x15e),'message':_0xc087a9(0x15e)};}}const _0x408dfd=_0x590d07['token']??_0x226631;if(!_0x408dfd)return{'valid':![],'ok':![],'error':'Bearer\x20token\x20not\x20provided','message':'Token\x20is\x20required'};const _0x594b35=_0x590d07[_0xc087a9(0x1c9)]??null;return{'ok':!![],'valid':!![],'token':_0x408dfd,'auth':{'type':_0xc087a9(0x16d),'header_name':_0x19c188,'prefix':_0x114f4b,'value':''+_0x114f4b+_0x408dfd,..._0x594b35!=null?{'expires_in':_0x594b35}:{}}};}if(_0x2f44cc===_0xc087a9(0x142)){if(!_0x226631)return{'valid':![],'ok':![],'error':_0xc087a9(0x1e0),'message':'Token\x20is\x20required'};const _0x463d82=_0x590d07[_0xc087a9(0x13d)]??_0x590d07[_0xc087a9(0x216)];if(_0x463d82)try{const _0x3f0d3a=jsonwebtoken_1[_0xc087a9(0x1e4)][_0xc087a9(0x20b)](_0x226631,_0x463d82);return{'valid':!![],'ok':!![],'token':_0x226631,'decoded':_0x3f0d3a,'payload':_0x3f0d3a,'message':_0xc087a9(0x181)};}catch(_0x976767){let _0x5458d2=null;try{_0x5458d2=jsonwebtoken_1['default'][_0xc087a9(0x27f)](_0x226631,{'complete':![]});}catch{}return{'valid':![],'ok':![],'token':null,'decoded':_0x5458d2,'payload':_0x5458d2,'error':_0x976767?.['message']||'Token\x20validation\x20failed','message':_0xc087a9(0x22e)};}const requiredPrefix=_0x590d07[_0xc087a9(0x1ca)],_0x49f52f=_0x542a98[_0xc087a9(0x27c)]?.[_0xc087a9(0x139)]||'';if(requiredPrefix&&_0x49f52f&&!_0x49f52f[_0xc087a9(0x293)](requiredPrefix))return{'valid':![],'ok':![],'token':_0x226631,'error':'Bearer\x20token\x20prefix\x20mismatch'};return{'valid':!![],'ok':!![],'token':_0x226631,'message':_0xc087a9(0x246)};}}if(_0x47b458==='api_key'){const _0x47c3c7=_0x590d07[_0xc087a9(0x113)]||'x-api-key',_0x6d6e7d=_0x542a98[_0xc087a9(0x27c)]?.[_0x47c3c7]??_0x542a98[_0xc087a9(0x27c)]?.[_0xc087a9(0x292)],_0x1a3c53=_0x542a98[_0xc087a9(0x11e)]?.[_0x47c3c7]??_0x542a98[_0xc087a9(0x21e)]?.[_0x47c3c7],_0x14fe23=_0x590d07[_0xc087a9(0x21d)]??_0x590d07['token']??_0x6d6e7d??_0x1a3c53??_0x226631;if(_0x2f44cc===_0xc087a9(0x104)){if(!_0x14fe23)return{'valid':![],'ok':![],'error':_0xc087a9(0x126)};const _0x316619=_0x590d07['in']||_0xc087a9(0x12b),_0x5cc515=_0x590d07[_0xc087a9(0x18b)]||'';return{'valid':!![],'ok':!![],'token':_0x14fe23,'auth':{'type':_0xc087a9(0x21d),'in':_0x316619,'name':_0x47c3c7,'value':''+_0x5cc515+_0x14fe23}};}if(!_0x14fe23)return{'valid':![],'ok':![],'error':'API\x20key\x20not\x20provided'};return{'valid':!![],'ok':!![],'token':_0x14fe23,'name':_0x47c3c7};}if(_0x47b458==='basic'){const _0x52f753=_0x590d07[_0xc087a9(0x22a)]??_0x590d07[_0xc087a9(0x1bc)],_0x590936=_0x590d07[_0xc087a9(0x19c)];if(_0x2f44cc===_0xc087a9(0x104)){if(!_0x52f753||!_0x590936)return{'valid':![],'ok':![],'error':_0xc087a9(0x175)};const value=_0xc087a9(0x283)+Buffer[_0xc087a9(0x27e)](_0x52f753+':'+_0x590936)[_0xc087a9(0x22d)]('base64');return{'valid':!![],'ok':!![],'auth':{'type':_0xc087a9(0x1ac),'username':_0x52f753,'value':value}};}const _0x4a1393=_0x590d07['expected_username']??_0x590d07['username'],_0x6b1780=_0x590d07[_0xc087a9(0x280)]??_0x590d07[_0xc087a9(0x19c)],_0x1808d5=_0x542a98['headers']?.[_0xc087a9(0x139)]||'';let _0x53b7df=_0x590d07[_0xc087a9(0x22a)],_0x2be6c3=_0x590d07['password'];if((!_0x53b7df||!_0x2be6c3)&&_0x1808d5[_0xc087a9(0x293)]('Basic\x20'))try{const _0x9350f=Buffer[_0xc087a9(0x27e)](_0x1808d5[_0xc087a9(0x271)](/^Basic\s+/i,''),_0xc087a9(0x26a))[_0xc087a9(0x22d)](_0xc087a9(0x291)),_0x196af8=_0x9350f[_0xc087a9(0x145)](':');_0x53b7df=_0x53b7df??_0x196af8[0x0],_0x2be6c3=_0x2be6c3??_0x196af8['slice'](0x1)[_0xc087a9(0x1a4)](':');}catch{}if(_0x4a1393&&_0x6b1780){const _0x1dc828=_0x53b7df===_0x4a1393&&_0x2be6c3===_0x6b1780;return{'valid':_0x1dc828,'ok':_0x1dc828,'username':_0x53b7df};}const _0x56403d=Boolean(_0x53b7df&&_0x2be6c3);return{'valid':_0x56403d,'ok':_0x56403d,'username':_0x53b7df};}if(_0x47b458===_0xc087a9(0x167)){const _0x29df7f=_0x590d07[_0xc087a9(0x27c)]||{};if(_0x2f44cc===_0xc087a9(0x104))return{'valid':!![],'ok':!![],'auth':{'type':_0xc087a9(0x167),'headers':_0x29df7f}};const requiredHeaders=Array[_0xc087a9(0x1c4)](_0x590d07['required_headers'])?_0x590d07['required_headers']:Object[_0xc087a9(0x1f8)](_0x29df7f),_0x1d5ef7=_0x542a98[_0xc087a9(0x27c)]||{},_0x58af3b=requiredHeaders[_0xc087a9(0x233)](_0x34368d=>_0x1d5ef7[_0x34368d]==null);if(_0x58af3b['length']>0x0)return{'valid':![],'ok':![],'error':'Missing\x20required\x20headers:\x20'+_0x58af3b[_0xc087a9(0x1a4)](',\x20')};return{'valid':!![],'ok':!![]};}return{'valid':!![],'ok':!![]};}function areDeepEqual(_0x3512c3,_0x5495ed,_0x3db91a){const _0x231e27=_0x5e9ab1;if(_0x3512c3===_0x5495ed)return!![];if(_0x3512c3==null||_0x5495ed==null)return![];if(typeof _0x3512c3!==typeof _0x5495ed)return![];if(Array[_0x231e27(0x1c4)](_0x3512c3)&&Array[_0x231e27(0x1c4)](_0x5495ed)){if(_0x3512c3[_0x231e27(0x19e)]!==_0x5495ed[_0x231e27(0x19e)])return![];for(let _0x2f1bdc=0x0;_0x2f1bdc<_0x3512c3['length'];_0x2f1bdc++){if(!areDeepEqual(_0x3512c3[_0x2f1bdc],_0x5495ed[_0x2f1bdc],_0x3db91a))return![];}return!![];}if(typeof _0x3512c3===_0x231e27(0x125)){const _0x42f4ec=Object[_0x231e27(0x1f8)](_0x3512c3)[_0x231e27(0x233)](_0x537b41=>!_0x3db91a?.[_0x231e27(0x17e)](_0x537b41)),_0x1f2104=Object['keys'](_0x5495ed)[_0x231e27(0x233)](_0x428bde=>!_0x3db91a?.['includes'](_0x428bde));if(_0x42f4ec[_0x231e27(0x19e)]!==_0x1f2104[_0x231e27(0x19e)])return![];for(const _0x18e3a4 of _0x42f4ec){if(!_0x1f2104[_0x231e27(0x17e)](_0x18e3a4))return![];if(!areDeepEqual(_0x3512c3[_0x18e3a4],_0x5495ed[_0x18e3a4],_0x3db91a))return![];}return!![];}return![];}function levenshteinDistance(_0x4c860a,_0x250d2a){const _0x595e12=_0x5e9ab1,_0x3914af=[];for(let _0x5c3311=0x0;_0x5c3311<=_0x250d2a[_0x595e12(0x19e)];_0x5c3311++)_0x3914af[_0x5c3311]=[_0x5c3311];for(let _0x29aa27=0x0;_0x29aa27<=_0x4c860a[_0x595e12(0x19e)];_0x29aa27++)_0x3914af[0x0][_0x29aa27]=_0x29aa27;for(let _0x209150=0x1;_0x209150<=_0x250d2a[_0x595e12(0x19e)];_0x209150++){for(let _0x384d67=0x1;_0x384d67<=_0x4c860a['length'];_0x384d67++){_0x250d2a[_0x595e12(0x1ea)](_0x209150-0x1)===_0x4c860a[_0x595e12(0x1ea)](_0x384d67-0x1)?_0x3914af[_0x209150][_0x384d67]=_0x3914af[_0x209150-0x1][_0x384d67-0x1]:_0x3914af[_0x209150][_0x384d67]=Math[_0x595e12(0x250)](_0x3914af[_0x209150-0x1][_0x384d67-0x1]+0x1,_0x3914af[_0x209150][_0x384d67-0x1]+0x1,_0x3914af[_0x209150-0x1][_0x384d67]+0x1);}}return _0x3914af[_0x250d2a['length']][_0x4c860a[_0x595e12(0x19e)]];}function levenshteinSimilarity(_0x38d77c,_0x3b9cc8){const _0x23a30c=_0x5e9ab1,_0x5d4050=Math['max'](_0x38d77c[_0x23a30c(0x19e)],_0x3b9cc8[_0x23a30c(0x19e)]);if(_0x5d4050===0x0)return 0x1;return 0x1-levenshteinDistance(_0x38d77c,_0x3b9cc8)/_0x5d4050;}function executeCompare(_0x204ab6,_0x31c34e){const _0x246596=_0x5e9ab1;switch(_0x31c34e){case _0x246596(0x12d):{const {object1:_0x5436ab,object2:_0x30ba59,deep:deep=!![],ignore_keys:ignore_keys=[],include_added:include_added=!![],include_removed:include_removed=!![],include_changed:include_changed=!![]}=_0x204ab6;if(!_0x5436ab||!_0x30ba59)throw new Error(_0x246596(0x230));const _0x607e6a={},_0x4fac0c=new Set([...Object['keys'](_0x5436ab),...Object[_0x246596(0x1f8)](_0x30ba59)]);for(const _0x136f53 of _0x4fac0c){if(ignore_keys['includes'](_0x136f53))continue;const _0x1e54f3=_0x5436ab[_0x136f53],_0x4aa794=_0x30ba59[_0x136f53],_0x465ff8=_0x136f53 in _0x5436ab,_0x477210=_0x136f53 in _0x30ba59;if(!_0x465ff8&&_0x477210&&include_added)_0x607e6a[_0x136f53]={'type':_0x246596(0x19a),'value':_0x4aa794};else{if(_0x465ff8&&!_0x477210&&include_removed)_0x607e6a[_0x136f53]={'type':_0x246596(0x200),'value':_0x1e54f3};else{if(_0x465ff8&&_0x477210&&include_changed){const _0x4b394f=deep?!areDeepEqual(_0x1e54f3,_0x4aa794,ignore_keys):_0x1e54f3!==_0x4aa794;if(_0x4b394f)_0x607e6a[_0x136f53]={'type':_0x246596(0x120),'old':_0x1e54f3,'new':_0x4aa794};}}}}return{'diff':_0x607e6a,'has_changes':Object[_0x246596(0x1f8)](_0x607e6a)['length']>0x0};}case _0x246596(0x124):{const {array1:_0x12b623,array2:_0xf94adf,compare_order:compare_order=![],deep:deep=!![],include_added:include_added=!![],include_removed:include_removed=!![],include_changed:include_changed=!![]}=_0x204ab6;if(!Array['isArray'](_0x12b623)||!Array[_0x246596(0x1c4)](_0xf94adf))throw new Error(_0x246596(0x1da));const _0x44b163={'added':[],'removed':[],'changed':[]};if(compare_order){const _0x4c13e6=Math[_0x246596(0x269)](_0x12b623['length'],_0xf94adf[_0x246596(0x19e)]);for(let _0x3b0fe5=0x0;_0x3b0fe5<_0x4c13e6;_0x3b0fe5++){if(_0x3b0fe5>=_0x12b623[_0x246596(0x19e)]&&include_added)_0x44b163['added'][_0x246596(0x1fd)]({'index':_0x3b0fe5,'value':_0xf94adf[_0x3b0fe5]});else{if(_0x3b0fe5>=_0xf94adf['length']&&include_removed)_0x44b163['removed'][_0x246596(0x1fd)]({'index':_0x3b0fe5,'value':_0x12b623[_0x3b0fe5]});else{if(include_changed){const _0x292536=deep?!areDeepEqual(_0x12b623[_0x3b0fe5],_0xf94adf[_0x3b0fe5]):_0x12b623[_0x3b0fe5]!==_0xf94adf[_0x3b0fe5];if(_0x292536)_0x44b163['changed'][_0x246596(0x1fd)]({'index':_0x3b0fe5,'old':_0x12b623[_0x3b0fe5],'new':_0xf94adf[_0x3b0fe5]});}}}}}else{for(const _0x4893ad of _0xf94adf){if(!_0x12b623[_0x246596(0x150)](_0x3ecb53=>deep?areDeepEqual(_0x3ecb53,_0x4893ad):_0x3ecb53===_0x4893ad)&&include_added)_0x44b163[_0x246596(0x19a)]['push']({'value':_0x4893ad});}for(const _0x24375a of _0x12b623){if(!_0xf94adf[_0x246596(0x150)](_0x222b3c=>deep?areDeepEqual(_0x222b3c,_0x24375a):_0x222b3c===_0x24375a)&&include_removed)_0x44b163[_0x246596(0x200)][_0x246596(0x1fd)]({'value':_0x24375a});}}return{'diff':_0x44b163,'has_changes':_0x44b163[_0x246596(0x19a)]['length']>0x0||_0x44b163[_0x246596(0x200)]['length']>0x0||_0x44b163[_0x246596(0x120)][_0x246596(0x19e)]>0x0};}case _0x246596(0x112):{const {string1:_0x547575,string2:_0x43972c,case_sensitive:case_sensitive=!![],trim:trim=![],method:method=_0x246596(0x107)}=_0x204ab6;if(_0x547575===undefined||_0x43972c===undefined)throw new Error('Both\x20strings\x20are\x20required');let _0x2bfd56=String(_0x547575),_0x154d16=String(_0x43972c);trim&&(_0x2bfd56=_0x2bfd56[_0x246596(0x217)](),_0x154d16=_0x154d16[_0x246596(0x217)]());!case_sensitive&&(_0x2bfd56=_0x2bfd56[_0x246596(0x1a5)](),_0x154d16=_0x154d16['toLowerCase']());if(method===_0x246596(0x107))return{'equal':_0x2bfd56===_0x154d16,'similarity':_0x2bfd56===_0x154d16?0x1:0x0};if(method===_0x246596(0x1ae))return{'contains':_0x2bfd56['includes'](_0x154d16)||_0x154d16[_0x246596(0x17e)](_0x2bfd56)};if(method==='similarity')return{'similarity':levenshteinSimilarity(_0x2bfd56,_0x154d16)};return{'equal':_0x2bfd56===_0x154d16};}case'compare_numbers':{const {number1:_0x576560,number2:_0x3ed720,tolerance:tolerance=0x0,operator:operator='=='}=_0x204ab6;if(_0x576560===undefined||_0x3ed720===undefined)throw new Error(_0x246596(0x23b));const _0x357200=Number(_0x576560),_0x4bd0f8=Number(_0x3ed720),_0x7975e8=Math[_0x246596(0x15f)](_0x357200-_0x4bd0f8);let _0x26dcfe=![];if(operator==='==')_0x26dcfe=_0x7975e8<=tolerance;else{if(operator==='!=')_0x26dcfe=_0x7975e8>tolerance;else{if(operator==='>')_0x26dcfe=_0x357200>_0x4bd0f8;else{if(operator==='>=')_0x26dcfe=_0x357200>=_0x4bd0f8;else{if(operator==='<')_0x26dcfe=_0x357200<_0x4bd0f8;else{if(operator==='<=')_0x26dcfe=_0x357200<=_0x4bd0f8;}}}}}return{'result':_0x26dcfe,'difference':_0x7975e8};}case _0x246596(0x1a7):{const {date1:_0x3b0a3c,date2:_0x5830e8,operator:operator='==',tolerance_seconds:tolerance_seconds=0x0}=_0x204ab6;if(!_0x3b0a3c||!_0x5830e8)throw new Error(_0x246596(0x220));const _0x6bc7bf=new Date(_0x3b0a3c)['getTime'](),_0x599e71=new Date(_0x5830e8)[_0x246596(0x1fe)](),_0x1262bc=Math[_0x246596(0x15f)](_0x6bc7bf-_0x599e71)/0x3e8;let _0x4afc94=![];if(operator==='==')_0x4afc94=_0x1262bc<=tolerance_seconds;else{if(operator==='!=')_0x4afc94=_0x1262bc>tolerance_seconds;else{if(operator==='>')_0x4afc94=_0x6bc7bf>_0x599e71;else{if(operator==='>=')_0x4afc94=_0x6bc7bf>=_0x599e71;else{if(operator==='<')_0x4afc94=_0x6bc7bf<_0x599e71;else{if(operator==='<=')_0x4afc94=_0x6bc7bf<=_0x599e71;}}}}}return{'result':_0x4afc94,'difference_seconds':_0x1262bc};}case _0x246596(0x1aa):{const {value1:value1,value2:value2,deep:deep=!![],ignore_keys:ignore_keys=[]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error(_0x246596(0x17f));return{'changed':deep?!areDeepEqual(value1,value2,ignore_keys):value1!==value2};}case _0x246596(0x1d0):{const {value1:value1,value2:value2,deep:deep=!![],strict:strict=!![],ignore_keys:ignore_keys=[]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error(_0x246596(0x17f));if(strict&&!deep)return{'equal':value1===value2};return{'equal':deep?areDeepEqual(value1,value2,ignore_keys):value1==value2};}case'is_not_equal':{const {value1:value1,value2:value2,deep:deep=!![],strict:strict=!![],ignore_keys:ignore_keys=[]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error(_0x246596(0x17f));if(strict&&!deep)return{'not_equal':value1!==value2};const _0x1a5e09=deep?areDeepEqual(value1,value2,ignore_keys):value1==value2;return{'not_equal':!_0x1a5e09};}case _0x246596(0x11a):{const {value1:value1,value2:value2,or_equal:or_equal=![]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error(_0x246596(0x17f));return{'result':or_equal?value1>=value2:value1>value2};}case'is_less_than':{const {value1:value1,value2:value2,or_equal:or_equal=![]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error(_0x246596(0x17f));return{'result':or_equal?value1<=value2:value1<value2};}case'is_between':{const {value:value,min:_0x59512c,max:_0x3a2c76,inclusive:inclusive=!![]}=_0x204ab6;if(value===undefined||_0x59512c===undefined||_0x3a2c76===undefined)throw new Error(_0x246596(0x114));return{'result':inclusive?value>=_0x59512c&&value<=_0x3a2c76:value>_0x59512c&&value<_0x3a2c76};}case _0x246596(0x128):{const {value:value,check_whitespace:check_whitespace=!![]}=_0x204ab6;if(value===undefined)throw new Error(_0x246596(0x1c5));if(value==null)return{'empty':!![]};if(Array[_0x246596(0x1c4)](value))return{'empty':value['length']===0x0};if(typeof value===_0x246596(0x125))return{'empty':Object[_0x246596(0x1f8)](value)[_0x246596(0x19e)]===0x0};if(typeof value==='string')return{'empty':check_whitespace?value[_0x246596(0x217)]()[_0x246596(0x19e)]===0x0:value[_0x246596(0x19e)]===0x0};return{'empty':![]};}case'is_null_or_undefined':return{'is_null_or_undefined':_0x204ab6['value']==null};case _0x246596(0x214):{const {value1:value1,value2:value2}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error('Both\x20values\x20are\x20required');return{'same_type':typeof value1===typeof value2};}case _0x246596(0x16a):{const {value1:value1,value2:value2,ignore_keys:ignore_keys=[],ignore_order:ignore_order=![]}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error('Both\x20values\x20are\x20required');if(ignore_order&&Array['isArray'](value1)&&Array[_0x246596(0x1c4)](value2)){if(value1[_0x246596(0x19e)]!==value2[_0x246596(0x19e)])return{'equal':![]};const _0x256a6d=[...value1][_0x246596(0x10a)](),_0x1e2321=[...value2][_0x246596(0x10a)]();return{'equal':areDeepEqual(_0x256a6d,_0x1e2321,ignore_keys)};}return{'equal':areDeepEqual(value1,value2,ignore_keys)};}case'shallow_equal':{const {value1:value1,value2:value2}=_0x204ab6;if(value1===undefined||value2===undefined)throw new Error('Both\x20values\x20are\x20required');return{'equal':value1===value2};}case _0x246596(0x215):{const {string1:_0x35f3d2,string2:_0x58b28b,case_sensitive:case_sensitive=![]}=_0x204ab6;if(!_0x35f3d2||!_0x58b28b)throw new Error(_0x246596(0x277));const _0x4439f7=case_sensitive?_0x35f3d2:String(_0x35f3d2)[_0x246596(0x1a5)](),_0x1ae9f9=case_sensitive?_0x58b28b:String(_0x58b28b)['toLowerCase']();return{'similarity':levenshteinSimilarity(_0x4439f7,_0x1ae9f9)};}case _0x246596(0x1be):{const {array1:_0x4ded40,array2:_0x514646,deep:deep=![],unique:unique=!![]}=_0x204ab6;if(!Array[_0x246596(0x1c4)](_0x4ded40)||!Array[_0x246596(0x1c4)](_0x514646))throw new Error(_0x246596(0x1da));const _0x4c9630=[];for(const _0x56b1bc of _0x4ded40){if(_0x514646[_0x246596(0x150)](_0x4faf86=>deep?areDeepEqual(_0x56b1bc,_0x4faf86):_0x56b1bc===_0x4faf86)){if(unique&&!_0x4c9630['some'](_0x280791=>deep?areDeepEqual(_0x280791,_0x56b1bc):_0x280791===_0x56b1bc))_0x4c9630['push'](_0x56b1bc);else{if(!unique)_0x4c9630['push'](_0x56b1bc);}}}return{'intersection':_0x4c9630};}case _0x246596(0x17b):{const {array1:_0x52353c,array2:_0x34fee4,deep:deep=![]}=_0x204ab6;if(!Array[_0x246596(0x1c4)](_0x52353c)||!Array['isArray'](_0x34fee4))throw new Error(_0x246596(0x1da));const _0xe8061c=[..._0x52353c];for(const _0x134ee6 of _0x34fee4){if(!_0xe8061c['some'](_0x5fcd10=>deep?areDeepEqual(_0x5fcd10,_0x134ee6):_0x5fcd10===_0x134ee6))_0xe8061c['push'](_0x134ee6);}return{'union':_0xe8061c};}case'array_difference':{const {array1:_0x278551,array2:_0x2202e3,deep:deep=![]}=_0x204ab6;if(!Array[_0x246596(0x1c4)](_0x278551)||!Array['isArray'](_0x2202e3))throw new Error(_0x246596(0x1da));const _0x113d09=[];for(const _0xe6e83a of _0x278551){if(!_0x2202e3[_0x246596(0x150)](_0x142053=>deep?areDeepEqual(_0xe6e83a,_0x142053):_0xe6e83a===_0x142053))_0x113d09[_0x246596(0x1fd)](_0xe6e83a);}return{'difference':_0x113d09};}default:throw new Error(_0x246596(0x18a)+_0x31c34e);}}function executeGeo(_0x19f78c,_0x25aca9){const _0xc070d8=_0x5e9ab1,_0x8177da=_0x11dd27=>_0x11dd27*Math['PI']/0xb4,_0x31d93a=(_0x5077ca,_0x209f9c,_0x13273e,_0x1c03a1)=>{const _0x13d54c=_0x6af2,_0x3944b3=0x18e3,_0x1e84d3=_0x8177da(_0x13273e-_0x5077ca),_0x381766=_0x8177da(_0x1c03a1-_0x209f9c),_0x1f165b=Math['sin'](_0x1e84d3/0x2)*Math[_0x13d54c(0x1e6)](_0x1e84d3/0x2)+Math[_0x13d54c(0x206)](_0x8177da(_0x5077ca))*Math[_0x13d54c(0x206)](_0x8177da(_0x13273e))*Math['sin'](_0x381766/0x2)*Math[_0x13d54c(0x1e6)](_0x381766/0x2),_0x55ffa1=0x2*Math[_0x13d54c(0x176)](Math[_0x13d54c(0x22c)](_0x1f165b),Math['sqrt'](0x1-_0x1f165b));return _0x3944b3*_0x55ffa1;},_0x48edb4=(_0x4d31ae,_0x510f9c,_0x2afe9e,_0x47ae2c)=>{const _0x20a35d=_0x6af2,_0x5c785e=0x18e3,_0x299c59=_0x8177da(_0x2afe9e-_0x4d31ae),_0x383d3e=_0x8177da(_0x47ae2c-_0x510f9c),_0x571bcc=_0x8177da((_0x4d31ae+_0x2afe9e)/0x2),_0x3e2561=_0x383d3e*Math['cos'](_0x571bcc),_0x588788=_0x299c59;return _0x5c785e*Math[_0x20a35d(0x22c)](_0x3e2561*_0x3e2561+_0x588788*_0x588788);},_0x595b29={'km':0x1,'miles':0.621371,'meters':0x3e8,'feet':3280.84,'nautical_miles':0.539957};switch(_0x25aca9){case _0xc070d8(0x1d9):{const {lat1:_0x321c7d,lon1:_0x16bb24,lat2:_0x5c63f4,lon2:_0x1e72df,unit:unit='km',formula:formula='haversine'}=_0x19f78c;if(_0x321c7d===undefined||_0x16bb24===undefined||_0x5c63f4===undefined||_0x1e72df===undefined)throw new Error(_0xc070d8(0x116));const _0xc2249=formula==='equirectangular'?_0x48edb4(_0x321c7d,_0x16bb24,_0x5c63f4,_0x1e72df):_0x31d93a(_0x321c7d,_0x16bb24,_0x5c63f4,_0x1e72df);return{'distance':_0xc2249*(_0x595b29[unit]||0x1),'unit':unit};}case _0xc070d8(0x147):{const {point_lat:_0x5d6579,point_lon:_0x5c6081,polygon:_0x4ee5d1,format:format=_0xc070d8(0x110)}=_0x19f78c;if(_0x5d6579===undefined||_0x5c6081===undefined||!Array[_0xc070d8(0x1c4)](_0x4ee5d1))throw new Error(_0xc070d8(0x1c6));const _0x3304e8=_0x4ee5d1[_0xc070d8(0x136)](_0x1f1571=>{const _0x200c3b=_0xc070d8;if(format===_0x200c3b(0x268)||format===_0x200c3b(0x238))return[_0x1f1571[0x1],_0x1f1571[0x0]];return _0x1f1571;});let _0x3aae41=![];for(let _0x2b989d=0x0,_0x46b45a=_0x3304e8[_0xc070d8(0x19e)]-0x1;_0x2b989d<_0x3304e8['length'];_0x46b45a=_0x2b989d++){const [_0x4643cb,_0x2e1787]=_0x3304e8[_0x2b989d],[_0x5f05a2,_0x571158]=_0x3304e8[_0x46b45a],_0x9c6c56=_0x2e1787>_0x5d6579!==_0x571158>_0x5d6579&&_0x5c6081<(_0x5f05a2-_0x4643cb)*(_0x5d6579-_0x2e1787)/(_0x571158-_0x2e1787)+_0x4643cb;if(_0x9c6c56)_0x3aae41=!_0x3aae41;}return{'inside':_0x3aae41};}case'get_bounding_box':{const {points:_0x9eda54,format:format='lat_lon',padding:padding=0x0,output_format:output_format=_0xc070d8(0x12e)}=_0x19f78c;if(!Array['isArray'](_0x9eda54)||_0x9eda54[_0xc070d8(0x19e)]===0x0)throw new Error(_0xc070d8(0x222));const _0x405138=_0x9eda54[_0xc070d8(0x136)](_0x1483d3=>format==='lon_lat'?[_0x1483d3[0x1],_0x1483d3[0x0]]:_0x1483d3);let _0x35ac28=_0x405138[0x0][0x0],_0x389bb2=_0x405138[0x0][0x0],_0x256035=_0x405138[0x0][0x1],_0x1e78ae=_0x405138[0x0][0x1];for(const [_0xc15013,_0x42e337]of _0x405138){_0x35ac28=Math[_0xc070d8(0x250)](_0x35ac28,_0xc15013),_0x389bb2=Math[_0xc070d8(0x269)](_0x389bb2,_0xc15013),_0x256035=Math[_0xc070d8(0x250)](_0x256035,_0x42e337),_0x1e78ae=Math[_0xc070d8(0x269)](_0x1e78ae,_0x42e337);}_0x35ac28-=padding,_0x389bb2+=padding,_0x256035-=padding,_0x1e78ae+=padding;if(output_format==='bounds')return{'north':_0x389bb2,'south':_0x35ac28,'east':_0x1e78ae,'west':_0x256035};if(output_format==='corners')return{'corners':[[_0x35ac28,_0x256035],[_0x35ac28,_0x1e78ae],[_0x389bb2,_0x1e78ae],[_0x389bb2,_0x256035]]};return{'type':'Polygon','coordinates':[[[_0x256035,_0x35ac28],[_0x1e78ae,_0x35ac28],[_0x1e78ae,_0x389bb2],[_0x256035,_0x389bb2],[_0x256035,_0x35ac28]]]};}case'reverse_geocode':{const {lat:_0x1a2791,lon:_0x939720,provider:provider=_0xc070d8(0x131)}=_0x19f78c;if(_0x1a2791===undefined||_0x939720===undefined)throw new Error(_0xc070d8(0x1c0));return{'address':_0xc070d8(0x26b)+_0x1a2791+',\x20'+_0x939720,'lat':_0x1a2791,'lon':_0x939720,'provider':provider};}case _0xc070d8(0x164):{const {address:_0x572604,provider:provider=_0xc070d8(0x131),limit:limit=0x1}=_0x19f78c;if(!_0x572604)throw new Error(_0xc070d8(0x273));return{'results':[{'address':_0x572604,'lat':0x0,'lon':0x0,'provider':provider}],'count':0x1};}case'convert_coordinates':{const {lat:_0x4d753d,lon:_0x5d4cda,from_format:from_format=_0xc070d8(0x10c),to_format:to_format=_0xc070d8(0x10c),precision:precision=0x6}=_0x19f78c;if(_0x4d753d===undefined||_0x5d4cda===undefined)throw new Error(_0xc070d8(0x1c0));if(from_format===_0xc070d8(0x10c)&&to_format==='decimal')return{'lat':parseFloat(Number(_0x4d753d)[_0xc070d8(0x294)](precision)),'lon':parseFloat(Number(_0x5d4cda)[_0xc070d8(0x294)](precision))};return{'lat':_0x4d753d,'lon':_0x5d4cda,'from_format':from_format,'to_format':to_format,'note':'Advanced\x20conversions\x20require\x20additional\x20implementation'};}default:throw new Error(_0xc070d8(0x218)+_0x25aca9);}}async function executeDateTime(_0x3bd762,_0x3cdf25){const _0x3fa5a2=_0x5e9ab1,_0x23a860=(await Promise['resolve']()[_0x3fa5a2(0x14b)](()=>__importStar(require('dayjs'))))[_0x3fa5a2(0x1e4)],_0xe15831=(await Promise[_0x3fa5a2(0x15c)]()[_0x3fa5a2(0x14b)](()=>__importStar(require('dayjs/plugin/utc'))))[_0x3fa5a2(0x1e4)],_0x48be8e=(await Promise[_0x3fa5a2(0x15c)]()[_0x3fa5a2(0x14b)](()=>__importStar(require(_0x3fa5a2(0x21a)))))[_0x3fa5a2(0x1e4)],_0x50564c=(await Promise[_0x3fa5a2(0x15c)]()['then'](()=>__importStar(require('dayjs/plugin/isLeapYear'))))[_0x3fa5a2(0x1e4)],_0xf19e99=(await Promise[_0x3fa5a2(0x15c)]()[_0x3fa5a2(0x14b)](()=>__importStar(require(_0x3fa5a2(0x288)))))['default'],_0x7af41b=(await Promise[_0x3fa5a2(0x15c)]()['then'](()=>__importStar(require('dayjs/plugin/customParseFormat'))))[_0x3fa5a2(0x1e4)];_0x23a860[_0x3fa5a2(0x1ec)](_0xe15831),_0x23a860[_0x3fa5a2(0x1ec)](_0x48be8e),_0x23a860['extend'](_0x50564c),_0x23a860[_0x3fa5a2(0x1ec)](_0xf19e99),_0x23a860[_0x3fa5a2(0x1ec)](_0x7af41b);switch(_0x3cdf25){case _0x3fa5a2(0x13b):{const {format:format=_0x3fa5a2(0x1a9),timezone:_0x86d451}=_0x3bd762;let _0x5b9455=_0x23a860();if(_0x86d451)_0x5b9455=_0x5b9455['tz'](_0x86d451);return{'date':_0x5b9455[_0x3fa5a2(0x252)](format)};}case _0x3fa5a2(0x1c1):{const {format:format='HH:mm:ss',timezone:_0x22f18a}=_0x3bd762;let _0x3d3420=_0x23a860();if(_0x22f18a)_0x3d3420=_0x3d3420['tz'](_0x22f18a);return{'time':_0x3d3420['format'](format)};}case _0x3fa5a2(0x168):{const {format:format=_0x3fa5a2(0x1ce),timezone:_0x163d3f}=_0x3bd762;let _0x3588cf=_0x23a860();if(_0x163d3f)_0x3588cf=_0x3588cf['tz'](_0x163d3f);return{'datetime':_0x3588cf[_0x3fa5a2(0x252)](format),'iso':_0x3588cf[_0x3fa5a2(0x1e8)]()};}case _0x3fa5a2(0x252):case _0x3fa5a2(0x26f):{const {date:_0x133e2d,format:_0x2d94c6,input_format:_0x346a92,timezone:_0x12df51}=_0x3bd762,value=_0x133e2d??_0x3bd762[_0x3fa5a2(0x267)]??new Date()[_0x3fa5a2(0x1e8)]();if(!_0x2d94c6)return{'formatted':_0x23a860(value)[_0x3fa5a2(0x1e8)]()};let _0x53a402=_0x346a92?_0x23a860(value,_0x346a92):_0x23a860(value);if(_0x12df51)_0x53a402=_0x53a402['tz'](_0x12df51);return{'formatted':_0x53a402['format'](_0x2d94c6)};}case _0x3fa5a2(0x23f):{const {date_string:_0x4cc9d4,format:_0xeb065f,timezone:_0x3933ad}=_0x3bd762;if(!_0x4cc9d4)throw new Error(_0x3fa5a2(0x188));let _0x48f1c0=_0xeb065f?_0x23a860(_0x4cc9d4,_0xeb065f):_0x23a860(_0x4cc9d4);if(_0x3933ad)_0x48f1c0=_0x48f1c0['tz'](_0x3933ad);return{'parsed':_0x48f1c0[_0x3fa5a2(0x1e8)](),'timestamp':_0x48f1c0[_0x3fa5a2(0x1c2)]()};}case _0x3fa5a2(0x171):{const {date:_0x464783,amount:_0x568dc7,unit:_0x5c0810,format:_0x141d51}=_0x3bd762;if(!_0x464783||_0x568dc7===undefined||!_0x5c0810)throw new Error(_0x3fa5a2(0x1b9));let _0x498607=_0x23a860(_0x464783)[_0x3fa5a2(0x25e)](_0x568dc7,_0x5c0810);const _0x5187e3={'result':_0x498607['toISOString']()};if(_0x141d51)_0x5187e3[_0x3fa5a2(0x196)]=_0x498607['format'](_0x141d51);return _0x5187e3;}case _0x3fa5a2(0x184):{const {date:_0xad400d,amount:_0xe2b9f7,unit:_0xc72c1e,format:_0x2faa34}=_0x3bd762;if(!_0xad400d||_0xe2b9f7===undefined||!_0xc72c1e)throw new Error('Date,\x20amount,\x20and\x20unit\x20are\x20required');let _0x19905a=_0x23a860(_0xad400d)[_0x3fa5a2(0x286)](_0xe2b9f7,_0xc72c1e);const _0x3d5735={'result':_0x19905a[_0x3fa5a2(0x1e8)]()};if(_0x2faa34)_0x3d5735[_0x3fa5a2(0x196)]=_0x19905a[_0x3fa5a2(0x252)](_0x2faa34);return _0x3d5735;}case'diff_between_dates':{const {date1:_0x2b943b,date2:_0x5f382b,unit:unit='days',absolute:absolute=![]}=_0x3bd762;if(!_0x2b943b||!_0x5f382b)throw new Error('Both\x20dates\x20are\x20required');let _0x3b6f9e=_0x23a860(_0x5f382b)['diff'](_0x23a860(_0x2b943b),unit);if(absolute)_0x3b6f9e=Math[_0x3fa5a2(0x15f)](_0x3b6f9e);return{'difference':_0x3b6f9e,'unit':unit};}case _0x3fa5a2(0x228):{const {date:_0x44e82d,format:_0x2bc11e,timezone:_0x1a73b2}=_0x3bd762;if(!_0x44e82d)throw new Error(_0x3fa5a2(0x195));let _0x5d319c=_0x23a860(_0x44e82d)['startOf'](_0x3fa5a2(0x237));if(_0x1a73b2)_0x5d319c=_0x5d319c['tz'](_0x1a73b2);const _0x1d3008={'result':_0x5d319c[_0x3fa5a2(0x1e8)]()};if(_0x2bc11e)_0x1d3008[_0x3fa5a2(0x196)]=_0x5d319c['format'](_0x2bc11e);return _0x1d3008;}case _0x3fa5a2(0x160):{const {date:_0x2d3f19,format:_0x3f4f7b,timezone:_0x1d7266}=_0x3bd762;if(!_0x2d3f19)throw new Error('Date\x20is\x20required');let _0x18ee11=_0x23a860(_0x2d3f19)[_0x3fa5a2(0x11c)](_0x3fa5a2(0x237));if(_0x1d7266)_0x18ee11=_0x18ee11['tz'](_0x1d7266);const _0x57dd4f={'result':_0x18ee11['toISOString']()};if(_0x3f4f7b)_0x57dd4f['formatted']=_0x18ee11[_0x3fa5a2(0x252)](_0x3f4f7b);return _0x57dd4f;}case'start_of_week':{const {date:_0x50941c,week_start:week_start='monday',format:_0x5a7bc4,timezone:_0x392745}=_0x3bd762;if(!_0x50941c)throw new Error('Date\x20is\x20required');let _0x2e1c4e=week_start===_0x3fa5a2(0x241)?_0x23a860(_0x50941c)[_0x3fa5a2(0x1a2)](_0x3fa5a2(0x1c3)):_0x23a860(_0x50941c)[_0x3fa5a2(0x1a2)](_0x3fa5a2(0x28a));if(_0x392745)_0x2e1c4e=_0x2e1c4e['tz'](_0x392745);const _0x40e4b5={'result':_0x2e1c4e[_0x3fa5a2(0x1e8)]()};if(_0x5a7bc4)_0x40e4b5[_0x3fa5a2(0x196)]=_0x2e1c4e[_0x3fa5a2(0x252)](_0x5a7bc4);return _0x40e4b5;}case _0x3fa5a2(0x1f1):{const {date:_0x497c7a,week_start:week_start=_0x3fa5a2(0x241),format:_0x3bc314,timezone:_0xa4659}=_0x3bd762;if(!_0x497c7a)throw new Error(_0x3fa5a2(0x195));let _0x1655b6=week_start===_0x3fa5a2(0x241)?_0x23a860(_0x497c7a)[_0x3fa5a2(0x11c)](_0x3fa5a2(0x1c3)):_0x23a860(_0x497c7a)['endOf'](_0x3fa5a2(0x28a));if(_0xa4659)_0x1655b6=_0x1655b6['tz'](_0xa4659);const _0x2a8102={'result':_0x1655b6[_0x3fa5a2(0x1e8)]()};if(_0x3bc314)_0x2a8102[_0x3fa5a2(0x196)]=_0x1655b6[_0x3fa5a2(0x252)](_0x3bc314);return _0x2a8102;}case'start_of_month':{const {date:_0x3f3bd9,format:_0xbfece5,timezone:_0x3450b3}=_0x3bd762;if(!_0x3f3bd9)throw new Error('Date\x20is\x20required');let _0xafbe0b=_0x23a860(_0x3f3bd9)[_0x3fa5a2(0x1a2)]('month');if(_0x3450b3)_0xafbe0b=_0xafbe0b['tz'](_0x3450b3);const _0x434d90={'result':_0xafbe0b['toISOString']()};if(_0xbfece5)_0x434d90['formatted']=_0xafbe0b[_0x3fa5a2(0x252)](_0xbfece5);return _0x434d90;}case _0x3fa5a2(0x1f0):{const {date:_0x4ee470,format:_0x290a85,timezone:_0x4506e7}=_0x3bd762;if(!_0x4ee470)throw new Error(_0x3fa5a2(0x195));let _0x3fd39d=_0x23a860(_0x4ee470)['endOf'](_0x3fa5a2(0x18f));if(_0x4506e7)_0x3fd39d=_0x3fd39d['tz'](_0x4506e7);const _0x4fc833={'result':_0x3fd39d[_0x3fa5a2(0x1e8)]()};if(_0x290a85)_0x4fc833['formatted']=_0x3fd39d[_0x3fa5a2(0x252)](_0x290a85);return _0x4fc833;}case _0x3fa5a2(0x1b2):{const {date:_0x35be77,format:_0x18e7db,timezone:_0x258cec}=_0x3bd762;if(!_0x35be77)throw new Error(_0x3fa5a2(0x195));let _0x2168e6=_0x23a860(_0x35be77)[_0x3fa5a2(0x1a2)]('year');if(_0x258cec)_0x2168e6=_0x2168e6['tz'](_0x258cec);const _0x65979c={'result':_0x2168e6['toISOString']()};if(_0x18e7db)_0x65979c[_0x3fa5a2(0x196)]=_0x2168e6[_0x3fa5a2(0x252)](_0x18e7db);return _0x65979c;}case _0x3fa5a2(0x143):{const {date:_0x51b2df,format:_0x10d448,timezone:_0x325aae}=_0x3bd762;if(!_0x51b2df)throw new Error(_0x3fa5a2(0x195));let _0x26625e=_0x23a860(_0x51b2df)[_0x3fa5a2(0x11c)]('year');if(_0x325aae)_0x26625e=_0x26625e['tz'](_0x325aae);const _0x301470={'result':_0x26625e[_0x3fa5a2(0x1e8)]()};if(_0x10d448)_0x301470[_0x3fa5a2(0x196)]=_0x26625e['format'](_0x10d448);return _0x301470;}case _0x3fa5a2(0x208):{const {date:_0x2b34f5,from_timezone:_0x2f6920,to_timezone:_0x27f7a3,format:_0x637848}=_0x3bd762;if(!_0x2b34f5||!_0x27f7a3)throw new Error(_0x3fa5a2(0x211));let _0x28dc56=_0x2f6920?_0x23a860['tz'](_0x2b34f5,_0x2f6920):_0x23a860(_0x2b34f5);_0x28dc56=_0x28dc56['tz'](_0x27f7a3);const _0x121de5={'result':_0x28dc56[_0x3fa5a2(0x1e8)]()};if(_0x637848)_0x121de5[_0x3fa5a2(0x196)]=_0x28dc56[_0x3fa5a2(0x252)](_0x637848);return _0x121de5;}case _0x3fa5a2(0x1e1):{const {date:_0x5bd236}=_0x3bd762,_0x26d3f7=_0x5bd236?_0x23a860(_0x5bd236):_0x23a860();return{'timezone':_0x26d3f7[_0x3fa5a2(0x252)]('z'),'offset':_0x26d3f7[_0x3fa5a2(0x281)]()};}case'list_timezones':{const {filter:_0x30be43}=_0x3bd762;let _0x20b085=_0x23a860['tz'][_0x3fa5a2(0x17a)]();if(_0x30be43)_0x20b085=_0x20b085['filter'](_0x3afbb9=>_0x3afbb9['toLowerCase']()[_0x3fa5a2(0x17e)](_0x30be43[_0x3fa5a2(0x1a5)]()));return{'timezones':_0x20b085};}case _0x3fa5a2(0x132):{const {year:_0x101e50,date:_0x37d27f}=_0x3bd762,_0x3b4dfa=_0x101e50||(_0x37d27f?_0x23a860(_0x37d27f)[_0x3fa5a2(0x1b3)]():_0x23a860()[_0x3fa5a2(0x1b3)]());return{'is_leap_year':_0x23a860()[_0x3fa5a2(0x1b3)](_0x3b4dfa)[_0x3fa5a2(0x182)](),'year':_0x3b4dfa};}case _0x3fa5a2(0x1b4):{const {date:_0x4fa67e,unit:unit=_0x3fa5a2(0x1cb)}=_0x3bd762,_0x4c529c=_0x4fa67e?_0x23a860(_0x4fa67e):_0x23a860(),_0x39839d=unit===_0x3fa5a2(0x266)?_0x4c529c[_0x3fa5a2(0x1c2)]():_0x4c529c[_0x3fa5a2(0x247)]();return{'timestamp':_0x39839d,'unit':unit};}case _0x3fa5a2(0x155):{const {timestamp:_0x3ac61e,unit:unit='seconds',format:_0x301dee,timezone:_0x30ee91}=_0x3bd762;if(_0x3ac61e===undefined)throw new Error(_0x3fa5a2(0x253));let _0x2c1936=unit===_0x3fa5a2(0x266)?_0x23a860(_0x3ac61e):_0x23a860[_0x3fa5a2(0x247)](_0x3ac61e);if(_0x30ee91)_0x2c1936=_0x2c1936['tz'](_0x30ee91);const _0xfebfff={'result':_0x2c1936[_0x3fa5a2(0x1e8)]()};if(_0x301dee)_0xfebfff[_0x3fa5a2(0x196)]=_0x2c1936['format'](_0x301dee);return _0xfebfff;}default:{const _0x19fb14=_0x23a860();return{'datetime':_0x19fb14[_0x3fa5a2(0x252)](_0x3fa5a2(0x1ce)),'iso':_0x19fb14[_0x3fa5a2(0x1e8)]()};}}}async function executeUtilityConnector(_0x27c326,_0x59bae0,_0x77adb0,_0x2f00be){const _0x6d2dcf=_0x5e9ab1,_0x32c531=_0x27c326[_0x6d2dcf(0x1ed)]?.[_0x6d2dcf(0x145)]('.')[_0x6d2dcf(0x16f)]()||_0x27c326['_id']?.[_0x6d2dcf(0x145)]('.')[0x1]||_0x6d2dcf(0x226),_0x1af67a=_0x77adb0['body']||_0x77adb0,_0x37b99c=_0x59bae0[_0x6d2dcf(0x145)]('.')[_0x6d2dcf(0x16f)]()||_0x59bae0;let _0x2f5863;if(_0x32c531===_0x6d2dcf(0x138))_0x2f5863=await executeDateTime(_0x1af67a,_0x37b99c);else{if(_0x32c531==='compare')_0x2f5863=executeCompare(_0x1af67a,_0x37b99c);else{if(_0x32c531===_0x6d2dcf(0x210))_0x2f5863=executeGeo(_0x1af67a,_0x37b99c);else{if(_0x32c531===_0x6d2dcf(0x226))_0x2f5863=(0x0,string_executor_1['executeString'])(_0x1af67a,_0x37b99c);else{if(_0x32c531===_0x6d2dcf(0x1cc))_0x2f5863=(0x0,random_executor_1[_0x6d2dcf(0x197)])(_0x1af67a,_0x37b99c);else _0x32c531===_0x6d2dcf(0x265)?_0x2f5863=(0x0,math_executor_1['executeMath'])(_0x1af67a,_0x37b99c):_0x2f5863={'value':_0x1af67a[_0x6d2dcf(0x267)]??null};}}}}const _0x21240c=_0x2f5863[_0x6d2dcf(0x267)]!==undefined?_0x2f5863[_0x6d2dcf(0x267)]:_0x2f5863[_0x6d2dcf(0x196)]!==undefined?_0x2f5863['formatted']:_0x2f5863[_0x6d2dcf(0x11b)]!==undefined?_0x2f5863[_0x6d2dcf(0x11b)]:_0x2f5863[_0x6d2dcf(0x173)]!==undefined?_0x2f5863[_0x6d2dcf(0x173)]:_0x2f5863[_0x6d2dcf(0x258)]!==undefined?_0x2f5863[_0x6d2dcf(0x258)]:_0x2f5863;return{'raw':_0x2f5863,'mapped':_0x21240c};}async function executeEncryptionConnector(_0x40fd72,_0x508c70,_0x34273a,_0x5cfcf0){const _0x8b185f=_0x5e9ab1,_0x350985=await Promise[_0x8b185f(0x15c)]()[_0x8b185f(0x14b)](()=>__importStar(require(_0x8b185f(0x1b6)))),_0x3d0665=_0x40fd72[_0x8b185f(0x1ed)]?.[_0x8b185f(0x145)]('.')[0x0]||_0x8b185f(0x26a),_0x1f1613=_0x34273a[_0x8b185f(0x235)]||_0x34273a,_0x878def=_0x1f1613['data']??_0x1f1613['value']??_0x1f1613[_0x8b185f(0x226)]??'',_0x420058=typeof _0x878def==='string'?_0x878def:JSON[_0x8b185f(0x1bd)](_0x878def);let _0x32f26c;if(_0x3d0665===_0x8b185f(0x26a)){const _0x1e0338=_0x508c70[_0x8b185f(0x145)]('.')[_0x8b185f(0x16f)]()||_0x8b185f(0x192);if(_0x1e0338==='encode'){const _0x98ac93=_0x1f1613[_0x8b185f(0x212)]??_0x878def,_0x562799=typeof _0x98ac93===_0x8b185f(0x226)?_0x98ac93:JSON['stringify'](_0x98ac93);_0x32f26c={'value':Buffer['from'](_0x562799,_0x8b185f(0x1b1))[_0x8b185f(0x22d)](_0x8b185f(0x26a))};}else{const _0x290fa8=_0x1f1613[_0x8b185f(0x13a)]??_0x1f1613['data']??_0x878def;_0x32f26c={'value':Buffer['from'](String(_0x290fa8||''),'base64')[_0x8b185f(0x22d)](_0x8b185f(0x1b1))};}}else{if(_0x3d0665===_0x8b185f(0x234)){const _0x491e08=_0x1f1613['algorithm']||(_0x508c70[_0x8b185f(0x17e)]('.')?_0x508c70[_0x8b185f(0x145)]('.')[_0x8b185f(0x16f)]():_0x8b185f(0x242))||'sha256',_0x5bbece=_0x1f1613['output_format']||'hex',_0x40e1fc=_0x350985[_0x8b185f(0x108)](_0x491e08)[_0x8b185f(0x14c)](_0x420058)['digest'](),value=_0x5bbece===_0x8b185f(0x26a)?_0x40e1fc[_0x8b185f(0x22d)](_0x8b185f(0x26a)):_0x40e1fc[_0x8b185f(0x22d)](_0x8b185f(0x22f));_0x32f26c={'value':value,'hash':value,'algorithm':_0x491e08,'output_format':_0x5bbece};}else{if(_0x3d0665===_0x8b185f(0x111))_0x32f26c=await executeAes(_0x350985,_0x508c70,_0x1f1613,_0x420058);else{if(_0x3d0665===_0x8b185f(0x1cd))_0x32f26c=await executeRsa(_0x350985,_0x508c70,_0x1f1613,_0x420058);else{if(_0x3d0665===_0x8b185f(0x1c7))_0x32f26c=await executeHmac(_0x350985,_0x508c70,_0x1f1613,_0x420058);else _0x3d0665===_0x8b185f(0x19c)?_0x32f26c=await executePassword(_0x508c70,_0x1f1613,_0x420058):_0x32f26c={'value':_0x420058};}}}}const _0x19a080=_0x32f26c[_0x8b185f(0x267)]!==undefined?_0x32f26c[_0x8b185f(0x267)]:_0x32f26c;return{'raw':_0x32f26c,'mapped':_0x19a080};}async function executeAes(_0x2f3908,_0x334544,_0x931290,_0x2de115){const _0x25fe84=_0x5e9ab1,_0x50ff53=_0x334544[_0x25fe84(0x145)]('.')[_0x25fe84(0x16f)]()||'';if(_0x50ff53===_0x25fe84(0x28c)){const _0x20e96e=_0x931290[_0x25fe84(0x1ad)];if(!_0x20e96e)throw new Error(_0x25fe84(0x23c));const _0x5a21ea=_0x931290['algorithm']||_0x25fe84(0x25c),_0x5731a4=_0x931290[_0x25fe84(0x1a8)]||_0x25fe84(0x22f);let ivBuffer;_0x931290['iv']?ivBuffer=Buffer[_0x25fe84(0x27e)](_0x931290['iv'],_0x25fe84(0x22f)):ivBuffer=_0x2f3908[_0x25fe84(0x137)](0x10);const keyBuffer=Buffer[_0x25fe84(0x27e)](_0x20e96e,'utf8'),_0x3b3319=_0x2f3908[_0x25fe84(0x20a)](_0x5a21ea,keyBuffer,ivBuffer);let _0x143c5c=_0x3b3319[_0x25fe84(0x14c)](_0x2de115,_0x25fe84(0x291));_0x143c5c=Buffer[_0x25fe84(0x1d6)]([_0x143c5c,_0x3b3319['final']()]);const _0x35f291=_0x5731a4===_0x25fe84(0x26a)?_0x143c5c[_0x25fe84(0x22d)]('base64'):_0x143c5c[_0x25fe84(0x22d)](_0x25fe84(0x22f));return{'value':_0x35f291,'encrypted_data':_0x35f291,'iv':ivBuffer[_0x25fe84(0x22d)](_0x25fe84(0x22f)),'algorithm':_0x5a21ea,'output_format':_0x5731a4};}if(_0x50ff53===_0x25fe84(0x22b)){const _0x26f657=_0x931290[_0x25fe84(0x1ad)],_0x14f7a8=_0x931290[_0x25fe84(0x161)]||_0x2de115;if(!_0x26f657)throw new Error('Key\x20is\x20required\x20for\x20AES\x20decryption');if(!_0x14f7a8)throw new Error(_0x25fe84(0x1d4));const _0x502e83=_0x931290['algorithm']||_0x25fe84(0x25c),_0x29adf9=_0x931290[_0x25fe84(0x248)]||_0x25fe84(0x22f),_0x2795e8=_0x931290['iv'];if(!_0x2795e8&&_0x502e83[_0x25fe84(0x17e)]('cbc'))throw new Error('IV\x20is\x20required\x20for\x20CBC\x20decryption');const keyBuffer=Buffer['from'](_0x26f657,_0x25fe84(0x291)),ivBuffer=_0x2795e8?Buffer[_0x25fe84(0x27e)](_0x2795e8,'hex'):_0x2f3908[_0x25fe84(0x137)](0x10),encryptedBuffer=_0x29adf9==='base64'?Buffer[_0x25fe84(0x27e)](_0x14f7a8,'base64'):Buffer['from'](_0x14f7a8,'hex'),_0x2d206c=_0x2f3908[_0x25fe84(0x17d)](_0x502e83,keyBuffer,ivBuffer);let _0x5c1a28=_0x2d206c['update'](encryptedBuffer);return _0x5c1a28=Buffer[_0x25fe84(0x1d6)]([_0x5c1a28,_0x2d206c[_0x25fe84(0x284)]()]),{'value':_0x5c1a28['toString'](_0x25fe84(0x291)),'decrypted_data':_0x5c1a28[_0x25fe84(0x22d)](_0x25fe84(0x291)),'algorithm':_0x502e83};}if(_0x50ff53===_0x25fe84(0x1ee)){const _0x48d07c=_0x931290[_0x25fe84(0x105)]??0x20,_0x44876a=_0x931290[_0x25fe84(0x1a8)]||_0x25fe84(0x22f),_0x194f0d=_0x2f3908['randomBytes'](_0x48d07c),value=_0x44876a===_0x25fe84(0x26a)?_0x194f0d[_0x25fe84(0x22d)](_0x25fe84(0x26a)):_0x194f0d[_0x25fe84(0x22d)](_0x25fe84(0x22f));return{'value':value,'key':value,'key_length':_0x48d07c,'output_format':_0x44876a};}if(_0x50ff53==='generate_iv'){const _0x563912=_0x931290[_0x25fe84(0x19e)]??0x10,_0x239f92=_0x931290[_0x25fe84(0x1a8)]||'hex',_0x2ddd09=_0x2f3908[_0x25fe84(0x137)](_0x563912),value=_0x239f92===_0x25fe84(0x26a)?_0x2ddd09[_0x25fe84(0x22d)](_0x25fe84(0x26a)):_0x2ddd09['toString'](_0x25fe84(0x22f));return{'value':value,'iv':value,'length':_0x563912,'output_format':_0x239f92};}return{'value':_0x2de115};}async function executeRsa(_0x52e6c0,_0x25515e,_0x1c7f1d,_0x1c19c3){const _0x5f245f=_0x5e9ab1,_0x43eac9=_0x25515e['split']('.')[_0x5f245f(0x16f)]()||'';if(_0x43eac9===_0x5f245f(0x198)){const _0x17963c=_0x1c7f1d[_0x5f245f(0x16e)]??0x800,_0x223bd6=_0x1c7f1d[_0x5f245f(0x13f)]||_0x5f245f(0x202),_0x1d38da=_0x1c7f1d['private_key_format']||'pem',_0xfe699a=_0x223bd6===_0x5f245f(0x225)?'pkcs1':_0x5f245f(0x23e),_0x4edc01=_0x1d38da===_0x5f245f(0x225)?_0x5f245f(0x225):'pkcs8',{publicKey:_0x229f2c,privateKey:_0x5ef3f8}=_0x52e6c0['generateKeyPairSync'](_0x5f245f(0x1cd),{'modulusLength':_0x17963c,'publicKeyEncoding':{'type':_0xfe699a,'format':_0x5f245f(0x202)},'privateKeyEncoding':{'type':_0x4edc01,'format':'pem'}});return{'value':{'public_key':_0x229f2c,'private_key':_0x5ef3f8},'public_key':_0x229f2c,'private_key':_0x5ef3f8,'modulus_length':_0x17963c};}if(_0x43eac9===_0x5f245f(0x28c)){const _0x1fbc35=_0x1c7f1d['data']??_0x1c19c3,_0x183a2e=_0x1c7f1d['public_key'];if(!_0x183a2e)throw new Error(_0x5f245f(0x18c));const _0x28d64f=_0x1c7f1d['padding']||_0x5f245f(0x279),_0x7e7708=_0x1c7f1d['output_format']||_0x5f245f(0x26a),_0x26b0f4=_0x28d64f===_0x5f245f(0x130)?_0x52e6c0['constants'][_0x5f245f(0x130)]:_0x28d64f===_0x5f245f(0x25d)?_0x52e6c0[_0x5f245f(0x1a1)][_0x5f245f(0x25d)]:_0x52e6c0[_0x5f245f(0x1a1)][_0x5f245f(0x279)],_0x14a775=typeof _0x1fbc35===_0x5f245f(0x226)?_0x1fbc35:JSON[_0x5f245f(0x1bd)](_0x1fbc35),_0x501355=_0x52e6c0[_0x5f245f(0x1af)]({'key':_0x183a2e,'padding':_0x26b0f4},Buffer[_0x5f245f(0x27e)](_0x14a775,_0x5f245f(0x291))),value=_0x7e7708===_0x5f245f(0x22f)?_0x501355[_0x5f245f(0x22d)](_0x5f245f(0x22f)):_0x501355[_0x5f245f(0x22d)]('base64');return{'value':value,'encrypted_data':value,'padding':_0x28d64f,'output_format':_0x7e7708};}if(_0x43eac9===_0x5f245f(0x22b)){const _0x194c36=_0x1c7f1d[_0x5f245f(0x161)]??_0x1c19c3,_0x3582ae=_0x1c7f1d[_0x5f245f(0x153)];if(!_0x3582ae)throw new Error(_0x5f245f(0x1a3));const _0xc60dba=_0x1c7f1d[_0x5f245f(0x13c)]||'RSA_PKCS1_OAEP_PADDING',_0x5090e7=_0x1c7f1d[_0x5f245f(0x248)]||_0x5f245f(0x26a),_0x499d5e=_0xc60dba===_0x5f245f(0x130)?_0x52e6c0[_0x5f245f(0x1a1)]['RSA_PKCS1_PADDING']:_0xc60dba===_0x5f245f(0x25d)?_0x52e6c0[_0x5f245f(0x1a1)][_0x5f245f(0x25d)]:_0x52e6c0[_0x5f245f(0x1a1)][_0x5f245f(0x279)],encryptedBuffer=_0x5090e7===_0x5f245f(0x22f)?Buffer[_0x5f245f(0x27e)](_0x194c36,_0x5f245f(0x22f)):Buffer[_0x5f245f(0x27e)](_0x194c36,_0x5f245f(0x26a)),_0x53d011=_0x52e6c0['privateDecrypt']({'key':_0x3582ae,'padding':_0x499d5e},encryptedBuffer),value=_0x53d011[_0x5f245f(0x22d)]('utf8');return{'value':value,'decrypted_data':value,'padding':_0xc60dba};}if(_0x43eac9===_0x5f245f(0x11f)){const _0x6ff8b4=_0x1c7f1d[_0x5f245f(0x212)]??_0x1c19c3,_0x4c9b40=_0x1c7f1d[_0x5f245f(0x153)];if(!_0x4c9b40)throw new Error('Private\x20key\x20is\x20required\x20for\x20RSA\x20signing');const _0x2d1902=_0x1c7f1d['algorithm']||_0x5f245f(0x23d),_0x1ba29b=typeof _0x6ff8b4==='string'?_0x6ff8b4:JSON[_0x5f245f(0x1bd)](_0x6ff8b4),_0x2061dc=_0x52e6c0[_0x5f245f(0x10e)](_0x2d1902);_0x2061dc[_0x5f245f(0x14c)](_0x1ba29b);const _0x411a59=_0x2061dc[_0x5f245f(0x11f)](_0x4c9b40,_0x5f245f(0x26a));return{'value':_0x411a59,'signature':_0x411a59,'algorithm':_0x2d1902};}if(_0x43eac9==='verify'){const _0x4264dd=_0x1c7f1d[_0x5f245f(0x212)]??_0x1c19c3,_0x3a7aed=_0x1c7f1d['signature'],_0x42f49a=_0x1c7f1d['public_key'];if(!_0x3a7aed)throw new Error(_0x5f245f(0x187));if(!_0x42f49a)throw new Error(_0x5f245f(0x12a));const _0x7f96e7=_0x1c7f1d['algorithm']||_0x5f245f(0x23d),_0x21d72e=typeof _0x4264dd===_0x5f245f(0x226)?_0x4264dd:JSON[_0x5f245f(0x1bd)](_0x4264dd),_0x5c7373=_0x52e6c0[_0x5f245f(0x11d)](_0x7f96e7);_0x5c7373[_0x5f245f(0x14c)](_0x21d72e);const _0x54f002=_0x5c7373[_0x5f245f(0x20b)](_0x42f49a,_0x3a7aed,_0x5f245f(0x26a));return{'value':_0x54f002,'valid':_0x54f002,'algorithm':_0x7f96e7};}return{'value':_0x1c19c3};}async function executeHmac(_0x1b895d,_0x41f7d5,_0x4016ad,_0x1bcc98){const _0x4caf3a=_0x5e9ab1,_0x145013=_0x41f7d5[_0x4caf3a(0x145)]('.')['pop']()||'',_0x4235b9=_0x4016ad['key'];if(!_0x4235b9)throw new Error(_0x4caf3a(0x1b5));const _0x18ebd8=_0x4016ad[_0x4caf3a(0x14a)]||_0x4caf3a(0x242),_0x149c87=_0x4016ad[_0x4caf3a(0x212)]??_0x1bcc98,_0x4389e0=typeof _0x149c87===_0x4caf3a(0x226)?_0x149c87:JSON[_0x4caf3a(0x1bd)](_0x149c87);if(_0x145013===_0x4caf3a(0x104)){const _0x315d1a=_0x4016ad['output_format']||_0x4caf3a(0x22f),_0x91943=_0x1b895d[_0x4caf3a(0x183)](_0x18ebd8,_0x4235b9);_0x91943[_0x4caf3a(0x14c)](_0x4389e0);const _0x3f05f2=_0x91943['digest'](),value=_0x315d1a===_0x4caf3a(0x26a)?_0x3f05f2[_0x4caf3a(0x22d)](_0x4caf3a(0x26a)):_0x3f05f2['toString']('hex');return{'value':value,'hmac':value,'algorithm':_0x18ebd8,'output_format':_0x315d1a};}if(_0x145013===_0x4caf3a(0x20b)){const _0x1826fa=_0x4016ad['hmac'];if(!_0x1826fa)throw new Error('HMAC\x20is\x20required\x20for\x20verification');const _0x100f81=_0x4016ad['input_format']||_0x4caf3a(0x22f),_0x466892=_0x1b895d[_0x4caf3a(0x183)](_0x18ebd8,_0x4235b9);_0x466892[_0x4caf3a(0x14c)](_0x4389e0);const _0x41d684=_0x466892['digest'](),_0x2885ca=_0x100f81===_0x4caf3a(0x26a)?_0x41d684['toString'](_0x4caf3a(0x26a)):_0x41d684['toString'](_0x4caf3a(0x22f)),_0x58faa2=_0x2885ca===_0x1826fa;return{'value':_0x58faa2,'valid':_0x58faa2,'algorithm':_0x18ebd8};}return{'value':_0x1bcc98};}async function executePassword(_0xfee8bf,_0x470e53,_0x56a263){const _0x1b74ea=_0x5e9ab1,_0x14cefb=await Promise[_0x1b74ea(0x15c)]()[_0x1b74ea(0x14b)](()=>__importStar(require(_0x1b74ea(0x1b6)))),_0x4d708c=_0xfee8bf[_0x1b74ea(0x145)]('.')[_0x1b74ea(0x16f)]()||'',_0x4e42ba=_0x470e53[_0x1b74ea(0x19c)]??_0x56a263,_0x192501=_0x470e53[_0x1b74ea(0x152)];if(_0x4d708c===_0x1b74ea(0x140)){let _0x4abf45;try{_0x4abf45=await Promise['resolve']()[_0x1b74ea(0x14b)](()=>__importStar(require(_0x1b74ea(0x12f))));}catch{throw new Error(_0x1b74ea(0x14e));}const _0x4541b8=_0x470e53['type']||'argon2id',_0x27a21a=_0x470e53[_0x1b74ea(0x14f)]??0x10000,_0x192279=_0x470e53[_0x1b74ea(0x219)]??0x3,_0x5b4a3d=_0x470e53['parallelism']??0x4,_0x39ccdf=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x44465c=await _0x4abf45[_0x1b74ea(0x234)](_0x39ccdf,{'type':_0x4541b8===_0x1b74ea(0x146)?_0x4abf45[_0x1b74ea(0x146)]:_0x4541b8===_0x1b74ea(0x28d)?_0x4abf45['argon2d']:_0x4abf45['argon2id'],'memoryCost':_0x27a21a,'timeCost':_0x192279,'parallelism':_0x5b4a3d});return{'value':_0x44465c,'hash':_0x44465c,'type':_0x4541b8,'memoryCost':_0x27a21a,'timeCost':_0x192279,'parallelism':_0x5b4a3d};}if(_0x4d708c==='argon2_verify'){let _0x1313b5;try{_0x1313b5=await Promise[_0x1b74ea(0x15c)]()[_0x1b74ea(0x14b)](()=>__importStar(require(_0x1b74ea(0x12f))));}catch{throw new Error('argon2\x20package\x20is\x20required\x20for\x20argon2_verify.\x20Install\x20with:\x20npm\x20install\x20argon2');}const _0x155e5a=_0x470e53[_0x1b74ea(0x234)];if(!_0x155e5a)throw new Error(_0x1b74ea(0x1f2));const _0x2ac95f=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba;try{const _0x4bc139=await _0x1313b5[_0x1b74ea(0x20b)](_0x155e5a,_0x2ac95f);return{'value':_0x4bc139,'valid':_0x4bc139};}catch{return{'value':![],'valid':![]};}}if(_0x4d708c===_0x1b74ea(0x134)){const _0x445c33=_0x470e53['salt']??_0x14cefb[_0x1b74ea(0x137)](0x20)[_0x1b74ea(0x22d)]('hex'),_0x448a85=_0x470e53[_0x1b74ea(0x207)]??0x186a0,_0x533bc0=_0x470e53[_0x1b74ea(0x245)]??0x40,_0x2bf2ef=_0x470e53[_0x1b74ea(0x156)]||_0x1b74ea(0x242),_0x5db51d=_0x470e53[_0x1b74ea(0x1a8)]||_0x1b74ea(0x22f),_0x16e9c7=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x5a3bb6=_0x14cefb[_0x1b74ea(0x10b)](_0x16e9c7,_0x445c33,_0x448a85,_0x533bc0,_0x2bf2ef),_0x22e7eb=_0x5db51d==='base64'?_0x5a3bb6[_0x1b74ea(0x22d)](_0x1b74ea(0x26a)):_0x5a3bb6['toString'](_0x1b74ea(0x22f));return{'value':_0x22e7eb,'hash':_0x22e7eb,'salt':_0x445c33,'iterations':_0x448a85,'keylen':_0x533bc0,'digest':_0x2bf2ef,'output_format':_0x5db51d};}if(_0x4d708c===_0x1b74ea(0x261)){const _0x3419f0=_0x470e53[_0x1b74ea(0x234)],_0x3fd1b7=_0x470e53[_0x1b74ea(0x174)];if(!_0x3419f0||!_0x3fd1b7)throw new Error(_0x1b74ea(0x154));const _0x1c4271=_0x470e53['iterations']??0x186a0,_0x4ec8d0=_0x470e53[_0x1b74ea(0x245)]??0x40,_0x323411=_0x470e53['digest']||_0x1b74ea(0x242),_0x5f3530=_0x470e53[_0x1b74ea(0x1a8)]||_0x1b74ea(0x22f),_0x40c9db=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x3bdc12=_0x14cefb[_0x1b74ea(0x10b)](_0x40c9db,_0x3fd1b7,_0x1c4271,_0x4ec8d0,_0x323411),_0x376913=_0x5f3530===_0x1b74ea(0x26a)?_0x3bdc12[_0x1b74ea(0x22d)](_0x1b74ea(0x26a)):_0x3bdc12[_0x1b74ea(0x22d)](_0x1b74ea(0x22f)),_0x43e70e=_0x376913===_0x3419f0;return{'value':_0x43e70e,'valid':_0x43e70e};}if(_0x4d708c===_0x1b74ea(0x19b)){const _0x5c8571=_0x470e53[_0x1b74ea(0x174)]??_0x14cefb[_0x1b74ea(0x137)](0x20)[_0x1b74ea(0x22d)](_0x1b74ea(0x22f)),_0x5c2113=_0x470e53[_0x1b74ea(0x245)]??0x40,_0x250d07=_0x470e53['cost']??0x4000,_0x92afa0=_0x470e53['blockSize']??0x8,_0x34504d=_0x470e53[_0x1b74ea(0x151)]??0x1,_0xb016d1=_0x470e53[_0x1b74ea(0x1a8)]||'hex',_0x30e868=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x5e464a=_0x14cefb[_0x1b74ea(0x24b)](_0x30e868,_0x5c8571,_0x5c2113,{'cost':_0x250d07,'blockSize':_0x92afa0,'maxmem':0x80*_0x250d07*_0x92afa0}),_0x3ba469=_0xb016d1===_0x1b74ea(0x26a)?_0x5e464a[_0x1b74ea(0x22d)]('base64'):_0x5e464a[_0x1b74ea(0x22d)](_0x1b74ea(0x22f));return{'value':_0x3ba469,'hash':_0x3ba469,'salt':_0x5c8571,'keylen':_0x5c2113,'cost':_0x250d07,'blockSize':_0x92afa0,'parallelization':_0x34504d,'output_format':_0xb016d1};}if(_0x4d708c===_0x1b74ea(0x270)){const _0x2a6d48=_0x470e53[_0x1b74ea(0x234)],_0x50d38e=_0x470e53['salt'];if(!_0x2a6d48||!_0x50d38e)throw new Error(_0x1b74ea(0x10f));const _0x3740ed=_0x470e53[_0x1b74ea(0x245)]??0x40,_0x3099df=_0x470e53[_0x1b74ea(0x172)]??0x4000,_0x97ba67=_0x470e53['blockSize']??0x8,_0x41b24c=_0x470e53[_0x1b74ea(0x1a8)]||_0x1b74ea(0x22f),_0x3a229b=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x4efa9c=_0x14cefb[_0x1b74ea(0x24b)](_0x3a229b,_0x50d38e,_0x3740ed,{'cost':_0x3099df,'blockSize':_0x97ba67,'maxmem':0x80*_0x3099df*_0x97ba67}),_0x5e3a5e=_0x41b24c===_0x1b74ea(0x26a)?_0x4efa9c[_0x1b74ea(0x22d)](_0x1b74ea(0x26a)):_0x4efa9c[_0x1b74ea(0x22d)](_0x1b74ea(0x22f)),_0x560a40=_0x5e3a5e===_0x2a6d48;return{'value':_0x560a40,'valid':_0x560a40};}if(_0x4d708c==='bcrypt_hash'){let _0x553e53;try{_0x553e53=await Promise[_0x1b74ea(0x15c)]()[_0x1b74ea(0x14b)](()=>__importStar(require(_0x1b74ea(0x21f))));}catch{throw new Error(_0x1b74ea(0x169));}const _0x262c57=_0x470e53[_0x1b74ea(0x27a)]??0xa,_0x3f59f4=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba,_0x350b67=await _0x553e53['hash'](_0x3f59f4,_0x262c57);return{'value':_0x350b67,'hash':_0x350b67,'rounds':_0x262c57};}if(_0x4d708c==='bcrypt_verify'){let _0x3a4fe4;try{_0x3a4fe4=await Promise[_0x1b74ea(0x15c)]()[_0x1b74ea(0x14b)](()=>__importStar(require(_0x1b74ea(0x21f))));}catch{throw new Error(_0x1b74ea(0x1d5));}const _0x375902=_0x470e53['hash'];if(!_0x375902)throw new Error('Hash\x20is\x20required\x20for\x20bcrypt\x20verification');const _0x143a58=_0x192501?_0x192501+_0x4e42ba:_0x4e42ba;try{const _0x55d492=await _0x3a4fe4['compare'](_0x143a58,_0x375902);return{'value':_0x55d492,'valid':_0x55d492};}catch{return{'value':![],'valid':![]};}}if(_0x4d708c===_0x1b74ea(0x227)){const _0xd3e1a9=_0x470e53[_0x1b74ea(0x19e)]??0x20,_0x14fe10=_0x470e53[_0x1b74ea(0x1a8)]||'hex',_0x792b42=_0x14cefb[_0x1b74ea(0x137)](_0xd3e1a9),value=_0x14fe10===_0x1b74ea(0x26a)?_0x792b42[_0x1b74ea(0x22d)](_0x1b74ea(0x26a)):_0x792b42[_0x1b74ea(0x22d)](_0x1b74ea(0x22f));return{'value':value,'salt':value,'length':_0xd3e1a9,'output_format':_0x14fe10};}return{'value':_0x56a263};}function _0x6af2(_0x1b5a1b,_0x35029b){_0x1b5a1b=_0x1b5a1b-0x104;const _0x2b89a5=_0x2b89();let _0x6af2ff=_0x2b89a5[_0x1b5a1b];if(_0x6af2['xXgPdl']===undefined){var _0x3f1d33=function(_0x3d9c4d){const _0x5e2972='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xd977a8='',_0x529d9a='';for(let _0x47550d=0x0,_0x443cf4,_0x28f15c,_0x1fc513=0x0;_0x28f15c=_0x3d9c4d['charAt'](_0x1fc513++);~_0x28f15c&&(_0x443cf4=_0x47550d%0x4?_0x443cf4*0x40+_0x28f15c:_0x28f15c,_0x47550d++%0x4)?_0xd977a8+=String['fromCharCode'](0xff&_0x443cf4>>(-0x2*_0x47550d&0x6)):0x0){_0x28f15c=_0x5e2972['indexOf'](_0x28f15c);}for(let _0xc36083=0x0,_0x3f1b87=_0xd977a8['length'];_0xc36083<_0x3f1b87;_0xc36083++){_0x529d9a+='%'+('00'+_0xd977a8['charCodeAt'](_0xc36083)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x529d9a);};_0x6af2['BLaaRV']=_0x3f1d33,_0x6af2['GusBUR']={},_0x6af2['xXgPdl']=!![];}const _0x1bd98c=_0x2b89a5[0x0],_0x19f3d6=_0x1b5a1b+_0x1bd98c,_0x56a378=_0x6af2['GusBUR'][_0x19f3d6];return!_0x56a378?(_0x6af2ff=_0x6af2['BLaaRV'](_0x6af2ff),_0x6af2['GusBUR'][_0x19f3d6]=_0x6af2ff):_0x6af2ff=_0x56a378,_0x6af2ff;}function resolveRegisteredRestActionName(_0x212300,_0x560342){const _0x23a5b8=_0x5e9ab1,_0x28fc50=_0x212300[_0x23a5b8(0x179)]||[];if(!_0x28fc50[_0x23a5b8(0x19e)])return null;if(_0x28fc50[_0x23a5b8(0x150)](_0x249340=>_0x249340['name']===_0x560342||_0x249340[_0x23a5b8(0x166)]===_0x560342))return _0x560342;const _0x45fa81=_0x212300['actions'];if(_0x45fa81&&typeof _0x45fa81==='object'&&!Array[_0x23a5b8(0x1c4)](_0x45fa81)&&Object[_0x23a5b8(0x14d)][_0x23a5b8(0x1dd)][_0x23a5b8(0x117)](_0x45fa81,_0x560342)){const _0x3cdf65=_0x45fa81[_0x560342];if(typeof _0x3cdf65===_0x23a5b8(0x226)&&_0x28fc50[_0x23a5b8(0x150)](_0xcf882=>_0xcf882['name']===_0x3cdf65||_0xcf882[_0x23a5b8(0x166)]===_0x3cdf65))return _0x3cdf65;}return null;}async function executeConnectorAction(_0x52a1df,_0x5e23ce,_0xc8efc2={},_0xa84a0b={}){const _0x45591c=_0x5e9ab1,_0x448acf=resolveRegisteredRestActionName(_0x52a1df,_0x5e23ce);if(_0x448acf&&(_0x52a1df[_0x45591c(0x205)]===_0x45591c(0x16b)||_0x52a1df['type']===_0x45591c(0x264)||_0x52a1df[_0x45591c(0x179)]?.['length']))return executeRestConnector(_0x52a1df,_0x448acf,_0xc8efc2,_0xa84a0b);if(typeof _0x52a1df[_0x45591c(0x18d)]===_0x45591c(0x27d)){const _0x188670=await _0x52a1df[_0x45591c(0x18d)](_0x5e23ce,_0xc8efc2,_0xa84a0b);return{'raw':_0x188670,'mapped':_0x188670};}const _0x3544c3=_0x52a1df[_0x45591c(0x1f9)]?.['category'];if(_0x3544c3===_0x45591c(0x1e2))return executeResponder(_0x52a1df,_0xc8efc2,_0xa84a0b);if(_0x3544c3===_0x45591c(0x263))return executeDbConnector(_0x52a1df,_0x5e23ce,_0xc8efc2,_0xa84a0b);if(_0x3544c3==='authentication')return executeAuthConnector(_0x52a1df,_0x5e23ce,_0xc8efc2,_0xa84a0b);if(_0x3544c3===_0x45591c(0x1f3))return executeUtilityConnector(_0x52a1df,_0x5e23ce,_0xc8efc2,_0xa84a0b);if(_0x3544c3===_0x45591c(0x121))return executeEncryptionConnector(_0x52a1df,_0x5e23ce,_0xc8efc2,_0xa84a0b);if(_0x52a1df[_0x45591c(0x205)]==='REST'||_0x52a1df['type']===_0x45591c(0x264)||_0x52a1df[_0x45591c(0x179)])return executeRestConnector(_0x52a1df,_0x5e23ce,_0xc8efc2,_0xa84a0b);throw new Error(_0x45591c(0x133)+(_0x52a1df[_0x45591c(0x1ed)]||_0x52a1df['id']));}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.executeConnectorAction = executeConnectorAction;
|
|
40
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
42
|
+
const template_1 = require("../template");
|
|
43
|
+
const registry_1 = require("../connectors/registry");
|
|
44
|
+
const string_executor_1 = require("./utilities/string.executor");
|
|
45
|
+
const math_executor_1 = require("./utilities/math.executor");
|
|
46
|
+
const random_executor_1 = require("./utilities/random.executor");
|
|
47
|
+
async function renderBodyRecursive(val, context) {
|
|
48
|
+
if (val == null)
|
|
49
|
+
return val;
|
|
50
|
+
if (typeof val === "string" && val.includes("{{")) {
|
|
51
|
+
const rendered = await (0, template_1.renderTemplate)(val, context);
|
|
52
|
+
if (typeof rendered === "string" && rendered.startsWith("{") && rendered.endsWith("}")) {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(rendered);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return rendered;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return rendered;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(val)) {
|
|
63
|
+
return Promise.all(val.map((v) => renderBodyRecursive(v, context)));
|
|
64
|
+
}
|
|
65
|
+
if (typeof val === "object") {
|
|
66
|
+
const out = {};
|
|
67
|
+
for (const k of Object.keys(val)) {
|
|
68
|
+
out[k] = await renderBodyRecursive(val[k], context);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
return val;
|
|
73
|
+
}
|
|
74
|
+
function rethrowConnectorHttpError(err) {
|
|
75
|
+
if (axios_1.default.isAxiosError(err)) {
|
|
76
|
+
const res = err.response;
|
|
77
|
+
const data = res?.data;
|
|
78
|
+
const message = (data &&
|
|
79
|
+
typeof data === "object" &&
|
|
80
|
+
((typeof data.message === "string" && data.message) ||
|
|
81
|
+
(typeof data.error === "string" && data.error))) ||
|
|
82
|
+
err.message ||
|
|
83
|
+
"Request failed";
|
|
84
|
+
const wrapped = new Error(message);
|
|
85
|
+
wrapped.status = res?.status;
|
|
86
|
+
wrapped.response = data;
|
|
87
|
+
wrapped.data = data;
|
|
88
|
+
if (data && typeof data === "object" && typeof data.code === "string") {
|
|
89
|
+
wrapped.code = data.code;
|
|
90
|
+
}
|
|
91
|
+
throw wrapped;
|
|
92
|
+
}
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
async function executeResponder(connectorDef, options, context) {
|
|
96
|
+
const id = connectorDef._id || connectorDef.id || "";
|
|
97
|
+
if (id === "raw.responder") {
|
|
98
|
+
const statusCode = options.statusCode ?? 200;
|
|
99
|
+
const contentType = options.contentType || "text/plain";
|
|
100
|
+
let body = options.body ?? "";
|
|
101
|
+
if (body !== undefined && body !== null && typeof body === "string") {
|
|
102
|
+
body = await (0, template_1.renderTemplate)(body, context);
|
|
103
|
+
}
|
|
104
|
+
return { statusCode, headers: { "content-type": contentType }, body, terminate: true };
|
|
105
|
+
}
|
|
106
|
+
if (id === "redirect.responder") {
|
|
107
|
+
const statusCode = options.statusCode ?? 302;
|
|
108
|
+
let location = options.location ?? "";
|
|
109
|
+
if (typeof location === "string")
|
|
110
|
+
location = await (0, template_1.renderTemplate)(location, context);
|
|
111
|
+
return { statusCode, headers: { location }, terminate: true };
|
|
112
|
+
}
|
|
113
|
+
if (id === "empty.responder") {
|
|
114
|
+
const statusCode = options.statusCode ?? 202;
|
|
115
|
+
return { statusCode, terminate: true };
|
|
116
|
+
}
|
|
117
|
+
const statusCode = options.statusCode ?? 200;
|
|
118
|
+
let body = options.body;
|
|
119
|
+
if (body !== undefined && body !== null) {
|
|
120
|
+
body = await renderBodyRecursive(body, context);
|
|
121
|
+
}
|
|
122
|
+
const headers = { "content-type": "application/json" };
|
|
123
|
+
if (options.headers && typeof options.headers === "object") {
|
|
124
|
+
for (const [k, v] of Object.entries(options.headers)) {
|
|
125
|
+
if (typeof v === "string" && v.includes("{{")) {
|
|
126
|
+
headers[k] = await (0, template_1.renderTemplate)(v, context);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
headers[k] = String(v);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { statusCode, headers, body, terminate: true };
|
|
134
|
+
}
|
|
135
|
+
async function executeRestConnector(connectorDef, actionName, options, context) {
|
|
136
|
+
const endpoints = connectorDef.endpoints || [];
|
|
137
|
+
const endpoint = endpoints.find((e) => e.name === actionName || e.action === actionName);
|
|
138
|
+
if (!endpoint)
|
|
139
|
+
throw new Error("Endpoint not found: " + actionName);
|
|
140
|
+
let path = endpoint.path || "";
|
|
141
|
+
const pathParams = { ...(endpoint.pathParams || {}), ...(options.pathParams || {}) };
|
|
142
|
+
for (const k of Object.keys(pathParams)) {
|
|
143
|
+
const val = pathParams[k];
|
|
144
|
+
path = path.replace(new RegExp(`\\{\\{\\s*${k}\\s*\\}\\}|[:{]${k}[}]?`, "g"), encodeURIComponent(String(val)));
|
|
145
|
+
}
|
|
146
|
+
if (path.includes("{{"))
|
|
147
|
+
path = await (0, template_1.renderTemplate)(path, context);
|
|
148
|
+
const base = (connectorDef.base_url || "").replace(/\/+$/, "");
|
|
149
|
+
const url = base + (path.startsWith("/") ? path : "/" + path);
|
|
150
|
+
const params = { ...(endpoint.params || {}), ...(options.params || {}) };
|
|
151
|
+
for (const k of Object.keys(params)) {
|
|
152
|
+
if (typeof params[k] === "string" && params[k].includes("{{")) {
|
|
153
|
+
params[k] = await (0, template_1.renderTemplate)(params[k], context);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
let body = options.body ?? endpoint.body ?? null;
|
|
157
|
+
if (body && typeof body === "object") {
|
|
158
|
+
body = JSON.parse(await (0, template_1.renderTemplate)(JSON.stringify(body), context));
|
|
159
|
+
}
|
|
160
|
+
else if (typeof body === "string" && body.includes("{{")) {
|
|
161
|
+
body = await (0, template_1.renderTemplate)(body, context);
|
|
162
|
+
}
|
|
163
|
+
const headers = { ...(endpoint.headers || {}) };
|
|
164
|
+
const auth = connectorDef.auth || {};
|
|
165
|
+
if (auth.type === "bearer" && auth.token) {
|
|
166
|
+
const headerKey = auth.header_name || "Authorization";
|
|
167
|
+
const prefix = auth.prefix ?? "Bearer ";
|
|
168
|
+
headers[headerKey] = prefix + auth.token;
|
|
169
|
+
}
|
|
170
|
+
if (auth.type === "api_key" && auth.api_key) {
|
|
171
|
+
const key = auth.key_name || "Authorization";
|
|
172
|
+
headers[key] = auth.api_key;
|
|
173
|
+
}
|
|
174
|
+
const optionHeaders = options.headers || {};
|
|
175
|
+
for (const [k, v] of Object.entries(optionHeaders)) {
|
|
176
|
+
if (typeof v === "string" && v.includes("{{")) {
|
|
177
|
+
headers[k] = await (0, template_1.renderTemplate)(v, context);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
headers[k] = String(v);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const method = (endpoint.method || "GET").toUpperCase();
|
|
184
|
+
const cfg = {
|
|
185
|
+
method: method.toLowerCase(),
|
|
186
|
+
url,
|
|
187
|
+
params,
|
|
188
|
+
headers,
|
|
189
|
+
timeout: options.timeout || endpoint.timeout_ms || 10000,
|
|
190
|
+
};
|
|
191
|
+
if (body !== null && body !== undefined && method !== "GET") {
|
|
192
|
+
cfg.data = body;
|
|
193
|
+
}
|
|
194
|
+
const connectorConfig = context?.connectorConfig?.[connectorDef._id] || {};
|
|
195
|
+
if (connectorConfig.apiKey && auth.type === "bearer") {
|
|
196
|
+
const headerKey = auth.header_name || "Authorization";
|
|
197
|
+
const prefix = auth.prefix ?? "Bearer ";
|
|
198
|
+
headers[headerKey] = prefix + connectorConfig.apiKey;
|
|
199
|
+
}
|
|
200
|
+
let resp;
|
|
201
|
+
try {
|
|
202
|
+
resp = await (0, axios_1.default)(cfg);
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
rethrowConnectorHttpError(e);
|
|
206
|
+
}
|
|
207
|
+
const raw = resp.data;
|
|
208
|
+
let mapped;
|
|
209
|
+
if (endpoint.response_mapping && typeof endpoint.response_mapping === "object") {
|
|
210
|
+
mapped = {};
|
|
211
|
+
for (const [outKey, srcPath] of Object.entries(endpoint.response_mapping)) {
|
|
212
|
+
mapped[outKey] = getByPath(raw, srcPath);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
mapped = raw;
|
|
217
|
+
}
|
|
218
|
+
const responseWarnings = collectRestResponseWarnings(endpoint, mapped, connectorDef, actionName);
|
|
219
|
+
const out = { raw, mapped };
|
|
220
|
+
if (responseWarnings.length)
|
|
221
|
+
out.responseWarnings = responseWarnings;
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
function getByPath(obj, path) {
|
|
225
|
+
if (!obj || !path)
|
|
226
|
+
return undefined;
|
|
227
|
+
const parts = path.split(".");
|
|
228
|
+
let cur = obj;
|
|
229
|
+
for (const p of parts) {
|
|
230
|
+
if (cur == null)
|
|
231
|
+
return undefined;
|
|
232
|
+
cur = cur[p];
|
|
233
|
+
}
|
|
234
|
+
return cur;
|
|
235
|
+
}
|
|
236
|
+
function collectRestResponseWarnings(endpoint, mapped, connectorDef, actionName) {
|
|
237
|
+
const w = [];
|
|
238
|
+
const cid = connectorDef._id || connectorDef.id || "connector";
|
|
239
|
+
if (endpoint.response_mapping && mapped != null && typeof mapped === "object" && !Array.isArray(mapped)) {
|
|
240
|
+
for (const [outKey, srcPath] of Object.entries(endpoint.response_mapping)) {
|
|
241
|
+
if (!Object.prototype.hasOwnProperty.call(mapped, outKey)) {
|
|
242
|
+
w.push(`response_mapping output "${outKey}" missing from mapped result (path "${String(srcPath)}")`);
|
|
243
|
+
}
|
|
244
|
+
else if (mapped[outKey] === undefined) {
|
|
245
|
+
w.push(`response_mapping output "${outKey}" is undefined; provider JSON may not match path "${String(srcPath)}"`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if ((0, registry_1.isTypedConnectorDef)(connectorDef)) {
|
|
250
|
+
const schema = connectorDef.__schemas?.[actionName];
|
|
251
|
+
const sample = schema?.response;
|
|
252
|
+
if (sample != null && typeof sample === "object" && !Array.isArray(sample)) {
|
|
253
|
+
const keys = Object.keys(sample);
|
|
254
|
+
if (keys.length > 0) {
|
|
255
|
+
if (mapped == null || typeof mapped !== "object" || Array.isArray(mapped)) {
|
|
256
|
+
w.push(`typed connector "${cid}" action "${actionName}" expected object response, got ${mapped === null ? "null" : Array.isArray(mapped) ? "array" : typeof mapped}`);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
for (const k of keys) {
|
|
260
|
+
if (!Object.prototype.hasOwnProperty.call(mapped, k)) {
|
|
261
|
+
w.push(`typed connector "${cid}" expects response key "${k}" but mapped result has no such key`);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const expected = sample[k];
|
|
265
|
+
const actual = mapped[k];
|
|
266
|
+
const expT = expected === null ? "null" : Array.isArray(expected) ? "array" : typeof expected;
|
|
267
|
+
const actT = actual === null ? "null" : Array.isArray(actual) ? "array" : typeof actual;
|
|
268
|
+
if (expT !== actT) {
|
|
269
|
+
w.push(`typed connector "${cid}" response key "${k}" declared as ${expT} but provider returned ${actT}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return w;
|
|
277
|
+
}
|
|
278
|
+
async function executeDbConnector(connectorDef, actionName, options, context) {
|
|
279
|
+
const connectorId = connectorDef._id || connectorDef.id;
|
|
280
|
+
const config = context?.connectorConfig?.[connectorId] || context?.env || {};
|
|
281
|
+
const uri = config.uri || config.MONGO_URI || connectorDef.auth?.uri;
|
|
282
|
+
const database = options.database || config.database || connectorDef.auth?.database;
|
|
283
|
+
if (!uri)
|
|
284
|
+
throw new Error("MongoDB URI not configured for " + connectorId);
|
|
285
|
+
if (connectorId === "mongodb.system") {
|
|
286
|
+
try {
|
|
287
|
+
const { MongoClient } = await Promise.resolve().then(() => __importStar(require("mongodb")));
|
|
288
|
+
const client = new MongoClient(uri);
|
|
289
|
+
await client.connect();
|
|
290
|
+
try {
|
|
291
|
+
const db = client.db(database);
|
|
292
|
+
const collection = options.collection;
|
|
293
|
+
if (!collection)
|
|
294
|
+
throw new Error("collection is required");
|
|
295
|
+
let result;
|
|
296
|
+
switch (actionName) {
|
|
297
|
+
case "insertOne":
|
|
298
|
+
result = await db.collection(collection).insertOne(options.document || {});
|
|
299
|
+
return { raw: result, mapped: { insertedId: result.insertedId, ...result } };
|
|
300
|
+
case "insertMany":
|
|
301
|
+
result = await db.collection(collection).insertMany(options.documents || []);
|
|
302
|
+
return { raw: result, mapped: result };
|
|
303
|
+
case "findOne":
|
|
304
|
+
result = await db.collection(collection).findOne(options.filter || {});
|
|
305
|
+
return { raw: result, mapped: result };
|
|
306
|
+
case "find":
|
|
307
|
+
const cursor = db.collection(collection).find(options.filter || {});
|
|
308
|
+
if (options.limit)
|
|
309
|
+
cursor.limit(options.limit);
|
|
310
|
+
if (options.sort)
|
|
311
|
+
cursor.sort(options.sort);
|
|
312
|
+
result = await cursor.toArray();
|
|
313
|
+
return { raw: result, mapped: result };
|
|
314
|
+
case "updateOne":
|
|
315
|
+
result = await db.collection(collection).updateOne(options.filter || {}, options.update || {});
|
|
316
|
+
return { raw: result, mapped: result };
|
|
317
|
+
case "deleteOne":
|
|
318
|
+
result = await db.collection(collection).deleteOne(options.filter || {});
|
|
319
|
+
return { raw: result, mapped: result };
|
|
320
|
+
default:
|
|
321
|
+
throw new Error("Unsupported MongoDB action: " + actionName);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
finally {
|
|
325
|
+
await client.close();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch (e) {
|
|
329
|
+
if (e.code === "ERR_MODULE_NOT_FOUND" || e.message?.includes("mongodb")) {
|
|
330
|
+
throw new Error("mongodb package not installed. Add it as a dependency: npm install mongodb");
|
|
331
|
+
}
|
|
332
|
+
throw e;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (connectorId === "mysql.system") {
|
|
336
|
+
try {
|
|
337
|
+
const mysql = await Promise.resolve().then(() => __importStar(require("mysql2/promise")));
|
|
338
|
+
const connConfig = config.uri ? { uri: config.uri } : {
|
|
339
|
+
host: config.host || "localhost",
|
|
340
|
+
user: config.user,
|
|
341
|
+
password: config.password,
|
|
342
|
+
database: config.database || database,
|
|
343
|
+
};
|
|
344
|
+
const conn = config.uri
|
|
345
|
+
? await mysql.createConnection(config.uri)
|
|
346
|
+
: await mysql.createConnection(connConfig);
|
|
347
|
+
try {
|
|
348
|
+
const [rows] = await conn.execute(options.query || "SELECT 1", options.params);
|
|
349
|
+
return { raw: rows, mapped: rows };
|
|
350
|
+
}
|
|
351
|
+
finally {
|
|
352
|
+
await conn.end();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (e) {
|
|
356
|
+
if (e.code === "ERR_MODULE_NOT_FOUND" || e.message?.includes("mysql2")) {
|
|
357
|
+
throw new Error("mysql2 package not installed. Add it as a dependency: npm install mysql2");
|
|
358
|
+
}
|
|
359
|
+
throw e;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (connectorId === "postgres.system") {
|
|
363
|
+
try {
|
|
364
|
+
const { Pool } = await Promise.resolve().then(() => __importStar(require("pg")));
|
|
365
|
+
const poolConfig = config.uri
|
|
366
|
+
? { connectionString: config.uri }
|
|
367
|
+
: {
|
|
368
|
+
host: config.host || "localhost",
|
|
369
|
+
port: config.port || 5432,
|
|
370
|
+
user: config.username || config.user,
|
|
371
|
+
password: config.password,
|
|
372
|
+
database: config.database || database,
|
|
373
|
+
ssl: config.ssl ? { rejectUnauthorized: false } : undefined,
|
|
374
|
+
};
|
|
375
|
+
const pool = new Pool(poolConfig);
|
|
376
|
+
try {
|
|
377
|
+
const res = await pool.query(options.query || options.sql || "SELECT 1", options.params || []);
|
|
378
|
+
const rows = res.rows;
|
|
379
|
+
const maxRows = options.max_rows ?? 1000;
|
|
380
|
+
return { raw: rows.slice(0, maxRows), mapped: rows.slice(0, maxRows) };
|
|
381
|
+
}
|
|
382
|
+
finally {
|
|
383
|
+
await pool.end();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
if (e.code === "ERR_MODULE_NOT_FOUND" || e.message?.includes("pg")) {
|
|
388
|
+
throw new Error("pg package not installed. Add it as a dependency: npm install pg");
|
|
389
|
+
}
|
|
390
|
+
throw e;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (connectorId === "redis.system") {
|
|
394
|
+
try {
|
|
395
|
+
const Redis = (await Promise.resolve().then(() => __importStar(require("ioredis")))).default;
|
|
396
|
+
const url = config.uri || config.url;
|
|
397
|
+
if (!url)
|
|
398
|
+
throw new Error("Redis URL not configured for redis.system");
|
|
399
|
+
const client = new Redis(url);
|
|
400
|
+
try {
|
|
401
|
+
const actionMethod = actionName.split(".").pop() || actionName;
|
|
402
|
+
let result;
|
|
403
|
+
switch (actionMethod) {
|
|
404
|
+
case "get": {
|
|
405
|
+
const val = await client.get(options.key);
|
|
406
|
+
if (val === null)
|
|
407
|
+
result = null;
|
|
408
|
+
else {
|
|
409
|
+
try {
|
|
410
|
+
result = JSON.parse(val);
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
result = val;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
case "set": {
|
|
419
|
+
const strVal = typeof options.value === "string" ? options.value : JSON.stringify(options.value);
|
|
420
|
+
if (options.ttl && options.ttl > 0)
|
|
421
|
+
await client.setex(options.key, options.ttl, strVal);
|
|
422
|
+
else
|
|
423
|
+
await client.set(options.key, strVal);
|
|
424
|
+
result = { ok: true };
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
case "delete":
|
|
428
|
+
case "delete_key": {
|
|
429
|
+
const n = await client.del(options.key);
|
|
430
|
+
result = { deleted: n > 0, count: n };
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
case "hset": {
|
|
434
|
+
const hv = typeof options.value === "string" ? options.value : JSON.stringify(options.value);
|
|
435
|
+
await client.hset(options.key, options.field, hv);
|
|
436
|
+
result = { ok: true };
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
case "hget": {
|
|
440
|
+
const hv = await client.hget(options.key, options.field);
|
|
441
|
+
if (hv === null)
|
|
442
|
+
result = null;
|
|
443
|
+
else {
|
|
444
|
+
try {
|
|
445
|
+
result = JSON.parse(hv);
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
result = hv;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
case "lpush": {
|
|
454
|
+
const lv = typeof options.value === "string" ? options.value : JSON.stringify(options.value);
|
|
455
|
+
await client.lpush(options.key, lv);
|
|
456
|
+
result = { ok: true };
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
case "lpop": {
|
|
460
|
+
result = await client.lpop(options.key);
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case "zadd": {
|
|
464
|
+
await client.zadd(options.key, options.score, options.member);
|
|
465
|
+
result = { ok: true };
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
case "create_hash": {
|
|
469
|
+
const vals = options.values || {};
|
|
470
|
+
for (const [f, v] of Object.entries(vals)) {
|
|
471
|
+
await client.hset(options.key, f, typeof v === "string" ? v : JSON.stringify(v));
|
|
472
|
+
}
|
|
473
|
+
result = { ok: true };
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
default:
|
|
477
|
+
throw new Error("Unsupported Redis action: " + actionMethod);
|
|
478
|
+
}
|
|
479
|
+
return { raw: result, mapped: result };
|
|
480
|
+
}
|
|
481
|
+
finally {
|
|
482
|
+
await client.quit();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
catch (e) {
|
|
486
|
+
if (e.code === "ERR_MODULE_NOT_FOUND" || e.message?.includes("ioredis")) {
|
|
487
|
+
throw new Error("ioredis package not installed. Add it as a dependency: npm install ioredis");
|
|
488
|
+
}
|
|
489
|
+
throw e;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
throw new Error("Unsupported database connector: " + connectorId);
|
|
493
|
+
}
|
|
494
|
+
function bearerExpiresAtFromExpiresIn(expiresIn) {
|
|
495
|
+
if (typeof expiresIn === "string") {
|
|
496
|
+
const match = expiresIn.match(/^(\d+)([smhd])$/);
|
|
497
|
+
if (match) {
|
|
498
|
+
const value = parseInt(match[1], 10);
|
|
499
|
+
const unit = match[2];
|
|
500
|
+
const multipliers = {
|
|
501
|
+
s: 1000,
|
|
502
|
+
m: 60 * 1000,
|
|
503
|
+
h: 60 * 60 * 1000,
|
|
504
|
+
d: 24 * 60 * 60 * 1000,
|
|
505
|
+
};
|
|
506
|
+
return Date.now() + value * (multipliers[unit] || 1000);
|
|
507
|
+
}
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
if (typeof expiresIn === "number") {
|
|
511
|
+
return Date.now() + expiresIn * 1000;
|
|
512
|
+
}
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
async function executeAuthConnector(connectorDef, actionName, options, context) {
|
|
516
|
+
const authType = connectorDef._id?.split(".")[0] || "bearer";
|
|
517
|
+
const opts = options.body || options;
|
|
518
|
+
const tokenFromHeader = context.headers?.authorization?.replace(/^Bearer\s+/i, "");
|
|
519
|
+
const token = opts.token ?? tokenFromHeader ?? context.token;
|
|
520
|
+
const actionMethodRaw = actionName.split(".").pop() || "validate";
|
|
521
|
+
const actionMethod = actionMethodRaw.toLowerCase();
|
|
522
|
+
if (authType === "bearer") {
|
|
523
|
+
if (actionMethod === "create") {
|
|
524
|
+
const headerName = opts.header_name || "Authorization";
|
|
525
|
+
const prefix = opts.prefix ?? "Bearer ";
|
|
526
|
+
const secret = opts.token_secret ?? opts.tokenSecret;
|
|
527
|
+
if (secret) {
|
|
528
|
+
const payload = opts.payload ?? context?.payload ?? {};
|
|
529
|
+
const expiresIn = opts.expires_in ?? opts.expiresIn ?? context?.expiresIn ?? "1h";
|
|
530
|
+
const defaultPayload = {
|
|
531
|
+
sub: payload?.sub ?? payload?.id ?? "workflow",
|
|
532
|
+
iat: Math.floor(Date.now() / 1000),
|
|
533
|
+
...payload,
|
|
534
|
+
};
|
|
535
|
+
try {
|
|
536
|
+
const signOpts = typeof expiresIn === "number"
|
|
537
|
+
? { expiresIn }
|
|
538
|
+
: { expiresIn: String(expiresIn) };
|
|
539
|
+
const signed = jsonwebtoken_1.default.sign(defaultPayload, secret, signOpts);
|
|
540
|
+
const expiresAtMs = bearerExpiresAtFromExpiresIn(typeof expiresIn === "number" ? expiresIn : String(expiresIn));
|
|
541
|
+
const expiresAtIso = expiresAtMs != null ? new Date(expiresAtMs).toISOString() : null;
|
|
542
|
+
return {
|
|
543
|
+
ok: true,
|
|
544
|
+
valid: true,
|
|
545
|
+
token: signed,
|
|
546
|
+
token_type: "Bearer",
|
|
547
|
+
expires_in: expiresIn,
|
|
548
|
+
expires_at: expiresAtIso,
|
|
549
|
+
payload: defaultPayload,
|
|
550
|
+
formatted_token: `${prefix}${signed}`,
|
|
551
|
+
auth: {
|
|
552
|
+
type: "bearer",
|
|
553
|
+
header_name: headerName,
|
|
554
|
+
prefix,
|
|
555
|
+
value: `${prefix}${signed}`,
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
catch (e) {
|
|
560
|
+
return {
|
|
561
|
+
ok: false,
|
|
562
|
+
valid: false,
|
|
563
|
+
error: e?.message || "Failed to create bearer token",
|
|
564
|
+
message: "Failed to create bearer token",
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const createdToken = opts.token ?? token;
|
|
569
|
+
if (!createdToken) {
|
|
570
|
+
return { valid: false, ok: false, error: "Bearer token not provided", message: "Token is required" };
|
|
571
|
+
}
|
|
572
|
+
const expiresInOpaque = opts.expires_in ?? null;
|
|
573
|
+
return {
|
|
574
|
+
ok: true,
|
|
575
|
+
valid: true,
|
|
576
|
+
token: createdToken,
|
|
577
|
+
auth: {
|
|
578
|
+
type: "bearer",
|
|
579
|
+
header_name: headerName,
|
|
580
|
+
prefix,
|
|
581
|
+
value: `${prefix}${createdToken}`,
|
|
582
|
+
...(expiresInOpaque != null ? { expires_in: expiresInOpaque } : {}),
|
|
583
|
+
},
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (actionMethod === "validate") {
|
|
587
|
+
if (!token) {
|
|
588
|
+
return { valid: false, ok: false, error: "Bearer token not provided", message: "Token is required" };
|
|
589
|
+
}
|
|
590
|
+
const validateSecret = opts.token_secret ?? opts.tokenSecret;
|
|
591
|
+
if (validateSecret) {
|
|
592
|
+
try {
|
|
593
|
+
const decoded = jsonwebtoken_1.default.verify(token, validateSecret);
|
|
594
|
+
return {
|
|
595
|
+
valid: true,
|
|
596
|
+
ok: true,
|
|
597
|
+
token,
|
|
598
|
+
decoded,
|
|
599
|
+
payload: decoded,
|
|
600
|
+
message: "Token is valid",
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
catch (error) {
|
|
604
|
+
let decodedPayload = null;
|
|
605
|
+
try {
|
|
606
|
+
decodedPayload = jsonwebtoken_1.default.decode(token, { complete: false });
|
|
607
|
+
}
|
|
608
|
+
catch { }
|
|
609
|
+
return {
|
|
610
|
+
valid: false,
|
|
611
|
+
ok: false,
|
|
612
|
+
token: null,
|
|
613
|
+
decoded: decodedPayload,
|
|
614
|
+
payload: decodedPayload,
|
|
615
|
+
error: error?.message || "Token validation failed",
|
|
616
|
+
message: "Token is invalid or expired",
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const requiredPrefix = opts.required_prefix;
|
|
621
|
+
const rawAuthHeader = context.headers?.authorization || "";
|
|
622
|
+
if (requiredPrefix && rawAuthHeader && !rawAuthHeader.startsWith(requiredPrefix)) {
|
|
623
|
+
return { valid: false, ok: false, token, error: "Bearer token prefix mismatch" };
|
|
624
|
+
}
|
|
625
|
+
return { valid: true, ok: true, token, message: "Token accepted" };
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (authType === "api_key") {
|
|
629
|
+
const keyName = opts.name || "x-api-key";
|
|
630
|
+
const keyFromHeader = context.headers?.[keyName] ?? context.headers?.["x-api-key"];
|
|
631
|
+
const keyFromQuery = context.query?.[keyName] ?? context.params?.[keyName];
|
|
632
|
+
const key = opts.api_key ?? opts.token ?? keyFromHeader ?? keyFromQuery ?? token;
|
|
633
|
+
if (actionMethod === "create") {
|
|
634
|
+
if (!key) {
|
|
635
|
+
return { valid: false, ok: false, error: "API key not provided" };
|
|
636
|
+
}
|
|
637
|
+
const inLocation = opts.in || "header";
|
|
638
|
+
const prefix = opts.prefix || "";
|
|
639
|
+
return {
|
|
640
|
+
valid: true,
|
|
641
|
+
ok: true,
|
|
642
|
+
token: key,
|
|
643
|
+
auth: {
|
|
644
|
+
type: "api_key",
|
|
645
|
+
in: inLocation,
|
|
646
|
+
name: keyName,
|
|
647
|
+
value: `${prefix}${key}`,
|
|
648
|
+
},
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
if (!key) {
|
|
652
|
+
return { valid: false, ok: false, error: "API key not provided" };
|
|
653
|
+
}
|
|
654
|
+
return { valid: true, ok: true, token: key, name: keyName };
|
|
655
|
+
}
|
|
656
|
+
if (authType === "basic") {
|
|
657
|
+
const username = opts.username ?? opts.user;
|
|
658
|
+
const password = opts.password;
|
|
659
|
+
if (actionMethod === "create") {
|
|
660
|
+
if (!username || !password) {
|
|
661
|
+
return { valid: false, ok: false, error: "Username and password are required" };
|
|
662
|
+
}
|
|
663
|
+
const value = `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`;
|
|
664
|
+
return {
|
|
665
|
+
valid: true,
|
|
666
|
+
ok: true,
|
|
667
|
+
auth: { type: "basic", username, value },
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
const expectedUsername = opts.expected_username ?? opts.username;
|
|
671
|
+
const expectedPassword = opts.expected_password ?? opts.password;
|
|
672
|
+
const basicHeader = context.headers?.authorization || "";
|
|
673
|
+
let providedUsername = opts.username;
|
|
674
|
+
let providedPassword = opts.password;
|
|
675
|
+
if ((!providedUsername || !providedPassword) && basicHeader.startsWith("Basic ")) {
|
|
676
|
+
try {
|
|
677
|
+
const decoded = Buffer.from(basicHeader.replace(/^Basic\s+/i, ""), "base64").toString("utf8");
|
|
678
|
+
const parts = decoded.split(":");
|
|
679
|
+
providedUsername = providedUsername ?? parts[0];
|
|
680
|
+
providedPassword = providedPassword ?? parts.slice(1).join(":");
|
|
681
|
+
}
|
|
682
|
+
catch { }
|
|
683
|
+
}
|
|
684
|
+
if (expectedUsername && expectedPassword) {
|
|
685
|
+
const isValid = providedUsername === expectedUsername && providedPassword === expectedPassword;
|
|
686
|
+
return { valid: isValid, ok: isValid, username: providedUsername };
|
|
687
|
+
}
|
|
688
|
+
const present = Boolean(providedUsername && providedPassword);
|
|
689
|
+
return { valid: present, ok: present, username: providedUsername };
|
|
690
|
+
}
|
|
691
|
+
if (authType === "custom_header") {
|
|
692
|
+
const headers = (opts.headers || {});
|
|
693
|
+
if (actionMethod === "create") {
|
|
694
|
+
return {
|
|
695
|
+
valid: true,
|
|
696
|
+
ok: true,
|
|
697
|
+
auth: {
|
|
698
|
+
type: "custom_header",
|
|
699
|
+
headers,
|
|
700
|
+
},
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
const requiredHeaders = Array.isArray(opts.required_headers) ? opts.required_headers : Object.keys(headers);
|
|
704
|
+
const sourceHeaders = context.headers || {};
|
|
705
|
+
const missing = requiredHeaders.filter((h) => sourceHeaders[h] == null);
|
|
706
|
+
if (missing.length > 0) {
|
|
707
|
+
return { valid: false, ok: false, error: `Missing required headers: ${missing.join(", ")}` };
|
|
708
|
+
}
|
|
709
|
+
return { valid: true, ok: true };
|
|
710
|
+
}
|
|
711
|
+
return { valid: true, ok: true };
|
|
712
|
+
}
|
|
713
|
+
function areDeepEqual(obj1, obj2, ignoreKeys) {
|
|
714
|
+
if (obj1 === obj2)
|
|
715
|
+
return true;
|
|
716
|
+
if (obj1 == null || obj2 == null)
|
|
717
|
+
return false;
|
|
718
|
+
if (typeof obj1 !== typeof obj2)
|
|
719
|
+
return false;
|
|
720
|
+
if (Array.isArray(obj1) && Array.isArray(obj2)) {
|
|
721
|
+
if (obj1.length !== obj2.length)
|
|
722
|
+
return false;
|
|
723
|
+
for (let i = 0; i < obj1.length; i++) {
|
|
724
|
+
if (!areDeepEqual(obj1[i], obj2[i], ignoreKeys))
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
if (typeof obj1 === "object") {
|
|
730
|
+
const keys1 = Object.keys(obj1).filter((k) => !ignoreKeys?.includes(k));
|
|
731
|
+
const keys2 = Object.keys(obj2).filter((k) => !ignoreKeys?.includes(k));
|
|
732
|
+
if (keys1.length !== keys2.length)
|
|
733
|
+
return false;
|
|
734
|
+
for (const key of keys1) {
|
|
735
|
+
if (!keys2.includes(key))
|
|
736
|
+
return false;
|
|
737
|
+
if (!areDeepEqual(obj1[key], obj2[key], ignoreKeys))
|
|
738
|
+
return false;
|
|
739
|
+
}
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
function levenshteinDistance(str1, str2) {
|
|
745
|
+
const matrix = [];
|
|
746
|
+
for (let i = 0; i <= str2.length; i++)
|
|
747
|
+
matrix[i] = [i];
|
|
748
|
+
for (let j = 0; j <= str1.length; j++)
|
|
749
|
+
matrix[0][j] = j;
|
|
750
|
+
for (let i = 1; i <= str2.length; i++) {
|
|
751
|
+
for (let j = 1; j <= str1.length; j++) {
|
|
752
|
+
if (str2.charAt(i - 1) === str1.charAt(j - 1)) {
|
|
753
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return matrix[str2.length][str1.length];
|
|
761
|
+
}
|
|
762
|
+
function levenshteinSimilarity(str1, str2) {
|
|
763
|
+
const maxLen = Math.max(str1.length, str2.length);
|
|
764
|
+
if (maxLen === 0)
|
|
765
|
+
return 1;
|
|
766
|
+
return 1 - levenshteinDistance(str1, str2) / maxLen;
|
|
767
|
+
}
|
|
768
|
+
function executeCompare(opts, actionMethod) {
|
|
769
|
+
switch (actionMethod) {
|
|
770
|
+
case "diff_objects": {
|
|
771
|
+
const { object1, object2, deep = true, ignore_keys = [], include_added = true, include_removed = true, include_changed = true } = opts;
|
|
772
|
+
if (!object1 || !object2)
|
|
773
|
+
throw new Error("Both objects are required");
|
|
774
|
+
const diff = {};
|
|
775
|
+
const allKeys = new Set([...Object.keys(object1), ...Object.keys(object2)]);
|
|
776
|
+
for (const key of allKeys) {
|
|
777
|
+
if (ignore_keys.includes(key))
|
|
778
|
+
continue;
|
|
779
|
+
const val1 = object1[key];
|
|
780
|
+
const val2 = object2[key];
|
|
781
|
+
const has1 = key in object1;
|
|
782
|
+
const has2 = key in object2;
|
|
783
|
+
if (!has1 && has2 && include_added)
|
|
784
|
+
diff[key] = { type: "added", value: val2 };
|
|
785
|
+
else if (has1 && !has2 && include_removed)
|
|
786
|
+
diff[key] = { type: "removed", value: val1 };
|
|
787
|
+
else if (has1 && has2 && include_changed) {
|
|
788
|
+
const changed = deep ? !areDeepEqual(val1, val2, ignore_keys) : val1 !== val2;
|
|
789
|
+
if (changed)
|
|
790
|
+
diff[key] = { type: "changed", old: val1, new: val2 };
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return { diff, has_changes: Object.keys(diff).length > 0 };
|
|
794
|
+
}
|
|
795
|
+
case "diff_arrays": {
|
|
796
|
+
const { array1, array2, compare_order = false, deep = true, include_added = true, include_removed = true, include_changed = true } = opts;
|
|
797
|
+
if (!Array.isArray(array1) || !Array.isArray(array2))
|
|
798
|
+
throw new Error("Both arrays are required");
|
|
799
|
+
const diff = { added: [], removed: [], changed: [] };
|
|
800
|
+
if (compare_order) {
|
|
801
|
+
const maxLen = Math.max(array1.length, array2.length);
|
|
802
|
+
for (let i = 0; i < maxLen; i++) {
|
|
803
|
+
if (i >= array1.length && include_added)
|
|
804
|
+
diff.added.push({ index: i, value: array2[i] });
|
|
805
|
+
else if (i >= array2.length && include_removed)
|
|
806
|
+
diff.removed.push({ index: i, value: array1[i] });
|
|
807
|
+
else if (include_changed) {
|
|
808
|
+
const changed = deep ? !areDeepEqual(array1[i], array2[i]) : array1[i] !== array2[i];
|
|
809
|
+
if (changed)
|
|
810
|
+
diff.changed.push({ index: i, old: array1[i], new: array2[i] });
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
for (const item of array2) {
|
|
816
|
+
if (!array1.some((a) => (deep ? areDeepEqual(a, item) : a === item)) && include_added)
|
|
817
|
+
diff.added.push({ value: item });
|
|
818
|
+
}
|
|
819
|
+
for (const item of array1) {
|
|
820
|
+
if (!array2.some((a) => (deep ? areDeepEqual(a, item) : a === item)) && include_removed)
|
|
821
|
+
diff.removed.push({ value: item });
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return { diff, has_changes: diff.added.length > 0 || diff.removed.length > 0 || diff.changed.length > 0 };
|
|
825
|
+
}
|
|
826
|
+
case "compare_strings": {
|
|
827
|
+
const { string1, string2, case_sensitive = true, trim = false, method = "exact" } = opts;
|
|
828
|
+
if (string1 === undefined || string2 === undefined)
|
|
829
|
+
throw new Error("Both strings are required");
|
|
830
|
+
let s1 = String(string1);
|
|
831
|
+
let s2 = String(string2);
|
|
832
|
+
if (trim) {
|
|
833
|
+
s1 = s1.trim();
|
|
834
|
+
s2 = s2.trim();
|
|
835
|
+
}
|
|
836
|
+
if (!case_sensitive) {
|
|
837
|
+
s1 = s1.toLowerCase();
|
|
838
|
+
s2 = s2.toLowerCase();
|
|
839
|
+
}
|
|
840
|
+
if (method === "exact")
|
|
841
|
+
return { equal: s1 === s2, similarity: s1 === s2 ? 1 : 0 };
|
|
842
|
+
if (method === "contains")
|
|
843
|
+
return { contains: s1.includes(s2) || s2.includes(s1) };
|
|
844
|
+
if (method === "similarity")
|
|
845
|
+
return { similarity: levenshteinSimilarity(s1, s2) };
|
|
846
|
+
return { equal: s1 === s2 };
|
|
847
|
+
}
|
|
848
|
+
case "compare_numbers": {
|
|
849
|
+
const { number1, number2, tolerance = 0, operator = "==" } = opts;
|
|
850
|
+
if (number1 === undefined || number2 === undefined)
|
|
851
|
+
throw new Error("Both numbers are required");
|
|
852
|
+
const n1 = Number(number1);
|
|
853
|
+
const n2 = Number(number2);
|
|
854
|
+
const diff = Math.abs(n1 - n2);
|
|
855
|
+
let result = false;
|
|
856
|
+
if (operator === "==")
|
|
857
|
+
result = diff <= tolerance;
|
|
858
|
+
else if (operator === "!=")
|
|
859
|
+
result = diff > tolerance;
|
|
860
|
+
else if (operator === ">")
|
|
861
|
+
result = n1 > n2;
|
|
862
|
+
else if (operator === ">=")
|
|
863
|
+
result = n1 >= n2;
|
|
864
|
+
else if (operator === "<")
|
|
865
|
+
result = n1 < n2;
|
|
866
|
+
else if (operator === "<=")
|
|
867
|
+
result = n1 <= n2;
|
|
868
|
+
return { result, difference: diff };
|
|
869
|
+
}
|
|
870
|
+
case "compare_dates": {
|
|
871
|
+
const { date1, date2, operator = "==", tolerance_seconds = 0 } = opts;
|
|
872
|
+
if (!date1 || !date2)
|
|
873
|
+
throw new Error("Both dates are required");
|
|
874
|
+
const d1 = new Date(date1).getTime();
|
|
875
|
+
const d2 = new Date(date2).getTime();
|
|
876
|
+
const diff = Math.abs(d1 - d2) / 1000;
|
|
877
|
+
let result = false;
|
|
878
|
+
if (operator === "==")
|
|
879
|
+
result = diff <= tolerance_seconds;
|
|
880
|
+
else if (operator === "!=")
|
|
881
|
+
result = diff > tolerance_seconds;
|
|
882
|
+
else if (operator === ">")
|
|
883
|
+
result = d1 > d2;
|
|
884
|
+
else if (operator === ">=")
|
|
885
|
+
result = d1 >= d2;
|
|
886
|
+
else if (operator === "<")
|
|
887
|
+
result = d1 < d2;
|
|
888
|
+
else if (operator === "<=")
|
|
889
|
+
result = d1 <= d2;
|
|
890
|
+
return { result, difference_seconds: diff };
|
|
891
|
+
}
|
|
892
|
+
case "is_changed": {
|
|
893
|
+
const { value1, value2, deep = true, ignore_keys = [] } = opts;
|
|
894
|
+
if (value1 === undefined || value2 === undefined)
|
|
895
|
+
throw new Error("Both values are required");
|
|
896
|
+
return { changed: deep ? !areDeepEqual(value1, value2, ignore_keys) : value1 !== value2 };
|
|
897
|
+
}
|
|
898
|
+
case "is_equal": {
|
|
899
|
+
const { value1, value2, deep = true, strict = true, ignore_keys = [] } = opts;
|
|
900
|
+
if (value1 === undefined || value2 === undefined)
|
|
901
|
+
throw new Error("Both values are required");
|
|
902
|
+
if (strict && !deep)
|
|
903
|
+
return { equal: value1 === value2 };
|
|
904
|
+
return { equal: deep ? areDeepEqual(value1, value2, ignore_keys) : value1 == value2 };
|
|
905
|
+
}
|
|
906
|
+
case "is_not_equal": {
|
|
907
|
+
const { value1, value2, deep = true, strict = true, ignore_keys = [] } = opts;
|
|
908
|
+
if (value1 === undefined || value2 === undefined)
|
|
909
|
+
throw new Error("Both values are required");
|
|
910
|
+
if (strict && !deep)
|
|
911
|
+
return { not_equal: value1 !== value2 };
|
|
912
|
+
const equal = deep ? areDeepEqual(value1, value2, ignore_keys) : value1 == value2;
|
|
913
|
+
return { not_equal: !equal };
|
|
914
|
+
}
|
|
915
|
+
case "is_greater_than": {
|
|
916
|
+
const { value1, value2, or_equal = false } = opts;
|
|
917
|
+
if (value1 === undefined || value2 === undefined)
|
|
918
|
+
throw new Error("Both values are required");
|
|
919
|
+
return { result: or_equal ? value1 >= value2 : value1 > value2 };
|
|
920
|
+
}
|
|
921
|
+
case "is_less_than": {
|
|
922
|
+
const { value1, value2, or_equal = false } = opts;
|
|
923
|
+
if (value1 === undefined || value2 === undefined)
|
|
924
|
+
throw new Error("Both values are required");
|
|
925
|
+
return { result: or_equal ? value1 <= value2 : value1 < value2 };
|
|
926
|
+
}
|
|
927
|
+
case "is_between": {
|
|
928
|
+
const { value, min, max, inclusive = true } = opts;
|
|
929
|
+
if (value === undefined || min === undefined || max === undefined)
|
|
930
|
+
throw new Error("Value, min, and max are required");
|
|
931
|
+
return { result: inclusive ? value >= min && value <= max : value > min && value < max };
|
|
932
|
+
}
|
|
933
|
+
case "is_empty": {
|
|
934
|
+
const { value, check_whitespace = true } = opts;
|
|
935
|
+
if (value === undefined)
|
|
936
|
+
throw new Error("Value is required");
|
|
937
|
+
if (value == null)
|
|
938
|
+
return { empty: true };
|
|
939
|
+
if (Array.isArray(value))
|
|
940
|
+
return { empty: value.length === 0 };
|
|
941
|
+
if (typeof value === "object")
|
|
942
|
+
return { empty: Object.keys(value).length === 0 };
|
|
943
|
+
if (typeof value === "string")
|
|
944
|
+
return { empty: check_whitespace ? value.trim().length === 0 : value.length === 0 };
|
|
945
|
+
return { empty: false };
|
|
946
|
+
}
|
|
947
|
+
case "is_null_or_undefined":
|
|
948
|
+
return { is_null_or_undefined: opts.value == null };
|
|
949
|
+
case "is_same_type": {
|
|
950
|
+
const { value1, value2 } = opts;
|
|
951
|
+
if (value1 === undefined || value2 === undefined)
|
|
952
|
+
throw new Error("Both values are required");
|
|
953
|
+
return { same_type: typeof value1 === typeof value2 };
|
|
954
|
+
}
|
|
955
|
+
case "deep_equal": {
|
|
956
|
+
const { value1, value2, ignore_keys = [], ignore_order = false } = opts;
|
|
957
|
+
if (value1 === undefined || value2 === undefined)
|
|
958
|
+
throw new Error("Both values are required");
|
|
959
|
+
if (ignore_order && Array.isArray(value1) && Array.isArray(value2)) {
|
|
960
|
+
if (value1.length !== value2.length)
|
|
961
|
+
return { equal: false };
|
|
962
|
+
const sorted1 = [...value1].sort();
|
|
963
|
+
const sorted2 = [...value2].sort();
|
|
964
|
+
return { equal: areDeepEqual(sorted1, sorted2, ignore_keys) };
|
|
965
|
+
}
|
|
966
|
+
return { equal: areDeepEqual(value1, value2, ignore_keys) };
|
|
967
|
+
}
|
|
968
|
+
case "shallow_equal": {
|
|
969
|
+
const { value1, value2 } = opts;
|
|
970
|
+
if (value1 === undefined || value2 === undefined)
|
|
971
|
+
throw new Error("Both values are required");
|
|
972
|
+
return { equal: value1 === value2 };
|
|
973
|
+
}
|
|
974
|
+
case "similarity_score": {
|
|
975
|
+
const { string1, string2, case_sensitive = false } = opts;
|
|
976
|
+
if (!string1 || !string2)
|
|
977
|
+
throw new Error("Both strings are required");
|
|
978
|
+
const s1 = case_sensitive ? string1 : String(string1).toLowerCase();
|
|
979
|
+
const s2 = case_sensitive ? string2 : String(string2).toLowerCase();
|
|
980
|
+
return { similarity: levenshteinSimilarity(s1, s2) };
|
|
981
|
+
}
|
|
982
|
+
case "array_intersection": {
|
|
983
|
+
const { array1, array2, deep = false, unique = true } = opts;
|
|
984
|
+
if (!Array.isArray(array1) || !Array.isArray(array2))
|
|
985
|
+
throw new Error("Both arrays are required");
|
|
986
|
+
const intersection = [];
|
|
987
|
+
for (const item1 of array1) {
|
|
988
|
+
if (array2.some((item2) => (deep ? areDeepEqual(item1, item2) : item1 === item2))) {
|
|
989
|
+
if (unique && !intersection.some((item) => (deep ? areDeepEqual(item, item1) : item === item1)))
|
|
990
|
+
intersection.push(item1);
|
|
991
|
+
else if (!unique)
|
|
992
|
+
intersection.push(item1);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return { intersection };
|
|
996
|
+
}
|
|
997
|
+
case "array_union": {
|
|
998
|
+
const { array1, array2, deep = false } = opts;
|
|
999
|
+
if (!Array.isArray(array1) || !Array.isArray(array2))
|
|
1000
|
+
throw new Error("Both arrays are required");
|
|
1001
|
+
const union = [...array1];
|
|
1002
|
+
for (const item2 of array2) {
|
|
1003
|
+
if (!union.some((item) => (deep ? areDeepEqual(item, item2) : item === item2)))
|
|
1004
|
+
union.push(item2);
|
|
1005
|
+
}
|
|
1006
|
+
return { union };
|
|
1007
|
+
}
|
|
1008
|
+
case "array_difference": {
|
|
1009
|
+
const { array1, array2, deep = false } = opts;
|
|
1010
|
+
if (!Array.isArray(array1) || !Array.isArray(array2))
|
|
1011
|
+
throw new Error("Both arrays are required");
|
|
1012
|
+
const difference = [];
|
|
1013
|
+
for (const item1 of array1) {
|
|
1014
|
+
if (!array2.some((item2) => (deep ? areDeepEqual(item1, item2) : item1 === item2)))
|
|
1015
|
+
difference.push(item1);
|
|
1016
|
+
}
|
|
1017
|
+
return { difference };
|
|
1018
|
+
}
|
|
1019
|
+
default:
|
|
1020
|
+
throw new Error("Unsupported compare action: " + actionMethod);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function executeGeo(opts, actionMethod) {
|
|
1024
|
+
const toRad = (deg) => (deg * Math.PI) / 180;
|
|
1025
|
+
const haversine = (lat1, lon1, lat2, lon2) => {
|
|
1026
|
+
const R = 6371;
|
|
1027
|
+
const dLat = toRad(lat2 - lat1);
|
|
1028
|
+
const dLon = toRad(lon2 - lon1);
|
|
1029
|
+
const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
1030
|
+
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
1031
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
1032
|
+
return R * c;
|
|
1033
|
+
};
|
|
1034
|
+
const equirectangular = (lat1, lon1, lat2, lon2) => {
|
|
1035
|
+
const R = 6371;
|
|
1036
|
+
const dLat = toRad(lat2 - lat1);
|
|
1037
|
+
const dLon = toRad(lon2 - lon1);
|
|
1038
|
+
const avgLat = toRad((lat1 + lat2) / 2);
|
|
1039
|
+
const x = dLon * Math.cos(avgLat);
|
|
1040
|
+
const y = dLat;
|
|
1041
|
+
return R * Math.sqrt(x * x + y * y);
|
|
1042
|
+
};
|
|
1043
|
+
const conversions = {
|
|
1044
|
+
km: 1,
|
|
1045
|
+
miles: 0.621371,
|
|
1046
|
+
meters: 1000,
|
|
1047
|
+
feet: 3280.84,
|
|
1048
|
+
nautical_miles: 0.539957,
|
|
1049
|
+
};
|
|
1050
|
+
switch (actionMethod) {
|
|
1051
|
+
case "calculate_distance": {
|
|
1052
|
+
const { lat1, lon1, lat2, lon2, unit = "km", formula = "haversine" } = opts;
|
|
1053
|
+
if (lat1 === undefined || lon1 === undefined || lat2 === undefined || lon2 === undefined)
|
|
1054
|
+
throw new Error("All coordinates (lat1, lon1, lat2, lon2) are required");
|
|
1055
|
+
const distance = formula === "equirectangular" ? equirectangular(lat1, lon1, lat2, lon2) : haversine(lat1, lon1, lat2, lon2);
|
|
1056
|
+
return { distance: distance * (conversions[unit] || 1), unit };
|
|
1057
|
+
}
|
|
1058
|
+
case "point_in_polygon": {
|
|
1059
|
+
const { point_lat, point_lon, polygon, format = "lat_lon" } = opts;
|
|
1060
|
+
if (point_lat === undefined || point_lon === undefined || !Array.isArray(polygon))
|
|
1061
|
+
throw new Error("Point coordinates and polygon array are required");
|
|
1062
|
+
const normalizedPolygon = polygon.map((point) => {
|
|
1063
|
+
if (format === "lon_lat" || format === "geojson")
|
|
1064
|
+
return [point[1], point[0]];
|
|
1065
|
+
return point;
|
|
1066
|
+
});
|
|
1067
|
+
let inside = false;
|
|
1068
|
+
for (let i = 0, j = normalizedPolygon.length - 1; i < normalizedPolygon.length; j = i++) {
|
|
1069
|
+
const [xi, yi] = normalizedPolygon[i];
|
|
1070
|
+
const [xj, yj] = normalizedPolygon[j];
|
|
1071
|
+
const intersect = yi > point_lat !== yj > point_lat && point_lon < ((xj - xi) * (point_lat - yi)) / (yj - yi) + xi;
|
|
1072
|
+
if (intersect)
|
|
1073
|
+
inside = !inside;
|
|
1074
|
+
}
|
|
1075
|
+
return { inside };
|
|
1076
|
+
}
|
|
1077
|
+
case "get_bounding_box": {
|
|
1078
|
+
const { points, format = "lat_lon", padding = 0, output_format = "bounds" } = opts;
|
|
1079
|
+
if (!Array.isArray(points) || points.length === 0)
|
|
1080
|
+
throw new Error("Points array is required and must not be empty");
|
|
1081
|
+
const normalizedPoints = points.map((point) => (format === "lon_lat" ? [point[1], point[0]] : point));
|
|
1082
|
+
let minLat = normalizedPoints[0][0];
|
|
1083
|
+
let maxLat = normalizedPoints[0][0];
|
|
1084
|
+
let minLon = normalizedPoints[0][1];
|
|
1085
|
+
let maxLon = normalizedPoints[0][1];
|
|
1086
|
+
for (const [lat, lon] of normalizedPoints) {
|
|
1087
|
+
minLat = Math.min(minLat, lat);
|
|
1088
|
+
maxLat = Math.max(maxLat, lat);
|
|
1089
|
+
minLon = Math.min(minLon, lon);
|
|
1090
|
+
maxLon = Math.max(maxLon, lon);
|
|
1091
|
+
}
|
|
1092
|
+
minLat -= padding;
|
|
1093
|
+
maxLat += padding;
|
|
1094
|
+
minLon -= padding;
|
|
1095
|
+
maxLon += padding;
|
|
1096
|
+
if (output_format === "bounds")
|
|
1097
|
+
return { north: maxLat, south: minLat, east: maxLon, west: minLon };
|
|
1098
|
+
if (output_format === "corners")
|
|
1099
|
+
return { corners: [[minLat, minLon], [minLat, maxLon], [maxLat, maxLon], [maxLat, minLon]] };
|
|
1100
|
+
return { type: "Polygon", coordinates: [[[minLon, minLat], [maxLon, minLat], [maxLon, maxLat], [minLon, maxLat], [minLon, minLat]]] };
|
|
1101
|
+
}
|
|
1102
|
+
case "reverse_geocode": {
|
|
1103
|
+
const { lat, lon, provider = "nominatim" } = opts;
|
|
1104
|
+
if (lat === undefined || lon === undefined)
|
|
1105
|
+
throw new Error("Latitude and longitude are required");
|
|
1106
|
+
return { address: `Location at ${lat}, ${lon}`, lat, lon, provider };
|
|
1107
|
+
}
|
|
1108
|
+
case "geocode": {
|
|
1109
|
+
const { address, provider = "nominatim", limit = 1 } = opts;
|
|
1110
|
+
if (!address)
|
|
1111
|
+
throw new Error("Address is required");
|
|
1112
|
+
return { results: [{ address, lat: 0, lon: 0, provider }], count: 1 };
|
|
1113
|
+
}
|
|
1114
|
+
case "convert_coordinates": {
|
|
1115
|
+
const { lat, lon, from_format = "decimal", to_format = "decimal", precision = 6 } = opts;
|
|
1116
|
+
if (lat === undefined || lon === undefined)
|
|
1117
|
+
throw new Error("Latitude and longitude are required");
|
|
1118
|
+
if (from_format === "decimal" && to_format === "decimal")
|
|
1119
|
+
return { lat: parseFloat(Number(lat).toFixed(precision)), lon: parseFloat(Number(lon).toFixed(precision)) };
|
|
1120
|
+
return { lat, lon, from_format, to_format, note: "Advanced conversions require additional implementation" };
|
|
1121
|
+
}
|
|
1122
|
+
default:
|
|
1123
|
+
throw new Error("Unsupported geo action: " + actionMethod);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
async function executeDateTime(opts, actionMethod) {
|
|
1127
|
+
const dayjs = (await Promise.resolve().then(() => __importStar(require("dayjs")))).default;
|
|
1128
|
+
const utc = (await Promise.resolve().then(() => __importStar(require("dayjs/plugin/utc")))).default;
|
|
1129
|
+
const timezone = (await Promise.resolve().then(() => __importStar(require("dayjs/plugin/timezone")))).default;
|
|
1130
|
+
const isLeapYear = (await Promise.resolve().then(() => __importStar(require("dayjs/plugin/isLeapYear")))).default;
|
|
1131
|
+
const isoWeek = (await Promise.resolve().then(() => __importStar(require("dayjs/plugin/isoWeek")))).default;
|
|
1132
|
+
const customParseFormat = (await Promise.resolve().then(() => __importStar(require("dayjs/plugin/customParseFormat")))).default;
|
|
1133
|
+
dayjs.extend(utc);
|
|
1134
|
+
dayjs.extend(timezone);
|
|
1135
|
+
dayjs.extend(isLeapYear);
|
|
1136
|
+
dayjs.extend(isoWeek);
|
|
1137
|
+
dayjs.extend(customParseFormat);
|
|
1138
|
+
switch (actionMethod) {
|
|
1139
|
+
case "get_current_date": {
|
|
1140
|
+
const { format = "YYYY-MM-DD", timezone: tz } = opts;
|
|
1141
|
+
let d = dayjs();
|
|
1142
|
+
if (tz)
|
|
1143
|
+
d = d.tz(tz);
|
|
1144
|
+
return { date: d.format(format) };
|
|
1145
|
+
}
|
|
1146
|
+
case "get_current_time": {
|
|
1147
|
+
const { format = "HH:mm:ss", timezone: tz } = opts;
|
|
1148
|
+
let d = dayjs();
|
|
1149
|
+
if (tz)
|
|
1150
|
+
d = d.tz(tz);
|
|
1151
|
+
return { time: d.format(format) };
|
|
1152
|
+
}
|
|
1153
|
+
case "get_current_datetime": {
|
|
1154
|
+
const { format = "YYYY-MM-DD HH:mm:ss", timezone: tz } = opts;
|
|
1155
|
+
let d = dayjs();
|
|
1156
|
+
if (tz)
|
|
1157
|
+
d = d.tz(tz);
|
|
1158
|
+
return { datetime: d.format(format), iso: d.toISOString() };
|
|
1159
|
+
}
|
|
1160
|
+
case "format":
|
|
1161
|
+
case "format_date": {
|
|
1162
|
+
const { date, format, input_format, timezone: tz } = opts;
|
|
1163
|
+
const value = date ?? opts.value ?? new Date().toISOString();
|
|
1164
|
+
if (!format)
|
|
1165
|
+
return { formatted: dayjs(value).toISOString() };
|
|
1166
|
+
let d = input_format ? dayjs(value, input_format) : dayjs(value);
|
|
1167
|
+
if (tz)
|
|
1168
|
+
d = d.tz(tz);
|
|
1169
|
+
return { formatted: d.format(format) };
|
|
1170
|
+
}
|
|
1171
|
+
case "parse_date": {
|
|
1172
|
+
const { date_string, format, timezone: tz } = opts;
|
|
1173
|
+
if (!date_string)
|
|
1174
|
+
throw new Error("Date string is required");
|
|
1175
|
+
let d = format ? dayjs(date_string, format) : dayjs(date_string);
|
|
1176
|
+
if (tz)
|
|
1177
|
+
d = d.tz(tz);
|
|
1178
|
+
return { parsed: d.toISOString(), timestamp: d.valueOf() };
|
|
1179
|
+
}
|
|
1180
|
+
case "add_time": {
|
|
1181
|
+
const { date, amount, unit, format } = opts;
|
|
1182
|
+
if (!date || amount === undefined || !unit)
|
|
1183
|
+
throw new Error("Date, amount, and unit are required");
|
|
1184
|
+
let d = dayjs(date).add(amount, unit);
|
|
1185
|
+
const result = { result: d.toISOString() };
|
|
1186
|
+
if (format)
|
|
1187
|
+
result.formatted = d.format(format);
|
|
1188
|
+
return result;
|
|
1189
|
+
}
|
|
1190
|
+
case "subtract_time": {
|
|
1191
|
+
const { date, amount, unit, format } = opts;
|
|
1192
|
+
if (!date || amount === undefined || !unit)
|
|
1193
|
+
throw new Error("Date, amount, and unit are required");
|
|
1194
|
+
let d = dayjs(date).subtract(amount, unit);
|
|
1195
|
+
const result = { result: d.toISOString() };
|
|
1196
|
+
if (format)
|
|
1197
|
+
result.formatted = d.format(format);
|
|
1198
|
+
return result;
|
|
1199
|
+
}
|
|
1200
|
+
case "diff_between_dates": {
|
|
1201
|
+
const { date1, date2, unit = "days", absolute = false } = opts;
|
|
1202
|
+
if (!date1 || !date2)
|
|
1203
|
+
throw new Error("Both dates are required");
|
|
1204
|
+
let diff = dayjs(date2).diff(dayjs(date1), unit);
|
|
1205
|
+
if (absolute)
|
|
1206
|
+
diff = Math.abs(diff);
|
|
1207
|
+
return { difference: diff, unit };
|
|
1208
|
+
}
|
|
1209
|
+
case "start_of_day": {
|
|
1210
|
+
const { date, format, timezone: tz } = opts;
|
|
1211
|
+
if (!date)
|
|
1212
|
+
throw new Error("Date is required");
|
|
1213
|
+
let d = dayjs(date).startOf("day");
|
|
1214
|
+
if (tz)
|
|
1215
|
+
d = d.tz(tz);
|
|
1216
|
+
const result = { result: d.toISOString() };
|
|
1217
|
+
if (format)
|
|
1218
|
+
result.formatted = d.format(format);
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
case "end_of_day": {
|
|
1222
|
+
const { date, format, timezone: tz } = opts;
|
|
1223
|
+
if (!date)
|
|
1224
|
+
throw new Error("Date is required");
|
|
1225
|
+
let d = dayjs(date).endOf("day");
|
|
1226
|
+
if (tz)
|
|
1227
|
+
d = d.tz(tz);
|
|
1228
|
+
const result = { result: d.toISOString() };
|
|
1229
|
+
if (format)
|
|
1230
|
+
result.formatted = d.format(format);
|
|
1231
|
+
return result;
|
|
1232
|
+
}
|
|
1233
|
+
case "start_of_week": {
|
|
1234
|
+
const { date, week_start = "monday", format, timezone: tz } = opts;
|
|
1235
|
+
if (!date)
|
|
1236
|
+
throw new Error("Date is required");
|
|
1237
|
+
let d = week_start === "monday" ? dayjs(date).startOf("isoWeek") : dayjs(date).startOf("week");
|
|
1238
|
+
if (tz)
|
|
1239
|
+
d = d.tz(tz);
|
|
1240
|
+
const result = { result: d.toISOString() };
|
|
1241
|
+
if (format)
|
|
1242
|
+
result.formatted = d.format(format);
|
|
1243
|
+
return result;
|
|
1244
|
+
}
|
|
1245
|
+
case "end_of_week": {
|
|
1246
|
+
const { date, week_start = "monday", format, timezone: tz } = opts;
|
|
1247
|
+
if (!date)
|
|
1248
|
+
throw new Error("Date is required");
|
|
1249
|
+
let d = week_start === "monday" ? dayjs(date).endOf("isoWeek") : dayjs(date).endOf("week");
|
|
1250
|
+
if (tz)
|
|
1251
|
+
d = d.tz(tz);
|
|
1252
|
+
const result = { result: d.toISOString() };
|
|
1253
|
+
if (format)
|
|
1254
|
+
result.formatted = d.format(format);
|
|
1255
|
+
return result;
|
|
1256
|
+
}
|
|
1257
|
+
case "start_of_month": {
|
|
1258
|
+
const { date, format, timezone: tz } = opts;
|
|
1259
|
+
if (!date)
|
|
1260
|
+
throw new Error("Date is required");
|
|
1261
|
+
let d = dayjs(date).startOf("month");
|
|
1262
|
+
if (tz)
|
|
1263
|
+
d = d.tz(tz);
|
|
1264
|
+
const result = { result: d.toISOString() };
|
|
1265
|
+
if (format)
|
|
1266
|
+
result.formatted = d.format(format);
|
|
1267
|
+
return result;
|
|
1268
|
+
}
|
|
1269
|
+
case "end_of_month": {
|
|
1270
|
+
const { date, format, timezone: tz } = opts;
|
|
1271
|
+
if (!date)
|
|
1272
|
+
throw new Error("Date is required");
|
|
1273
|
+
let d = dayjs(date).endOf("month");
|
|
1274
|
+
if (tz)
|
|
1275
|
+
d = d.tz(tz);
|
|
1276
|
+
const result = { result: d.toISOString() };
|
|
1277
|
+
if (format)
|
|
1278
|
+
result.formatted = d.format(format);
|
|
1279
|
+
return result;
|
|
1280
|
+
}
|
|
1281
|
+
case "start_of_year": {
|
|
1282
|
+
const { date, format, timezone: tz } = opts;
|
|
1283
|
+
if (!date)
|
|
1284
|
+
throw new Error("Date is required");
|
|
1285
|
+
let d = dayjs(date).startOf("year");
|
|
1286
|
+
if (tz)
|
|
1287
|
+
d = d.tz(tz);
|
|
1288
|
+
const result = { result: d.toISOString() };
|
|
1289
|
+
if (format)
|
|
1290
|
+
result.formatted = d.format(format);
|
|
1291
|
+
return result;
|
|
1292
|
+
}
|
|
1293
|
+
case "end_of_year": {
|
|
1294
|
+
const { date, format, timezone: tz } = opts;
|
|
1295
|
+
if (!date)
|
|
1296
|
+
throw new Error("Date is required");
|
|
1297
|
+
let d = dayjs(date).endOf("year");
|
|
1298
|
+
if (tz)
|
|
1299
|
+
d = d.tz(tz);
|
|
1300
|
+
const result = { result: d.toISOString() };
|
|
1301
|
+
if (format)
|
|
1302
|
+
result.formatted = d.format(format);
|
|
1303
|
+
return result;
|
|
1304
|
+
}
|
|
1305
|
+
case "convert_timezone": {
|
|
1306
|
+
const { date, from_timezone, to_timezone, format } = opts;
|
|
1307
|
+
if (!date || !to_timezone)
|
|
1308
|
+
throw new Error("Date and to_timezone are required");
|
|
1309
|
+
let d = from_timezone ? dayjs.tz(date, from_timezone) : dayjs(date);
|
|
1310
|
+
d = d.tz(to_timezone);
|
|
1311
|
+
const result = { result: d.toISOString() };
|
|
1312
|
+
if (format)
|
|
1313
|
+
result.formatted = d.format(format);
|
|
1314
|
+
return result;
|
|
1315
|
+
}
|
|
1316
|
+
case "get_timezone": {
|
|
1317
|
+
const { date } = opts;
|
|
1318
|
+
const d = date ? dayjs(date) : dayjs();
|
|
1319
|
+
return { timezone: d.format("z"), offset: d.utcOffset() };
|
|
1320
|
+
}
|
|
1321
|
+
case "list_timezones": {
|
|
1322
|
+
const { filter } = opts;
|
|
1323
|
+
let timezones = dayjs.tz.names();
|
|
1324
|
+
if (filter)
|
|
1325
|
+
timezones = timezones.filter((tz) => tz.toLowerCase().includes(filter.toLowerCase()));
|
|
1326
|
+
return { timezones };
|
|
1327
|
+
}
|
|
1328
|
+
case "is_leap_year": {
|
|
1329
|
+
const { year, date } = opts;
|
|
1330
|
+
const y = year || (date ? dayjs(date).year() : dayjs().year());
|
|
1331
|
+
return { is_leap_year: dayjs().year(y).isLeapYear(), year: y };
|
|
1332
|
+
}
|
|
1333
|
+
case "get_unix_timestamp": {
|
|
1334
|
+
const { date, unit = "seconds" } = opts;
|
|
1335
|
+
const d = date ? dayjs(date) : dayjs();
|
|
1336
|
+
const timestamp = unit === "milliseconds" ? d.valueOf() : d.unix();
|
|
1337
|
+
return { timestamp, unit };
|
|
1338
|
+
}
|
|
1339
|
+
case "from_unix_timestamp": {
|
|
1340
|
+
const { timestamp, unit = "seconds", format, timezone: tz } = opts;
|
|
1341
|
+
if (timestamp === undefined)
|
|
1342
|
+
throw new Error("Timestamp is required");
|
|
1343
|
+
let d = unit === "milliseconds" ? dayjs(timestamp) : dayjs.unix(timestamp);
|
|
1344
|
+
if (tz)
|
|
1345
|
+
d = d.tz(tz);
|
|
1346
|
+
const result = { result: d.toISOString() };
|
|
1347
|
+
if (format)
|
|
1348
|
+
result.formatted = d.format(format);
|
|
1349
|
+
return result;
|
|
1350
|
+
}
|
|
1351
|
+
default: {
|
|
1352
|
+
const now = dayjs();
|
|
1353
|
+
return { datetime: now.format("YYYY-MM-DD HH:mm:ss"), iso: now.toISOString() };
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
async function executeUtilityConnector(connectorDef, actionName, options, context) {
|
|
1358
|
+
const utilityType = connectorDef._id?.split(".").pop() || connectorDef._id?.split(".")[1] || "string";
|
|
1359
|
+
const opts = options.body || options;
|
|
1360
|
+
const actionMethod = actionName.split(".").pop() || actionName;
|
|
1361
|
+
let result;
|
|
1362
|
+
if (utilityType === "date_time") {
|
|
1363
|
+
result = await executeDateTime(opts, actionMethod);
|
|
1364
|
+
}
|
|
1365
|
+
else if (utilityType === "compare") {
|
|
1366
|
+
result = executeCompare(opts, actionMethod);
|
|
1367
|
+
}
|
|
1368
|
+
else if (utilityType === "geo") {
|
|
1369
|
+
result = executeGeo(opts, actionMethod);
|
|
1370
|
+
}
|
|
1371
|
+
else if (utilityType === "string") {
|
|
1372
|
+
result = (0, string_executor_1.executeString)(opts, actionMethod);
|
|
1373
|
+
}
|
|
1374
|
+
else if (utilityType === "random") {
|
|
1375
|
+
result = (0, random_executor_1.executeRandom)(opts, actionMethod);
|
|
1376
|
+
}
|
|
1377
|
+
else if (utilityType === "math") {
|
|
1378
|
+
result = (0, math_executor_1.executeMath)(opts, actionMethod);
|
|
1379
|
+
}
|
|
1380
|
+
else {
|
|
1381
|
+
result = { value: opts.value ?? null };
|
|
1382
|
+
}
|
|
1383
|
+
const mapped = result.value !== undefined
|
|
1384
|
+
? result.value
|
|
1385
|
+
: result.formatted !== undefined
|
|
1386
|
+
? result.formatted
|
|
1387
|
+
: result.datetime !== undefined
|
|
1388
|
+
? result.datetime
|
|
1389
|
+
: result.date !== undefined
|
|
1390
|
+
? result.date
|
|
1391
|
+
: result.time !== undefined
|
|
1392
|
+
? result.time
|
|
1393
|
+
: result;
|
|
1394
|
+
return { raw: result, mapped };
|
|
1395
|
+
}
|
|
1396
|
+
async function executeEncryptionConnector(connectorDef, actionName, options, context) {
|
|
1397
|
+
const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
|
|
1398
|
+
const encType = connectorDef._id?.split(".")[0] || "base64";
|
|
1399
|
+
const opts = options.body || options;
|
|
1400
|
+
const data = opts.data ?? opts.value ?? opts.string ?? "";
|
|
1401
|
+
const str = typeof data === "string" ? data : JSON.stringify(data);
|
|
1402
|
+
let result;
|
|
1403
|
+
if (encType === "base64") {
|
|
1404
|
+
const method = actionName.split(".").pop() || "encode";
|
|
1405
|
+
if (method === "encode") {
|
|
1406
|
+
const toEncode = opts.data ?? data;
|
|
1407
|
+
const inputStr = typeof toEncode === "string" ? toEncode : JSON.stringify(toEncode);
|
|
1408
|
+
result = { value: Buffer.from(inputStr, "utf-8").toString("base64") };
|
|
1409
|
+
}
|
|
1410
|
+
else {
|
|
1411
|
+
const encoded = opts.encoded_data ?? opts.data ?? data;
|
|
1412
|
+
result = { value: Buffer.from(String(encoded || ""), "base64").toString("utf-8") };
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
else if (encType === "hash") {
|
|
1416
|
+
const algo = opts.algorithm || (actionName.includes(".") ? actionName.split(".").pop() : "sha256") || "sha256";
|
|
1417
|
+
const outFmt = opts.output_format || "hex";
|
|
1418
|
+
const hash = crypto.createHash(algo).update(str).digest();
|
|
1419
|
+
const value = outFmt === "base64" ? hash.toString("base64") : hash.toString("hex");
|
|
1420
|
+
result = { value, hash: value, algorithm: algo, output_format: outFmt };
|
|
1421
|
+
}
|
|
1422
|
+
else if (encType === "aes") {
|
|
1423
|
+
result = await executeAes(crypto, actionName, opts, str);
|
|
1424
|
+
}
|
|
1425
|
+
else if (encType === "rsa") {
|
|
1426
|
+
result = await executeRsa(crypto, actionName, opts, str);
|
|
1427
|
+
}
|
|
1428
|
+
else if (encType === "hmac") {
|
|
1429
|
+
result = await executeHmac(crypto, actionName, opts, str);
|
|
1430
|
+
}
|
|
1431
|
+
else if (encType === "password") {
|
|
1432
|
+
result = await executePassword(actionName, opts, str);
|
|
1433
|
+
}
|
|
1434
|
+
else {
|
|
1435
|
+
result = { value: str };
|
|
1436
|
+
}
|
|
1437
|
+
const mapped = result.value !== undefined ? result.value : result;
|
|
1438
|
+
return { raw: result, mapped };
|
|
1439
|
+
}
|
|
1440
|
+
async function executeAes(crypto, actionName, opts, str) {
|
|
1441
|
+
const action = actionName.split(".").pop() || "";
|
|
1442
|
+
if (action === "encrypt") {
|
|
1443
|
+
const key = opts.key;
|
|
1444
|
+
if (!key)
|
|
1445
|
+
throw new Error("Key is required for AES encryption");
|
|
1446
|
+
const algorithm = opts.algorithm || "aes-256-cbc";
|
|
1447
|
+
const outputFormat = opts.output_format || "hex";
|
|
1448
|
+
let ivBuffer;
|
|
1449
|
+
if (opts.iv) {
|
|
1450
|
+
ivBuffer = Buffer.from(opts.iv, "hex");
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
ivBuffer = crypto.randomBytes(16);
|
|
1454
|
+
}
|
|
1455
|
+
const keyBuffer = Buffer.from(key, "utf8");
|
|
1456
|
+
const cipher = crypto.createCipheriv(algorithm, keyBuffer, ivBuffer);
|
|
1457
|
+
let encrypted = cipher.update(str, "utf8");
|
|
1458
|
+
encrypted = Buffer.concat([encrypted, cipher.final()]);
|
|
1459
|
+
const encryptedData = outputFormat === "base64" ? encrypted.toString("base64") : encrypted.toString("hex");
|
|
1460
|
+
return { value: encryptedData, encrypted_data: encryptedData, iv: ivBuffer.toString("hex"), algorithm, output_format: outputFormat };
|
|
1461
|
+
}
|
|
1462
|
+
if (action === "decrypt") {
|
|
1463
|
+
const key = opts.key;
|
|
1464
|
+
const encryptedData = opts.encrypted_data || str;
|
|
1465
|
+
if (!key)
|
|
1466
|
+
throw new Error("Key is required for AES decryption");
|
|
1467
|
+
if (!encryptedData)
|
|
1468
|
+
throw new Error("Encrypted data is required");
|
|
1469
|
+
const algorithm = opts.algorithm || "aes-256-cbc";
|
|
1470
|
+
const inputFormat = opts.input_format || "hex";
|
|
1471
|
+
const iv = opts.iv;
|
|
1472
|
+
if (!iv && algorithm.includes("cbc"))
|
|
1473
|
+
throw new Error("IV is required for CBC decryption");
|
|
1474
|
+
const keyBuffer = Buffer.from(key, "utf8");
|
|
1475
|
+
const ivBuffer = iv ? Buffer.from(iv, "hex") : crypto.randomBytes(16);
|
|
1476
|
+
const encryptedBuffer = inputFormat === "base64" ? Buffer.from(encryptedData, "base64") : Buffer.from(encryptedData, "hex");
|
|
1477
|
+
const decipher = crypto.createDecipheriv(algorithm, keyBuffer, ivBuffer);
|
|
1478
|
+
let decrypted = decipher.update(encryptedBuffer);
|
|
1479
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
1480
|
+
return { value: decrypted.toString("utf8"), decrypted_data: decrypted.toString("utf8"), algorithm };
|
|
1481
|
+
}
|
|
1482
|
+
if (action === "generate_key") {
|
|
1483
|
+
const keyLength = opts.key_length ?? 32;
|
|
1484
|
+
const outputFormat = opts.output_format || "hex";
|
|
1485
|
+
const key = crypto.randomBytes(keyLength);
|
|
1486
|
+
const value = outputFormat === "base64" ? key.toString("base64") : key.toString("hex");
|
|
1487
|
+
return { value, key: value, key_length: keyLength, output_format: outputFormat };
|
|
1488
|
+
}
|
|
1489
|
+
if (action === "generate_iv") {
|
|
1490
|
+
const length = opts.length ?? 16;
|
|
1491
|
+
const outputFormat = opts.output_format || "hex";
|
|
1492
|
+
const iv = crypto.randomBytes(length);
|
|
1493
|
+
const value = outputFormat === "base64" ? iv.toString("base64") : iv.toString("hex");
|
|
1494
|
+
return { value, iv: value, length, output_format: outputFormat };
|
|
1495
|
+
}
|
|
1496
|
+
return { value: str };
|
|
1497
|
+
}
|
|
1498
|
+
async function executeRsa(crypto, actionName, opts, str) {
|
|
1499
|
+
const action = actionName.split(".").pop() || "";
|
|
1500
|
+
if (action === "generate_keypair") {
|
|
1501
|
+
const modulusLength = opts.modulus_length ?? 2048;
|
|
1502
|
+
const publicKeyFormat = opts.public_key_format || "pem";
|
|
1503
|
+
const privateKeyFormat = opts.private_key_format || "pem";
|
|
1504
|
+
const publicKeyType = publicKeyFormat === "pkcs1" ? "pkcs1" : "spki";
|
|
1505
|
+
const privateKeyType = privateKeyFormat === "pkcs1" ? "pkcs1" : "pkcs8";
|
|
1506
|
+
const { publicKey, privateKey } = crypto.generateKeyPairSync("rsa", {
|
|
1507
|
+
modulusLength,
|
|
1508
|
+
publicKeyEncoding: { type: publicKeyType, format: "pem" },
|
|
1509
|
+
privateKeyEncoding: { type: privateKeyType, format: "pem" },
|
|
1510
|
+
});
|
|
1511
|
+
return { value: { public_key: publicKey, private_key: privateKey }, public_key: publicKey, private_key: privateKey, modulus_length: modulusLength };
|
|
1512
|
+
}
|
|
1513
|
+
if (action === "encrypt") {
|
|
1514
|
+
const data = opts.data ?? str;
|
|
1515
|
+
const publicKey = opts.public_key;
|
|
1516
|
+
if (!publicKey)
|
|
1517
|
+
throw new Error("Public key is required for RSA encryption");
|
|
1518
|
+
const padding = opts.padding || "RSA_PKCS1_OAEP_PADDING";
|
|
1519
|
+
const outputFormat = opts.output_format || "base64";
|
|
1520
|
+
const paddingConst = padding === "RSA_PKCS1_PADDING" ? crypto.constants.RSA_PKCS1_PADDING : padding === "RSA_NO_PADDING" ? crypto.constants.RSA_NO_PADDING : crypto.constants.RSA_PKCS1_OAEP_PADDING;
|
|
1521
|
+
const dataStr = typeof data === "string" ? data : JSON.stringify(data);
|
|
1522
|
+
const encrypted = crypto.publicEncrypt({ key: publicKey, padding: paddingConst }, Buffer.from(dataStr, "utf8"));
|
|
1523
|
+
const value = outputFormat === "hex" ? encrypted.toString("hex") : encrypted.toString("base64");
|
|
1524
|
+
return { value, encrypted_data: value, padding, output_format: outputFormat };
|
|
1525
|
+
}
|
|
1526
|
+
if (action === "decrypt") {
|
|
1527
|
+
const encryptedData = opts.encrypted_data ?? str;
|
|
1528
|
+
const privateKey = opts.private_key;
|
|
1529
|
+
if (!privateKey)
|
|
1530
|
+
throw new Error("Private key is required for RSA decryption");
|
|
1531
|
+
const padding = opts.padding || "RSA_PKCS1_OAEP_PADDING";
|
|
1532
|
+
const inputFormat = opts.input_format || "base64";
|
|
1533
|
+
const paddingConst = padding === "RSA_PKCS1_PADDING" ? crypto.constants.RSA_PKCS1_PADDING : padding === "RSA_NO_PADDING" ? crypto.constants.RSA_NO_PADDING : crypto.constants.RSA_PKCS1_OAEP_PADDING;
|
|
1534
|
+
const encryptedBuffer = inputFormat === "hex" ? Buffer.from(encryptedData, "hex") : Buffer.from(encryptedData, "base64");
|
|
1535
|
+
const decrypted = crypto.privateDecrypt({ key: privateKey, padding: paddingConst }, encryptedBuffer);
|
|
1536
|
+
const value = decrypted.toString("utf8");
|
|
1537
|
+
return { value, decrypted_data: value, padding };
|
|
1538
|
+
}
|
|
1539
|
+
if (action === "sign") {
|
|
1540
|
+
const data = opts.data ?? str;
|
|
1541
|
+
const privateKey = opts.private_key;
|
|
1542
|
+
if (!privateKey)
|
|
1543
|
+
throw new Error("Private key is required for RSA signing");
|
|
1544
|
+
const algorithm = opts.algorithm || "RSA-SHA256";
|
|
1545
|
+
const dataStr = typeof data === "string" ? data : JSON.stringify(data);
|
|
1546
|
+
const sign = crypto.createSign(algorithm);
|
|
1547
|
+
sign.update(dataStr);
|
|
1548
|
+
const signature = sign.sign(privateKey, "base64");
|
|
1549
|
+
return { value: signature, signature, algorithm };
|
|
1550
|
+
}
|
|
1551
|
+
if (action === "verify") {
|
|
1552
|
+
const data = opts.data ?? str;
|
|
1553
|
+
const signature = opts.signature;
|
|
1554
|
+
const publicKey = opts.public_key;
|
|
1555
|
+
if (!signature)
|
|
1556
|
+
throw new Error("Signature is required for RSA verification");
|
|
1557
|
+
if (!publicKey)
|
|
1558
|
+
throw new Error("Public key is required for RSA verification");
|
|
1559
|
+
const algorithm = opts.algorithm || "RSA-SHA256";
|
|
1560
|
+
const dataStr = typeof data === "string" ? data : JSON.stringify(data);
|
|
1561
|
+
const verify = crypto.createVerify(algorithm);
|
|
1562
|
+
verify.update(dataStr);
|
|
1563
|
+
const valid = verify.verify(publicKey, signature, "base64");
|
|
1564
|
+
return { value: valid, valid, algorithm };
|
|
1565
|
+
}
|
|
1566
|
+
return { value: str };
|
|
1567
|
+
}
|
|
1568
|
+
async function executeHmac(crypto, actionName, opts, str) {
|
|
1569
|
+
const action = actionName.split(".").pop() || "";
|
|
1570
|
+
const key = opts.key;
|
|
1571
|
+
if (!key)
|
|
1572
|
+
throw new Error("Key is required for HMAC");
|
|
1573
|
+
const algorithm = opts.algorithm || "sha256";
|
|
1574
|
+
const data = opts.data ?? str;
|
|
1575
|
+
const dataStr = typeof data === "string" ? data : JSON.stringify(data);
|
|
1576
|
+
if (action === "create") {
|
|
1577
|
+
const outputFormat = opts.output_format || "hex";
|
|
1578
|
+
const hmac = crypto.createHmac(algorithm, key);
|
|
1579
|
+
hmac.update(dataStr);
|
|
1580
|
+
const hmacValue = hmac.digest();
|
|
1581
|
+
const value = outputFormat === "base64" ? hmacValue.toString("base64") : hmacValue.toString("hex");
|
|
1582
|
+
return { value, hmac: value, algorithm, output_format: outputFormat };
|
|
1583
|
+
}
|
|
1584
|
+
if (action === "verify") {
|
|
1585
|
+
const providedHmac = opts.hmac;
|
|
1586
|
+
if (!providedHmac)
|
|
1587
|
+
throw new Error("HMAC is required for verification");
|
|
1588
|
+
const inputFormat = opts.input_format || "hex";
|
|
1589
|
+
const hmac = crypto.createHmac(algorithm, key);
|
|
1590
|
+
hmac.update(dataStr);
|
|
1591
|
+
const computedHash = hmac.digest();
|
|
1592
|
+
const computedHmac = inputFormat === "base64" ? computedHash.toString("base64") : computedHash.toString("hex");
|
|
1593
|
+
const valid = computedHmac === providedHmac;
|
|
1594
|
+
return { value: valid, valid, algorithm };
|
|
1595
|
+
}
|
|
1596
|
+
return { value: str };
|
|
1597
|
+
}
|
|
1598
|
+
async function executePassword(actionName, opts, str) {
|
|
1599
|
+
const crypto = await Promise.resolve().then(() => __importStar(require("crypto")));
|
|
1600
|
+
const action = actionName.split(".").pop() || "";
|
|
1601
|
+
const password = opts.password ?? str;
|
|
1602
|
+
const pepper = opts.pepper;
|
|
1603
|
+
if (action === "argon2_hash") {
|
|
1604
|
+
let argon2;
|
|
1605
|
+
try {
|
|
1606
|
+
argon2 = await Promise.resolve().then(() => __importStar(require("argon2")));
|
|
1607
|
+
}
|
|
1608
|
+
catch {
|
|
1609
|
+
throw new Error("argon2 package is required for argon2_hash. Install with: npm install argon2");
|
|
1610
|
+
}
|
|
1611
|
+
const type = opts.type || "argon2id";
|
|
1612
|
+
const memoryCost = opts.memoryCost ?? 65536;
|
|
1613
|
+
const timeCost = opts.timeCost ?? 3;
|
|
1614
|
+
const parallelism = opts.parallelism ?? 4;
|
|
1615
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1616
|
+
const hash = await argon2.hash(passwordWithPepper, {
|
|
1617
|
+
type: type === "argon2i" ? argon2.argon2i : type === "argon2d" ? argon2.argon2d : argon2.argon2id,
|
|
1618
|
+
memoryCost,
|
|
1619
|
+
timeCost,
|
|
1620
|
+
parallelism,
|
|
1621
|
+
});
|
|
1622
|
+
return { value: hash, hash, type, memoryCost, timeCost, parallelism };
|
|
1623
|
+
}
|
|
1624
|
+
if (action === "argon2_verify") {
|
|
1625
|
+
let argon2;
|
|
1626
|
+
try {
|
|
1627
|
+
argon2 = await Promise.resolve().then(() => __importStar(require("argon2")));
|
|
1628
|
+
}
|
|
1629
|
+
catch {
|
|
1630
|
+
throw new Error("argon2 package is required for argon2_verify. Install with: npm install argon2");
|
|
1631
|
+
}
|
|
1632
|
+
const hash = opts.hash;
|
|
1633
|
+
if (!hash)
|
|
1634
|
+
throw new Error("Hash is required for argon2 verification");
|
|
1635
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1636
|
+
try {
|
|
1637
|
+
const valid = await argon2.verify(hash, passwordWithPepper);
|
|
1638
|
+
return { value: valid, valid };
|
|
1639
|
+
}
|
|
1640
|
+
catch {
|
|
1641
|
+
return { value: false, valid: false };
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
if (action === "pbkdf2_hash") {
|
|
1645
|
+
const salt = opts.salt ?? crypto.randomBytes(32).toString("hex");
|
|
1646
|
+
const iterations = opts.iterations ?? 100000;
|
|
1647
|
+
const keylen = opts.keylen ?? 64;
|
|
1648
|
+
const digest = opts.digest || "sha256";
|
|
1649
|
+
const outputFormat = opts.output_format || "hex";
|
|
1650
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1651
|
+
const derivedKey = crypto.pbkdf2Sync(passwordWithPepper, salt, iterations, keylen, digest);
|
|
1652
|
+
const hash = outputFormat === "base64" ? derivedKey.toString("base64") : derivedKey.toString("hex");
|
|
1653
|
+
return { value: hash, hash, salt, iterations, keylen, digest, output_format: outputFormat };
|
|
1654
|
+
}
|
|
1655
|
+
if (action === "pbkdf2_verify") {
|
|
1656
|
+
const hash = opts.hash;
|
|
1657
|
+
const salt = opts.salt;
|
|
1658
|
+
if (!hash || !salt)
|
|
1659
|
+
throw new Error("Hash and salt are required for PBKDF2 verification");
|
|
1660
|
+
const iterations = opts.iterations ?? 100000;
|
|
1661
|
+
const keylen = opts.keylen ?? 64;
|
|
1662
|
+
const digest = opts.digest || "sha256";
|
|
1663
|
+
const outputFormat = opts.output_format || "hex";
|
|
1664
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1665
|
+
const derivedKey = crypto.pbkdf2Sync(passwordWithPepper, salt, iterations, keylen, digest);
|
|
1666
|
+
const computedHash = outputFormat === "base64" ? derivedKey.toString("base64") : derivedKey.toString("hex");
|
|
1667
|
+
const valid = computedHash === hash;
|
|
1668
|
+
return { value: valid, valid };
|
|
1669
|
+
}
|
|
1670
|
+
if (action === "scrypt_hash") {
|
|
1671
|
+
const salt = opts.salt ?? crypto.randomBytes(32).toString("hex");
|
|
1672
|
+
const keylen = opts.keylen ?? 64;
|
|
1673
|
+
const cost = opts.cost ?? 16384;
|
|
1674
|
+
const blockSize = opts.blockSize ?? 8;
|
|
1675
|
+
const parallelization = opts.parallelization ?? 1;
|
|
1676
|
+
const outputFormat = opts.output_format || "hex";
|
|
1677
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1678
|
+
const derivedKey = crypto.scryptSync(passwordWithPepper, salt, keylen, { cost, blockSize, maxmem: 128 * cost * blockSize });
|
|
1679
|
+
const hash = outputFormat === "base64" ? derivedKey.toString("base64") : derivedKey.toString("hex");
|
|
1680
|
+
return { value: hash, hash, salt, keylen, cost, blockSize, parallelization, output_format: outputFormat };
|
|
1681
|
+
}
|
|
1682
|
+
if (action === "scrypt_verify") {
|
|
1683
|
+
const hash = opts.hash;
|
|
1684
|
+
const salt = opts.salt;
|
|
1685
|
+
if (!hash || !salt)
|
|
1686
|
+
throw new Error("Hash and salt are required for scrypt verification");
|
|
1687
|
+
const keylen = opts.keylen ?? 64;
|
|
1688
|
+
const cost = opts.cost ?? 16384;
|
|
1689
|
+
const blockSize = opts.blockSize ?? 8;
|
|
1690
|
+
const outputFormat = opts.output_format || "hex";
|
|
1691
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1692
|
+
const derivedKey = crypto.scryptSync(passwordWithPepper, salt, keylen, { cost, blockSize, maxmem: 128 * cost * blockSize });
|
|
1693
|
+
const computedHash = outputFormat === "base64" ? derivedKey.toString("base64") : derivedKey.toString("hex");
|
|
1694
|
+
const valid = computedHash === hash;
|
|
1695
|
+
return { value: valid, valid };
|
|
1696
|
+
}
|
|
1697
|
+
if (action === "bcrypt_hash") {
|
|
1698
|
+
let bcrypt;
|
|
1699
|
+
try {
|
|
1700
|
+
bcrypt = await Promise.resolve().then(() => __importStar(require("bcrypt")));
|
|
1701
|
+
}
|
|
1702
|
+
catch {
|
|
1703
|
+
throw new Error("bcrypt package is required for bcrypt_hash. Install with: npm install bcrypt");
|
|
1704
|
+
}
|
|
1705
|
+
const rounds = opts.rounds ?? 10;
|
|
1706
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1707
|
+
const hash = await bcrypt.hash(passwordWithPepper, rounds);
|
|
1708
|
+
return { value: hash, hash, rounds };
|
|
1709
|
+
}
|
|
1710
|
+
if (action === "bcrypt_verify") {
|
|
1711
|
+
let bcrypt;
|
|
1712
|
+
try {
|
|
1713
|
+
bcrypt = await Promise.resolve().then(() => __importStar(require("bcrypt")));
|
|
1714
|
+
}
|
|
1715
|
+
catch {
|
|
1716
|
+
throw new Error("bcrypt package is required for bcrypt_verify. Install with: npm install bcrypt");
|
|
1717
|
+
}
|
|
1718
|
+
const hash = opts.hash;
|
|
1719
|
+
if (!hash)
|
|
1720
|
+
throw new Error("Hash is required for bcrypt verification");
|
|
1721
|
+
const passwordWithPepper = pepper ? pepper + password : password;
|
|
1722
|
+
try {
|
|
1723
|
+
const valid = await bcrypt.compare(passwordWithPepper, hash);
|
|
1724
|
+
return { value: valid, valid };
|
|
1725
|
+
}
|
|
1726
|
+
catch {
|
|
1727
|
+
return { value: false, valid: false };
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
if (action === "generate_salt") {
|
|
1731
|
+
const length = opts.length ?? 32;
|
|
1732
|
+
const outputFormat = opts.output_format || "hex";
|
|
1733
|
+
const salt = crypto.randomBytes(length);
|
|
1734
|
+
const value = outputFormat === "base64" ? salt.toString("base64") : salt.toString("hex");
|
|
1735
|
+
return { value, salt: value, length, output_format: outputFormat };
|
|
1736
|
+
}
|
|
1737
|
+
return { value: str };
|
|
1738
|
+
}
|
|
1739
|
+
function resolveRegisteredRestActionName(connectorDef, actionName) {
|
|
1740
|
+
const endpoints = connectorDef.endpoints || [];
|
|
1741
|
+
if (!endpoints.length)
|
|
1742
|
+
return null;
|
|
1743
|
+
if (endpoints.some((e) => e.name === actionName || e.action === actionName)) {
|
|
1744
|
+
return actionName;
|
|
1745
|
+
}
|
|
1746
|
+
const actions = connectorDef.actions;
|
|
1747
|
+
if (actions && typeof actions === "object" && !Array.isArray(actions) && Object.prototype.hasOwnProperty.call(actions, actionName)) {
|
|
1748
|
+
const mapped = actions[actionName];
|
|
1749
|
+
if (typeof mapped === "string" &&
|
|
1750
|
+
endpoints.some((e) => e.name === mapped || e.action === mapped)) {
|
|
1751
|
+
return mapped;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
return null;
|
|
1755
|
+
}
|
|
1756
|
+
async function executeConnectorAction(connectorDef, actionName, options = {}, context = {}) {
|
|
1757
|
+
const restActionName = resolveRegisteredRestActionName(connectorDef, actionName);
|
|
1758
|
+
if (restActionName &&
|
|
1759
|
+
(connectorDef.type === "REST" || connectorDef.type === "rest" || connectorDef.endpoints?.length)) {
|
|
1760
|
+
return executeRestConnector(connectorDef, restActionName, options, context);
|
|
1761
|
+
}
|
|
1762
|
+
if (typeof connectorDef.execute === "function") {
|
|
1763
|
+
const result = await connectorDef.execute(actionName, options, context);
|
|
1764
|
+
return { raw: result, mapped: result };
|
|
1765
|
+
}
|
|
1766
|
+
const category = connectorDef.meta?.category;
|
|
1767
|
+
if (category === "responder") {
|
|
1768
|
+
return executeResponder(connectorDef, options, context);
|
|
1769
|
+
}
|
|
1770
|
+
if (category === "database") {
|
|
1771
|
+
return executeDbConnector(connectorDef, actionName, options, context);
|
|
1772
|
+
}
|
|
1773
|
+
if (category === "authentication") {
|
|
1774
|
+
return executeAuthConnector(connectorDef, actionName, options, context);
|
|
1775
|
+
}
|
|
1776
|
+
if (category === "utility") {
|
|
1777
|
+
return executeUtilityConnector(connectorDef, actionName, options, context);
|
|
1778
|
+
}
|
|
1779
|
+
if (category === "encryption") {
|
|
1780
|
+
return executeEncryptionConnector(connectorDef, actionName, options, context);
|
|
1781
|
+
}
|
|
1782
|
+
if (connectorDef.type === "REST" || connectorDef.type === "rest" || connectorDef.endpoints) {
|
|
1783
|
+
return executeRestConnector(connectorDef, actionName, options, context);
|
|
1784
|
+
}
|
|
1785
|
+
throw new Error("Unsupported connector: " + (connectorDef._id || connectorDef.id));
|
|
1786
|
+
}
|