cliodot 1.2.3 → 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 +2 -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 +50 -9
- package/dist/CommercialAppClient.d.ts.map +1 -1
- package/dist/CommercialAppClient.js +576 -1
- 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 +1 -0
- package/dist/IdentityAppClient.d.ts.map +1 -1
- package/dist/IdentityAppClient.js +197 -1
- package/dist/MemoryAppClient.d.ts +1 -0
- package/dist/MemoryAppClient.d.ts.map +1 -1
- package/dist/MemoryAppClient.js +149 -1
- package/dist/MemoryClient.js +20 -1
- 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.js +61 -1
- 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.js +232 -1
- 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.js +174 -1
- package/dist/identity-token-cache.js +51 -1
- package/dist/index.d.ts +1 -1
- 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 +407 -11
- package/dist/types/commercial-app.api.d.ts.map +1 -1
- package/dist/types/commercial-app.api.js +2 -1
- 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 +2 -0
- package/dist/types/identity-app.api.d.ts.map +1 -1
- package/dist/types/identity-app.api.js +2 -1
- package/dist/types/index.js +23 -1
- package/dist/types/memory-app.api.d.ts +2 -0
- package/dist/types/memory-app.api.d.ts.map +1 -1
- package/dist/types/memory-app.api.js +2 -1
- 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.js +2 -1
- 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
package/dist/Surface.js
CHANGED
|
@@ -1 +1,255 @@
|
|
|
1
|
-
'use strict';const _0x460eb5=_0x378a;(function(_0x129c22,_0x4c56e0){const _0x4181ad=_0x378a,_0x15ff08=_0x129c22();while(!![]){try{const _0x1f1d24=parseInt(_0x4181ad(0xb6))/0x1+parseInt(_0x4181ad(0xbf))/0x2*(-parseInt(_0x4181ad(0x100))/0x3)+-parseInt(_0x4181ad(0xb5))/0x4*(parseInt(_0x4181ad(0xd8))/0x5)+parseInt(_0x4181ad(0x10f))/0x6*(parseInt(_0x4181ad(0xe0))/0x7)+parseInt(_0x4181ad(0xf7))/0x8+parseInt(_0x4181ad(0xb4))/0x9+parseInt(_0x4181ad(0xc9))/0xa;if(_0x1f1d24===_0x4c56e0)break;else _0x15ff08['push'](_0x15ff08['shift']());}catch(_0xc8c016){_0x15ff08['push'](_0x15ff08['shift']());}}}(_0x1854,0xf29df));function _0x378a(_0x3f6061,_0x398261){_0x3f6061=_0x3f6061-0xb3;const _0x1854ee=_0x1854();let _0x378a43=_0x1854ee[_0x3f6061];if(_0x378a['QAVlOS']===undefined){var _0x1221dc=function(_0x5b31d9){const _0x1ccef6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4c51a6='',_0x6591a5='';for(let _0x338504=0x0,_0x9e9237,_0x1da7f8,_0x5580a7=0x0;_0x1da7f8=_0x5b31d9['charAt'](_0x5580a7++);~_0x1da7f8&&(_0x9e9237=_0x338504%0x4?_0x9e9237*0x40+_0x1da7f8:_0x1da7f8,_0x338504++%0x4)?_0x4c51a6+=String['fromCharCode'](0xff&_0x9e9237>>(-0x2*_0x338504&0x6)):0x0){_0x1da7f8=_0x1ccef6['indexOf'](_0x1da7f8);}for(let _0x500c2f=0x0,_0x297b7f=_0x4c51a6['length'];_0x500c2f<_0x297b7f;_0x500c2f++){_0x6591a5+='%'+('00'+_0x4c51a6['charCodeAt'](_0x500c2f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x6591a5);};_0x378a['jebmBc']=_0x1221dc,_0x378a['ZFcqrA']={},_0x378a['QAVlOS']=!![];}const _0x6f10e1=_0x1854ee[0x0],_0x5cece5=_0x3f6061+_0x6f10e1,_0x8e6900=_0x378a['ZFcqrA'][_0x5cece5];return!_0x8e6900?(_0x378a43=_0x378a['jebmBc'](_0x378a43),_0x378a['ZFcqrA'][_0x5cece5]=_0x378a43):_0x378a43=_0x8e6900,_0x378a43;}function _0x1854(){const _0x2d9602=['Aw52B2TLqMfZzvvYBa','yxbPs2v5sgvHzgvY','xhmQxh1CFq','u1vsrKfdrv9srvfvrvnux0zbsuXfra','y3j5ChrV','BM93','zgvMyxvSDa','u3vYzMfJzsbYB290igLZig5VDcbJywXSywjSzq','zw50CMLLCW','rMfPBgvKihrVigXVywqGC3vYzMfJzsaO','BM9Uy2u','w1n1CMzHy2vD','x19LC01VzhvSzq','mti2qM5itfjm','r0vu','mtiWndq4odbevgDlzhu','mZG5mtC2nhnqAwnYEq','ndu4nJuXyK1lC2nf','C2HHmJu2','zgLNzxn0','C3vYzMfJzvbYB21PC2u','DxrMoa','qxv0Ag9YAxPHDgLVBG','DxbKyxrL','C3rYAw5NAwz5','CM9VDejHC2vvCMW','nezAwe1gua','x19PBxbVCNrezwzHDwX0','BgvUz3rO','u3vYzMfJzsbYzxf1zxn0igzHAwXLzcaO','zxjYB3i','Agv4','u0rlx09qx05pvf9fwfbpu0ve','Dg9vChbLCKnHC2u','C2X1zW','xcqM','mJGYody5mfzZzgXPBG','Cgf0Aa','zw5KCg9PBNrFCgf0Aa','DhjPBq','u3vYzMfJzq','zMLUza','z2f0zxDHEq','C3rYAw5N','u0rlig9WzxjHDgLVBIbUB3qGzxHWB3nLzdOG','yM9KEq','DMvYC2LVBG','q29UDgvUDc1uExbL','C2rRvMvYC2LVBG','AND0','Bg9Hzfn1CMzHy2u','mtbxt25KzfK','yxnqCM94Eq','Bwv0Ag9K','yMfZzvvYBa','Dg9tDhjPBMC','Bwf0y2HbBgW','u1vsrKfdrv9mt0fex0zbsuXfra','yxbPs2v5','ndK2mtK1wLbwuKvi','C3LTyM9S','BwfW','kd89jhXBlZ8JjL18w15HlxPblvOWltLFlv0P','yxHPB3m','C2LNBMLUz1nLy3jLDa','DgHLBG','A2v5CW','lI9LCNjVCNm','zgf0yq','CMvXDwvZDa','CgfYC2vbCgLfCNjVCK1LC3nHz2u','rMfPBgvKihrVigXVywqGC3vYzMfJzq','xhTCE1XZkG','y3jLyxrLsg1HyW','B3bZ','CMvWBgfJzq','C2rRx3bHDgG','C2XPy2u','q2XPB2rVDefWAuvYCM9Y','zMLUze9W','yxr0zxn0yxrPB25izwfKzxjZ','C3rHCNrZv2L0Aa','mJiXndG2ng11sMDTEG','C2rRoG','C3rHDhvZ','zMfPBfjLC3bVBNnL','C3vYzMfJzq','AM9PBG','CgfYC2vbCgLfCNjVCLn0yxr1CW','yxbWBgLJyxrPB24VANnVBG','u3vYzMfJzsbYzxf1zxn0igzHAwXLza','mtm1odq2m1HnsurOrG','z2v0'];_0x1854=function(){return _0x2d9602;};return _0x1854();}var __importDefault=this&&this[_0x460eb5(0xc0)]||function(_0x4c51a6){return _0x4c51a6&&_0x4c51a6['__esModule']?_0x4c51a6:{'default':_0x4c51a6};};Object['defineProperty'](exports,_0x460eb5(0x10e),{'value':!![]}),exports[_0x460eb5(0xcd)]=void 0x0;const axios_1=__importDefault(require(_0x460eb5(0xe4))),crypto_1=__importDefault(require(_0x460eb5(0x106))),errors_1=require(_0x460eb5(0xe8)),parse_api_error_1=require('./http/parse-api-error'),DEFAULT_SDK_VERSION='1.2.1';function trimBaseUrl(_0x6591a5){const _0x555057=_0x460eb5;return _0x6591a5[_0x555057(0xcc)]()[_0x555057(0xf0)](/\/+$/,'');}function sha256Hex(value){const _0x3cb8ad=_0x460eb5;return crypto_1[_0x3cb8ad(0x108)]['createHash'](_0x3cb8ad(0xb7))[_0x3cb8ad(0xbc)](value,_0x3cb8ad(0xba))[_0x3cb8ad(0xb8)]('hex');}function hmacSha256Hex(_0x338504,_0x9e9237){const _0x102282=_0x460eb5;return crypto_1[_0x102282(0x108)][_0x102282(0xee)](_0x102282(0xb7),_0x338504)[_0x102282(0xbc)](_0x9e9237,_0x102282(0xba))[_0x102282(0xb8)](_0x102282(0xc4));}function randomNonce(){const _0x5b87ff=_0x460eb5;return crypto_1['default']['randomBytes'](0x10)['toString'](_0x5b87ff(0xc4));}function buildCanonical(_0x1da7f8){const _0x1331fe=_0x460eb5,_0x5580a7=_0x1da7f8[_0x1331fe(0xd2)]===undefined||_0x1da7f8[_0x1331fe(0xd2)]===null||typeof _0x1da7f8['body']==='object'&&!Array['isArray'](_0x1da7f8[_0x1331fe(0xd2)])&&Object[_0x1331fe(0xe7)](_0x1da7f8[_0x1331fe(0xd2)])[_0x1331fe(0xc1)]===0x0?'':typeof _0x1da7f8[_0x1331fe(0xd2)]===_0x1331fe(0xd0)?_0x1da7f8[_0x1331fe(0xd2)]:JSON[_0x1331fe(0xbd)](_0x1da7f8[_0x1331fe(0xd2)]);return[_0x1da7f8['timestamp'],_0x1da7f8[_0x1331fe(0x10c)],(_0x1da7f8[_0x1331fe(0xda)]||_0x1331fe(0xb3))[_0x1331fe(0xc6)](),_0x1da7f8[_0x1331fe(0xca)]||'/',sha256Hex(_0x5580a7)][_0x1331fe(0xfc)]('.');}function sanitizePathParamKey(_0x500c2f){const _0x2b71ff=_0x460eb5;return String(_0x500c2f||'')['replace'](/[^a-zA-Z0-9_]+/g,'_')[_0x2b71ff(0xf0)](/_+/g,'_')[_0x2b71ff(0xf0)](/^_|_$/g,'');}function fillEndpointPath(_0x297b7f,_0x8bdd96){const _0x3034d0=_0x460eb5;let _0x10a936=_0x297b7f;const _0x4f5b68=Object[_0x3034d0(0x10a)](_0x8bdd96)['sort']((_0x23d0e7,_0xb158d0)=>_0xb158d0[0x0][_0x3034d0(0xc1)]-_0x23d0e7[0x0][_0x3034d0(0xc1)]),_0x3b0bb4=(_0x299851,_0x4f8db3,_0x414fe5)=>{const _0x40c0ae=_0x3034d0,_0x17f66d=_0x4f8db3['replace'](/[.*+?^${}()|[\]\\]/g,_0x40c0ae(0xc8));return _0x299851['replace'](new RegExp(':'+_0x17f66d+_0x40c0ae(0xe3),'g'),_0x414fe5)[_0x40c0ae(0xf0)](new RegExp(_0x40c0ae(0xed)+_0x17f66d+_0x40c0ae(0x104),'g'),_0x414fe5)[_0x40c0ae(0xf0)](new RegExp('\x5c{'+_0x17f66d+'\x5c}','g'),_0x414fe5);};for(const [_0x246cf0,value]of _0x4f5b68){_0x10a936=_0x3b0bb4(_0x10a936,_0x246cf0,encodeURIComponent(value));}const _0xab5ba=[..._0x10a936[_0x3034d0(0xdd)](/\{\{\s*([a-zA-Z_][a-zA-Z0-9_-]*)\s*\}\}/g),..._0x10a936[_0x3034d0(0xdd)](/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=$|[/?#&]|[^a-zA-Z0-9_-])/g),..._0x10a936[_0x3034d0(0xdd)](/\{([a-zA-Z_][a-zA-Z0-9_-]*)\}/g)][_0x3034d0(0xe2)](_0x43df9e=>_0x43df9e[0x1]);for(const _0x212fce of _0xab5ba){const _0x4bc7bb=sanitizePathParamKey(_0x212fce),_0x41a51b=_0x4f5b68[_0x3034d0(0xce)](([_0x34f88e])=>sanitizePathParamKey(_0x34f88e)===_0x4bc7bb);if(!_0x41a51b)continue;_0x10a936=_0x3b0bb4(_0x10a936,_0x212fce,encodeURIComponent(_0x41a51b[0x1]));}if(!_0x10a936[_0x3034d0(0xf6)]('/'))_0x10a936='/'+_0x10a936;return _0x10a936;}class SurfaceRuntime{constructor(_0x5b5d2e){const _0x498b33=_0x460eb5;this[_0x498b33(0xb9)]=null,this[_0x498b33(0xfb)]=null;if(!_0x5b5d2e[_0x498b33(0xdb)]?.[_0x498b33(0xcc)]())throw new errors_1['CliodotApiError']('Surface\x20requires\x20baseUrl');this[_0x498b33(0xbe)]=trimBaseUrl(_0x5b5d2e['baseUrl']),this['slug']=_0x5b5d2e[_0x498b33(0xc7)]?.[_0x498b33(0xcc)]()||undefined,this[_0x498b33(0xdf)]=_0x5b5d2e['apiKey']?.[_0x498b33(0xcc)]()||undefined,this[_0x498b33(0xd6)]=_0x5b5d2e[_0x498b33(0xd6)]?.[_0x498b33(0xcc)]()||undefined,this[_0x498b33(0x103)]=_0x5b5d2e[_0x498b33(0x103)]?.[_0x498b33(0xcc)]()||'X-API-Key',this['sdkVersion']=_0x5b5d2e[_0x498b33(0xd3)]?.[_0x498b33(0xcc)]()||DEFAULT_SDK_VERSION,this['invokeBaseUrl']=this[_0x498b33(0xc7)]?this[_0x498b33(0xbe)]+'/'+this[_0x498b33(0xc7)]:this[_0x498b33(0xbe)],this[_0x498b33(0xe4)]=axios_1[_0x498b33(0x108)]['create']({'timeout':0xea60,'validateStatus':()=>!![]});}[_0x460eb5(0xfa)](_0x465c1b,_0x279be1,_0x1bfb76){const _0x15990c=_0x460eb5,_0x3e6d13=_0x465c1b?.['data'],_0x25d76f=(0x0,parse_api_error_1[_0x15990c(0xeb)])(_0x3e6d13)||(typeof _0x3e6d13?.['error']===_0x15990c(0xd0)?_0x3e6d13[_0x15990c(0xc3)]:undefined)||_0x279be1;throw new errors_1[(_0x15990c(0xf3))](_0x25d76f,{'status':(0x0,parse_api_error_1[_0x15990c(0xfd)])(_0x3e6d13,_0x465c1b?.[_0x15990c(0xf9)]),'data':_0x3e6d13,'code':_0x1bfb76||(0x0,parse_api_error_1['parseApiErrorCode'])(_0x3e6d13)});}[_0x460eb5(0xe5)](){const _0x3f4c5a=_0x460eb5;if(this['apiKey'])return this[_0x3f4c5a(0xdf)];if(this['jwt'])return this['jwt'];return _0x3f4c5a(0xf8)+(this[_0x3f4c5a(0xc7)]||_0x3f4c5a(0xcf));}[_0x460eb5(0xf5)](_0x8c52f4,_0x11e8cc,_0x4796ee){const _0x210a74=_0x460eb5,_0x5d4c1e=String(Date[_0x210a74(0x107)]()),_0x436c5d=randomNonce(),_0x382bb7=buildCanonical({'timestamp':_0x5d4c1e,'nonce':_0x436c5d,'method':_0x8c52f4,'path':_0x11e8cc,'body':_0x4796ee}),_0xaf080a=hmacSha256Hex(this[_0x210a74(0xe5)](),_0x382bb7),_0x24396f={'X-Cliodot-Client':'sdk','X-Cliodot-SDK-Version':this[_0x210a74(0xd5)],'X-Cliodot-SDK-Timestamp':_0x5d4c1e,'X-Cliodot-SDK-Nonce':_0x436c5d,'X-Cliodot-SDK-Signature':_0xaf080a};return this[_0x210a74(0xdf)]&&(_0x24396f[this[_0x210a74(0x103)]]=this[_0x210a74(0xdf)]),this[_0x210a74(0xd6)]&&(_0x24396f[_0x210a74(0xbb)]='Bearer\x20'+this[_0x210a74(0xd6)]),_0x24396f;}async[_0x460eb5(0xd7)](_0x593f2e=![]){const _0x25b05d=_0x460eb5;if(!_0x593f2e&&this[_0x25b05d(0xfb)])return this[_0x25b05d(0xfb)];if(!_0x593f2e&&this['surfacePromise'])return this[_0x25b05d(0xb9)];return this[_0x25b05d(0xb9)]=((async()=>{const _0x4d757e=_0x25b05d,_0x4e30f9='/sdk/surface',_0x2dd8c0=''+this[_0x4d757e(0x102)]+_0x4e30f9;try{const _0x4c94fd=await this[_0x4d757e(0xe4)][_0x4d757e(0x101)](_0x2dd8c0,{'headers':this[_0x4d757e(0xf5)](_0x4d757e(0xb3),_0x4e30f9)});return(_0x4c94fd[_0x4d757e(0xf9)]>=0x190||_0x4c94fd['data']?.['ok']===![])&&this[_0x4d757e(0xfa)](_0x4c94fd,_0x4d757e(0x10b)+_0x4c94fd['status']+')',_0x4d757e(0xde)),this[_0x4d757e(0xfb)]=_0x4c94fd[_0x4d757e(0xe9)][_0x4d757e(0xfb)],this[_0x4d757e(0xfb)];}catch(_0x56be2c){this[_0x4d757e(0xb9)]=null;if(_0x56be2c instanceof errors_1[_0x4d757e(0xf3)])throw _0x56be2c;throw(0x0,errors_1['cliodotApiErrorFromAxios'])(_0x56be2c,_0x4d757e(0xec));}})()),this[_0x25b05d(0xb9)];}[_0x460eb5(0xf4)](_0x525562,_0x9ed6d8,_0x2753e4){const _0x5e765c=_0x460eb5,_0x3f0707=_0x2753e4[_0x5e765c(0xef)][_0x5e765c(0xce)](_0x2483df=>_0x2483df['op']===_0x9ed6d8&&_0x2483df['sdk_path'][_0x5e765c(0xc1)]===_0x525562['length']&&_0x2483df[_0x5e765c(0xf1)]['every']((_0x15cb62,_0x78ce8b)=>_0x15cb62===_0x525562[_0x78ce8b]));if(!_0x3f0707){const _0x582df4=[..._0x525562,_0x9ed6d8][_0x5e765c(0xfc)]('.');throw new errors_1['CliodotApiError'](_0x5e765c(0xd1)+_0x582df4,{'code':_0x5e765c(0xc5)});}return _0x3f0707;}async['invoke'](_0x28dc65,_0x9bceca,_0x4b3c85){const _0x14dc48=_0x460eb5,_0x3eab0d=await this['loadSurface'](),_0x45df4b=this['findOp'](_0x28dc65,_0x9bceca,_0x3eab0d);let _0x5d0428=0x0;const _0x17673d={};for(const _0x343ef2 of _0x45df4b['path_params']||[]){const value=_0x4b3c85[_0x5d0428++];if(value===undefined||value===null)throw new errors_1[(_0x14dc48(0xf3))]('Missing\x20path\x20argument:\x20'+_0x343ef2);_0x17673d[_0x343ef2]=String(value);}let _0x17ada9,_0x51e310;_0x45df4b['body']&&(_0x17ada9=_0x4b3c85[_0x5d0428++]);_0x45df4b['query_schema']&&(_0x51e310=_0x4b3c85[_0x5d0428++]||undefined);const _0x16837a=fillEndpointPath(_0x45df4b[_0x14dc48(0xcb)],_0x17673d),_0x23257a=''+this['invokeBaseUrl']+_0x16837a,_0x569f07=!!_0x45df4b[_0x14dc48(0xd2)]&&_0x17ada9!==undefined,_0x368e0d=this['attestationHeaders'](_0x45df4b[_0x14dc48(0xda)],_0x16837a,_0x569f07?_0x17ada9:undefined);_0x569f07&&(_0x368e0d[_0x14dc48(0xd4)]=_0x14dc48(0xfe));try{const _0x2941e5=await this['axios'][_0x14dc48(0xea)]({'url':_0x23257a,'method':_0x45df4b[_0x14dc48(0xda)],'headers':_0x368e0d,'params':_0x51e310,'data':_0x569f07?_0x17ada9:undefined});return(_0x2941e5[_0x14dc48(0xf9)]>=0x190||_0x2941e5['data']?.['ok']===![])&&this[_0x14dc48(0xfa)](_0x2941e5,_0x14dc48(0xc2)+_0x2941e5[_0x14dc48(0xf9)]+')',_0x14dc48(0x105)),_0x2941e5['data']?.[_0x14dc48(0xe9)]!==undefined?_0x2941e5[_0x14dc48(0xe9)][_0x14dc48(0xe9)]:_0x2941e5[_0x14dc48(0xe9)];}catch(_0x3685bd){if(_0x3685bd instanceof errors_1[_0x14dc48(0xf3)])throw _0x3685bd;throw(0x0,errors_1['cliodotApiErrorFromAxios'])(_0x3685bd,_0x14dc48(0xff));}}[_0x460eb5(0xd9)](_0x3b3428=[]){const _0x45932e=this,_0x5ce0c2=(..._0x2b1ea3)=>{const _0x298530=_0x378a;if(_0x3b3428[_0x298530(0xc1)]===0x0)throw new errors_1[(_0x298530(0xf3))](_0x298530(0x109));const _0x3d4ad1=_0x3b3428[_0x3b3428[_0x298530(0xc1)]-0x1],_0x142926=_0x3b3428[_0x298530(0xf2)](0x0,-0x1);return _0x45932e['invoke'](_0x142926,_0x3d4ad1,_0x2b1ea3);};return new Proxy(_0x5ce0c2,{'get'(_target,_0x26583d){const _0x546b71=_0x378a;if(typeof _0x26583d===_0x546b71(0xe1))return undefined;if(_0x26583d===_0x546b71(0xe6))return undefined;if(_0x26583d==='loadSurface')return _0x49d1b9=>_0x45932e['loadSurface'](_0x49d1b9);if(_0x26583d===_0x546b71(0xdc))return()=>_0x546b71(0x10d);return _0x45932e[_0x546b71(0xd9)]([..._0x3b3428,String(_0x26583d)]);},'apply'(_target,_0x5afa85,_0x1c0c81){return _0x5ce0c2(..._0x1c0c81||[]);}});}}exports[_0x460eb5(0xcd)]=function Surface(_0x3a6ed9){const _0x108660=new SurfaceRuntime(_0x3a6ed9);return _0x108660['asProxy']();};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Surface = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const parse_api_error_1 = require("./http/parse-api-error");
|
|
11
|
+
const cliodot_request_1 = require("./http/cliodot-request");
|
|
12
|
+
const DEFAULT_SDK_VERSION = "1.2.1";
|
|
13
|
+
function trimBaseUrl(url) {
|
|
14
|
+
return url.trim().replace(/\/+$/, "");
|
|
15
|
+
}
|
|
16
|
+
function sha256Hex(value) {
|
|
17
|
+
return crypto_1.default.createHash("sha256").update(value, "utf8").digest("hex");
|
|
18
|
+
}
|
|
19
|
+
function hmacSha256Hex(secret, payload) {
|
|
20
|
+
return crypto_1.default.createHmac("sha256", secret).update(payload, "utf8").digest("hex");
|
|
21
|
+
}
|
|
22
|
+
function randomNonce() {
|
|
23
|
+
return crypto_1.default.randomBytes(16).toString("hex");
|
|
24
|
+
}
|
|
25
|
+
function buildCanonical(input) {
|
|
26
|
+
const bodyRaw = input.body === undefined ||
|
|
27
|
+
input.body === null ||
|
|
28
|
+
(typeof input.body === "object" &&
|
|
29
|
+
!Array.isArray(input.body) &&
|
|
30
|
+
Object.keys(input.body).length === 0)
|
|
31
|
+
? ""
|
|
32
|
+
: typeof input.body === "string"
|
|
33
|
+
? input.body
|
|
34
|
+
: JSON.stringify(input.body);
|
|
35
|
+
return [
|
|
36
|
+
input.timestamp,
|
|
37
|
+
input.nonce,
|
|
38
|
+
(input.method || "GET").toUpperCase(),
|
|
39
|
+
input.path || "/",
|
|
40
|
+
sha256Hex(bodyRaw),
|
|
41
|
+
].join(".");
|
|
42
|
+
}
|
|
43
|
+
function sanitizePathParamKey(name) {
|
|
44
|
+
return String(name || "")
|
|
45
|
+
.replace(/[^a-zA-Z0-9_]+/g, "_")
|
|
46
|
+
.replace(/_+/g, "_")
|
|
47
|
+
.replace(/^_|_$/g, "");
|
|
48
|
+
}
|
|
49
|
+
function fillEndpointPath(template, pathParams) {
|
|
50
|
+
let path = template;
|
|
51
|
+
const entries = Object.entries(pathParams).sort((a, b) => b[0].length - a[0].length);
|
|
52
|
+
const replaceName = (current, name, encoded) => {
|
|
53
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
54
|
+
return current
|
|
55
|
+
.replace(new RegExp(`:${escaped}(?=$|[/?#&]|[^a-zA-Z0-9_-])`, "g"), encoded)
|
|
56
|
+
.replace(new RegExp(`\\{\\{\\s*${escaped}\\s*\\}\\}`, "g"), encoded)
|
|
57
|
+
.replace(new RegExp(`\\{${escaped}\\}`, "g"), encoded);
|
|
58
|
+
};
|
|
59
|
+
for (const [name, value] of entries) {
|
|
60
|
+
path = replaceName(path, name, encodeURIComponent(value));
|
|
61
|
+
}
|
|
62
|
+
const remaining = [
|
|
63
|
+
...path.matchAll(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_-]*)\s*\}\}/g),
|
|
64
|
+
...path.matchAll(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=$|[/?#&]|[^a-zA-Z0-9_-])/g),
|
|
65
|
+
...path.matchAll(/\{([a-zA-Z_][a-zA-Z0-9_-]*)\}/g),
|
|
66
|
+
].map((match) => match[1]);
|
|
67
|
+
for (const placeholder of remaining) {
|
|
68
|
+
const normalizedPlaceholder = sanitizePathParamKey(placeholder);
|
|
69
|
+
const match = entries.find(([key]) => sanitizePathParamKey(key) === normalizedPlaceholder);
|
|
70
|
+
if (!match)
|
|
71
|
+
continue;
|
|
72
|
+
path = replaceName(path, placeholder, encodeURIComponent(match[1]));
|
|
73
|
+
}
|
|
74
|
+
if (!path.startsWith("/"))
|
|
75
|
+
path = `/${path}`;
|
|
76
|
+
return path;
|
|
77
|
+
}
|
|
78
|
+
class SurfaceRuntime {
|
|
79
|
+
constructor(config) {
|
|
80
|
+
this.surfacePromise = null;
|
|
81
|
+
this.surface = null;
|
|
82
|
+
if (!config.baseUrl?.trim()) {
|
|
83
|
+
throw new errors_1.CliodotApiError("Surface requires baseUrl");
|
|
84
|
+
}
|
|
85
|
+
this.rootBaseUrl = trimBaseUrl(config.baseUrl);
|
|
86
|
+
this.slug = config.slug?.trim() || undefined;
|
|
87
|
+
this.apiKey = config.apiKey?.trim() || undefined;
|
|
88
|
+
this.jwt = config.jwt?.trim() || undefined;
|
|
89
|
+
this.apiKeyHeader = config.apiKeyHeader?.trim() || "X-API-Key";
|
|
90
|
+
this.sdkVersion = config.version?.trim() || DEFAULT_SDK_VERSION;
|
|
91
|
+
this.environment = config.environment;
|
|
92
|
+
this.invokeBaseUrl = this.slug
|
|
93
|
+
? `${this.rootBaseUrl}/${this.slug}`
|
|
94
|
+
: this.rootBaseUrl;
|
|
95
|
+
this.axios = axios_1.default.create({
|
|
96
|
+
timeout: 60000,
|
|
97
|
+
validateStatus: () => true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
failResponse(response, fallback, code) {
|
|
101
|
+
const data = response?.data;
|
|
102
|
+
const message = (0, parse_api_error_1.parseApiErrorMessage)(data) ||
|
|
103
|
+
(typeof data?.error === "string" ? data.error : undefined) ||
|
|
104
|
+
fallback;
|
|
105
|
+
throw new errors_1.CliodotApiError(message, {
|
|
106
|
+
status: (0, parse_api_error_1.parseApiErrorStatus)(data, response?.status),
|
|
107
|
+
data,
|
|
108
|
+
code: code || (0, parse_api_error_1.parseApiErrorCode)(data),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
signingSecret() {
|
|
112
|
+
if (this.apiKey)
|
|
113
|
+
return this.apiKey;
|
|
114
|
+
if (this.jwt)
|
|
115
|
+
return this.jwt;
|
|
116
|
+
return `sdk:${this.slug || "gateway"}`;
|
|
117
|
+
}
|
|
118
|
+
attestationHeaders(method, path, body) {
|
|
119
|
+
const timestamp = String(Date.now());
|
|
120
|
+
const nonce = randomNonce();
|
|
121
|
+
const canonical = buildCanonical({ timestamp, nonce, method, path, body });
|
|
122
|
+
const signature = hmacSha256Hex(this.signingSecret(), canonical);
|
|
123
|
+
const headers = {
|
|
124
|
+
"X-Cliodot-Client": "sdk",
|
|
125
|
+
"X-Cliodot-SDK-Version": this.sdkVersion,
|
|
126
|
+
"X-Cliodot-SDK-Timestamp": timestamp,
|
|
127
|
+
"X-Cliodot-SDK-Nonce": nonce,
|
|
128
|
+
"X-Cliodot-SDK-Signature": signature,
|
|
129
|
+
};
|
|
130
|
+
if (this.apiKey) {
|
|
131
|
+
headers[this.apiKeyHeader] = this.apiKey;
|
|
132
|
+
}
|
|
133
|
+
if (this.jwt) {
|
|
134
|
+
headers.Authorization = `Bearer ${this.jwt}`;
|
|
135
|
+
}
|
|
136
|
+
return (0, cliodot_request_1.applyEnvironmentHeader)(headers, this.environment);
|
|
137
|
+
}
|
|
138
|
+
async loadSurface(force = false) {
|
|
139
|
+
if (!force && this.surface)
|
|
140
|
+
return this.surface;
|
|
141
|
+
if (!force && this.surfacePromise)
|
|
142
|
+
return this.surfacePromise;
|
|
143
|
+
this.surfacePromise = (async () => {
|
|
144
|
+
const path = "/sdk/surface";
|
|
145
|
+
const url = `${this.invokeBaseUrl}${path}`;
|
|
146
|
+
try {
|
|
147
|
+
const response = await this.axios.get(url, {
|
|
148
|
+
headers: this.attestationHeaders("GET", path),
|
|
149
|
+
});
|
|
150
|
+
if (response.status >= 400 || response.data?.ok === false) {
|
|
151
|
+
this.failResponse(response, `Failed to load surface (${response.status})`, "SURFACE_LOAD_FAILED");
|
|
152
|
+
}
|
|
153
|
+
this.surface = response.data.surface;
|
|
154
|
+
return this.surface;
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
this.surfacePromise = null;
|
|
158
|
+
if (error instanceof errors_1.CliodotApiError)
|
|
159
|
+
throw error;
|
|
160
|
+
throw (0, errors_1.cliodotApiErrorFromAxios)(error, "Failed to load surface");
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
163
|
+
return this.surfacePromise;
|
|
164
|
+
}
|
|
165
|
+
findOp(sdkPath, op, catalog) {
|
|
166
|
+
const match = catalog.ops.find((item) => item.op === op &&
|
|
167
|
+
item.sdk_path.length === sdkPath.length &&
|
|
168
|
+
item.sdk_path.every((segment, index) => segment === sdkPath[index]));
|
|
169
|
+
if (!match) {
|
|
170
|
+
const fluent = [...sdkPath, op].join(".");
|
|
171
|
+
throw new errors_1.CliodotApiError(`SDK operation not exposed: ${fluent}`, {
|
|
172
|
+
code: "SDK_OP_NOT_EXPOSED",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return match;
|
|
176
|
+
}
|
|
177
|
+
async invoke(sdkPath, opName, args) {
|
|
178
|
+
const catalog = await this.loadSurface();
|
|
179
|
+
const op = this.findOp(sdkPath, opName, catalog);
|
|
180
|
+
let argIndex = 0;
|
|
181
|
+
const pathParams = {};
|
|
182
|
+
for (const name of op.path_params || []) {
|
|
183
|
+
const value = args[argIndex++];
|
|
184
|
+
if (value === undefined || value === null) {
|
|
185
|
+
throw new errors_1.CliodotApiError(`Missing path argument: ${name}`);
|
|
186
|
+
}
|
|
187
|
+
pathParams[name] = String(value);
|
|
188
|
+
}
|
|
189
|
+
let body;
|
|
190
|
+
let query;
|
|
191
|
+
if (op.body) {
|
|
192
|
+
body = args[argIndex++];
|
|
193
|
+
}
|
|
194
|
+
if (op.query_schema) {
|
|
195
|
+
query = args[argIndex++] || undefined;
|
|
196
|
+
}
|
|
197
|
+
const endpointPath = fillEndpointPath(op.endpoint_path, pathParams);
|
|
198
|
+
const url = `${this.invokeBaseUrl}${endpointPath}`;
|
|
199
|
+
const hasBody = !!op.body && body !== undefined;
|
|
200
|
+
const headers = this.attestationHeaders(op.method, endpointPath, hasBody ? body : undefined);
|
|
201
|
+
if (hasBody) {
|
|
202
|
+
headers["Content-Type"] = "application/json";
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const response = await this.axios.request({
|
|
206
|
+
url,
|
|
207
|
+
method: op.method,
|
|
208
|
+
headers,
|
|
209
|
+
params: query,
|
|
210
|
+
data: hasBody ? body : undefined,
|
|
211
|
+
});
|
|
212
|
+
if (response.status >= 400 || response.data?.ok === false) {
|
|
213
|
+
this.failResponse(response, `Surface request failed (${response.status})`, "SURFACE_REQUEST_FAILED");
|
|
214
|
+
}
|
|
215
|
+
return response.data?.data !== undefined ? response.data.data : response.data;
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
if (error instanceof errors_1.CliodotApiError)
|
|
219
|
+
throw error;
|
|
220
|
+
throw (0, errors_1.cliodotApiErrorFromAxios)(error, "Surface request failed");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
asProxy(path = []) {
|
|
224
|
+
const runtime = this;
|
|
225
|
+
const callable = (...args) => {
|
|
226
|
+
if (path.length === 0) {
|
|
227
|
+
throw new errors_1.CliodotApiError("Surface root is not callable");
|
|
228
|
+
}
|
|
229
|
+
const op = path[path.length - 1];
|
|
230
|
+
const sdkPath = path.slice(0, -1);
|
|
231
|
+
return runtime.invoke(sdkPath, op, args);
|
|
232
|
+
};
|
|
233
|
+
return new Proxy(callable, {
|
|
234
|
+
get(_target, prop) {
|
|
235
|
+
if (typeof prop === "symbol")
|
|
236
|
+
return undefined;
|
|
237
|
+
if (prop === "then")
|
|
238
|
+
return undefined;
|
|
239
|
+
if (prop === "loadSurface") {
|
|
240
|
+
return (force) => runtime.loadSurface(force);
|
|
241
|
+
}
|
|
242
|
+
if (prop === "toString")
|
|
243
|
+
return () => "[Surface]";
|
|
244
|
+
return runtime.asProxy([...path, String(prop)]);
|
|
245
|
+
},
|
|
246
|
+
apply(_target, _thisArg, argArray) {
|
|
247
|
+
return callable(...(argArray || []));
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.Surface = function Surface(config) {
|
|
253
|
+
const runtime = new SurfaceRuntime(config);
|
|
254
|
+
return runtime.asProxy();
|
|
255
|
+
};
|
package/dist/ValidatorBuilder.js
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidatorBuilder = void 0;
|
|
4
|
+
exports.validationGroups = validationGroups;
|
|
5
|
+
class ValidatorBuilder {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._groups = [];
|
|
8
|
+
}
|
|
9
|
+
group(fields, validators) {
|
|
10
|
+
this._groups.push({ fields, validators });
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
addGroup(group) {
|
|
14
|
+
this._groups.push(group);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
build() {
|
|
18
|
+
return this._groups;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ValidatorBuilder = ValidatorBuilder;
|
|
22
|
+
function validationGroups() {
|
|
23
|
+
return new ValidatorBuilder();
|
|
24
|
+
}
|
package/dist/Webhooks.js
CHANGED
|
@@ -1 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Webhooks = void 0;
|
|
7
|
+
exports.buildWebhookReceiveUrl = buildWebhookReceiveUrl;
|
|
8
|
+
exports.signCliodotWebhookPayload = signCliodotWebhookPayload;
|
|
9
|
+
exports.verifyCliodotWebhookSignature = verifyCliodotWebhookSignature;
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
function buildWebhookReceiveUrl(config) {
|
|
12
|
+
const domain = config.domain.trim().replace(/^https?:\/\//, "").split("/")[0];
|
|
13
|
+
const appSlug = config.appSlug.trim().toLowerCase();
|
|
14
|
+
const endpointSlug = config.endpointSlug.trim().toLowerCase();
|
|
15
|
+
const scheme = config.scheme || "https";
|
|
16
|
+
return `${scheme}://${domain}/webhook/${appSlug}/${endpointSlug}`;
|
|
17
|
+
}
|
|
18
|
+
function signCliodotWebhookPayload(secret, timestamp, body) {
|
|
19
|
+
const digest = crypto_1.default
|
|
20
|
+
.createHmac("sha256", secret)
|
|
21
|
+
.update(`${timestamp}.${body}`)
|
|
22
|
+
.digest("hex");
|
|
23
|
+
return `t=${timestamp},v1=${digest}`;
|
|
24
|
+
}
|
|
25
|
+
function verifyCliodotWebhookSignature(input) {
|
|
26
|
+
const header = Array.isArray(input.signatureHeader)
|
|
27
|
+
? input.signatureHeader[0]
|
|
28
|
+
: input.signatureHeader;
|
|
29
|
+
if (!header)
|
|
30
|
+
return false;
|
|
31
|
+
const parts = header.split(",").map((p) => p.trim());
|
|
32
|
+
let timestamp;
|
|
33
|
+
let v1;
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
const [k, v] = part.split("=");
|
|
36
|
+
if (k === "t" && v)
|
|
37
|
+
timestamp = Number(v);
|
|
38
|
+
if (k === "v1" && v)
|
|
39
|
+
v1 = v;
|
|
40
|
+
}
|
|
41
|
+
if (!timestamp || !v1 || Number.isNaN(timestamp))
|
|
42
|
+
return false;
|
|
43
|
+
const tolerance = input.toleranceSeconds ?? 300;
|
|
44
|
+
const now = Math.floor(Date.now() / 1000);
|
|
45
|
+
if (Math.abs(now - timestamp) > tolerance)
|
|
46
|
+
return false;
|
|
47
|
+
const expected = signCliodotWebhookPayload(input.secret, timestamp, input.body);
|
|
48
|
+
const expectedDigest = expected.split("v1=")[1];
|
|
49
|
+
try {
|
|
50
|
+
return crypto_1.default.timingSafeEqual(Buffer.from(expectedDigest, "hex"), Buffer.from(v1, "hex"));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class Webhooks {
|
|
57
|
+
}
|
|
58
|
+
exports.Webhooks = Webhooks;
|
|
59
|
+
Webhooks.buildReceiveUrl = buildWebhookReceiveUrl;
|
|
60
|
+
Webhooks.sign = signCliodotWebhookPayload;
|
|
61
|
+
Webhooks.verify = verifyCliodotWebhookSignature;
|