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.
Files changed (147) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +178 -0
  7. package/dist/CommercialAppClient.d.ts.map +1 -0
  8. package/dist/CommercialAppClient.js +576 -0
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +23 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -0
  18. package/dist/IdentityAppClient.js +197 -0
  19. package/dist/MemoryAppClient.d.ts +28 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -0
  21. package/dist/MemoryAppClient.js +149 -0
  22. package/dist/MemoryClient.d.ts +8 -0
  23. package/dist/MemoryClient.d.ts.map +1 -0
  24. package/dist/MemoryClient.js +20 -0
  25. package/dist/OAuthAppClient.d.ts +1 -0
  26. package/dist/OAuthAppClient.d.ts.map +1 -1
  27. package/dist/OAuthAppClient.js +269 -1
  28. package/dist/ProviderServicesClient.d.ts +24 -0
  29. package/dist/ProviderServicesClient.d.ts.map +1 -0
  30. package/dist/ProviderServicesClient.js +158 -0
  31. package/dist/Surface.d.ts +2 -0
  32. package/dist/Surface.d.ts.map +1 -1
  33. package/dist/Surface.js +255 -1
  34. package/dist/ValidatorBuilder.js +24 -1
  35. package/dist/Webhooks.d.ts +20 -0
  36. package/dist/Webhooks.d.ts.map +1 -0
  37. package/dist/Webhooks.js +61 -0
  38. package/dist/WorkflowBuilder.js +279 -1
  39. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  40. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  41. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  42. package/dist/__tests__/Events.test.js +191 -1
  43. package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
  44. package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
  45. package/dist/__tests__/IdentityAppClient.test.js +232 -0
  46. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  47. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  48. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  49. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  50. package/dist/__tests__/Surface.test.js +150 -1
  51. package/dist/__tests__/errors.test.js +54 -1
  52. package/dist/__tests__/function.test.js +58 -1
  53. package/dist/__tests__/helpers.d.ts +5 -0
  54. package/dist/__tests__/helpers.d.ts.map +1 -0
  55. package/dist/__tests__/helpers.js +10 -0
  56. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  57. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  58. package/dist/__tests__/localhost-lookup.test.js +26 -0
  59. package/dist/__tests__/parse-api-error.test.js +26 -1
  60. package/dist/__tests__/runner.test.js +156 -1
  61. package/dist/connectors/builtin.js +354 -1
  62. package/dist/connectors/registry.js +300 -1
  63. package/dist/decorators/build.js +105 -1
  64. package/dist/decorators/connector.js +56 -1
  65. package/dist/decorators/index.js +34 -1
  66. package/dist/decorators/metadata.js +338 -1
  67. package/dist/decorators/steps.js +220 -1
  68. package/dist/decorators/workflow.js +52 -1
  69. package/dist/errors.js +76 -1
  70. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  71. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  73. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  74. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  75. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  76. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  77. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  78. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  79. package/dist/http/cliodot-request.d.ts +35 -0
  80. package/dist/http/cliodot-request.d.ts.map +1 -0
  81. package/dist/http/cliodot-request.js +105 -0
  82. package/dist/http/cliodot-result.d.ts +40 -0
  83. package/dist/http/cliodot-result.d.ts.map +1 -0
  84. package/dist/http/cliodot-result.js +139 -0
  85. package/dist/http/create-client.d.ts +3 -0
  86. package/dist/http/create-client.d.ts.map +1 -0
  87. package/dist/http/create-client.js +14 -0
  88. package/dist/http/events-instance-id.d.ts +11 -0
  89. package/dist/http/events-instance-id.d.ts.map +1 -0
  90. package/dist/http/events-instance-id.js +86 -0
  91. package/dist/http/localhost-lookup.d.ts +12 -0
  92. package/dist/http/localhost-lookup.d.ts.map +1 -0
  93. package/dist/http/localhost-lookup.js +67 -0
  94. package/dist/http/parse-api-error.js +56 -1
  95. package/dist/http/sanitize-execution-headers.js +79 -1
  96. package/dist/identity-offline-verify.d.ts +6 -0
  97. package/dist/identity-offline-verify.d.ts.map +1 -0
  98. package/dist/identity-offline-verify.js +174 -0
  99. package/dist/identity-token-cache.d.ts +6 -0
  100. package/dist/identity-token-cache.d.ts.map +1 -0
  101. package/dist/identity-token-cache.js +51 -0
  102. package/dist/index.d.ts +10 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +108 -1
  105. package/dist/runner/ProcessorEngine.js +1311 -1
  106. package/dist/runner/connector.executor.js +1786 -1
  107. package/dist/runner/utilities/math.executor.js +153 -1
  108. package/dist/runner/utilities/random.executor.js +151 -1
  109. package/dist/runner/utilities/string.executor.js +825 -1
  110. package/dist/template.js +127 -1
  111. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  112. package/dist/transformers/WorkflowTransformer.js +189 -1
  113. package/dist/types/auth-app.api.d.ts +2 -0
  114. package/dist/types/auth-app.api.d.ts.map +1 -1
  115. package/dist/types/auth-app.api.js +2 -1
  116. package/dist/types/builtin.js +2 -1
  117. package/dist/types/client.api.js +2 -1
  118. package/dist/types/commercial-app.api.d.ts +963 -0
  119. package/dist/types/commercial-app.api.d.ts.map +1 -0
  120. package/dist/types/commercial-app.api.js +2 -0
  121. package/dist/types/connector.js +2 -1
  122. package/dist/types/context.js +2 -1
  123. package/dist/types/event-app.api.d.ts +8 -0
  124. package/dist/types/event-app.api.d.ts.map +1 -1
  125. package/dist/types/event-app.api.js +2 -1
  126. package/dist/types/function.js +2 -1
  127. package/dist/types/identity-app.api.d.ts +99 -0
  128. package/dist/types/identity-app.api.d.ts.map +1 -0
  129. package/dist/types/identity-app.api.js +2 -0
  130. package/dist/types/index.js +23 -1
  131. package/dist/types/memory-app.api.d.ts +140 -0
  132. package/dist/types/memory-app.api.d.ts.map +1 -0
  133. package/dist/types/memory-app.api.js +2 -0
  134. package/dist/types/oauth-app.api.d.ts +2 -0
  135. package/dist/types/oauth-app.api.d.ts.map +1 -1
  136. package/dist/types/oauth-app.api.js +105 -1
  137. package/dist/types/provider-services.api.d.ts +98 -0
  138. package/dist/types/provider-services.api.d.ts.map +1 -0
  139. package/dist/types/provider-services.api.js +2 -0
  140. package/dist/types/validator.js +2 -1
  141. package/dist/types/webhook-app.api.d.ts +2 -0
  142. package/dist/types/webhook-app.api.d.ts.map +1 -0
  143. package/dist/types/webhook-app.api.js +2 -0
  144. package/dist/types/workflow.js +33 -1
  145. package/dist/validators/validators.js +478 -1
  146. package/dist/variable.js +37 -1
  147. package/package.json +3 -2
@@ -1 +1,300 @@
1
- 'use strict';const _0x67b94e=_0x4955;(function(_0x534608,_0x2d684c){const _0x2cce2c=_0x4955,_0x3b3316=_0x534608();while(!![]){try{const _0x18448e=parseInt(_0x2cce2c(0x1a8))/0x1*(parseInt(_0x2cce2c(0x1f4))/0x2)+parseInt(_0x2cce2c(0x1d9))/0x3+-parseInt(_0x2cce2c(0x1ea))/0x4+parseInt(_0x2cce2c(0x1ff))/0x5+-parseInt(_0x2cce2c(0x1c0))/0x6*(-parseInt(_0x2cce2c(0x20c))/0x7)+-parseInt(_0x2cce2c(0x1ef))/0x8+parseInt(_0x2cce2c(0x203))/0x9*(-parseInt(_0x2cce2c(0x1ee))/0xa);if(_0x18448e===_0x2d684c)break;else _0x3b3316['push'](_0x3b3316['shift']());}catch(_0x231a4a){_0x3b3316['push'](_0x3b3316['shift']());}}}(_0x48fc,0x5c319));function _0x4955(_0x4cd9e7,_0x3e42a3){_0x4cd9e7=_0x4cd9e7-0x19d;const _0x48fc4f=_0x48fc();let _0x495530=_0x48fc4f[_0x4cd9e7];if(_0x4955['MulJpt']===undefined){var _0x43af09=function(_0x109dea){const _0x1bdab0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4d87c5='',_0x1f7373='';for(let _0xaff68b=0x0,_0x1929b3,_0x48479a,_0x31b38d=0x0;_0x48479a=_0x109dea['charAt'](_0x31b38d++);~_0x48479a&&(_0x1929b3=_0xaff68b%0x4?_0x1929b3*0x40+_0x48479a:_0x48479a,_0xaff68b++%0x4)?_0x4d87c5+=String['fromCharCode'](0xff&_0x1929b3>>(-0x2*_0xaff68b&0x6)):0x0){_0x48479a=_0x1bdab0['indexOf'](_0x48479a);}for(let _0x3f30c3=0x0,_0x5a9431=_0x4d87c5['length'];_0x3f30c3<_0x5a9431;_0x3f30c3++){_0x1f7373+='%'+('00'+_0x4d87c5['charCodeAt'](_0x3f30c3)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1f7373);};_0x4955['otAySI']=_0x43af09,_0x4955['EIKsGU']={},_0x4955['MulJpt']=!![];}const _0x1fea8c=_0x48fc4f[0x0],_0x5cf2fd=_0x4cd9e7+_0x1fea8c,_0x162aeb=_0x4955['EIKsGU'][_0x5cf2fd];return!_0x162aeb?(_0x495530=_0x4955['otAySI'](_0x495530),_0x4955['EIKsGU'][_0x5cf2fd]=_0x495530):_0x495530=_0x162aeb,_0x495530;}var __importDefault=this&&this[_0x67b94e(0x1a1)]||function(_0x4d87c5){const _0x5adaf7=_0x67b94e;return _0x4d87c5&&_0x4d87c5[_0x5adaf7(0x1c8)]?_0x4d87c5:{'default':_0x4d87c5};};Object['defineProperty'](exports,_0x67b94e(0x1c8),{'value':!![]});const axios_1=__importDefault(require(_0x67b94e(0x1df))),OAuthAppClient_1=require('../OAuthAppClient'),errors_1=require(_0x67b94e(0x19f)),oauth_app_api_1=require(_0x67b94e(0x1ba));function _0x48fc(){const _0x3f2418=['l2fWChmVB2f1DgHFyxbWx3rLC3qVy29UBMvJDa','y3jLyxrL','lI4VDhLWzxmVB2f1DgGTyxbWlMfWAq','Cg9SBa','C2fTBa','Dg9iyxzLqMvLBKnHBgXLzfDPDgG','y3jLyxrLCYbHEgLVCYbJBgLLBNqGD2L0AcaVB2f1DgGGyMfZzsbvuKW','DxnLCL8X','mtmYvvjssMvU','CgfZC2vZigfZC2vYDgLVBIbNCMfUDhmGB24Gy29UBMvJDcbZDgfYDa','B2jQzwn0q29UDgfPBMLUzW','y29UBMvJDgLVBNm','BwfWCYbJB25Uzwn0Aw9UCY5YzwzYzxnOigfUzcbJB25Uzwn0Aw9UCY5YzxzVA2u','Ahr0Chm6lY9Hy2nVDw50CY5NB29NBguUy29Tl28VB2f1DgGYl3yYl2f1DgG/lI4U','y29UBMvJDgLVBG','Dg9iyxzLqMvLBKnHBgXLzfrPBwvZ','x19LC01VzhvSzq','C3rHCNrZigLTBwvKAwf0zsbJBgLLBNrFy3jLzgvUDgLHBhmGy29UBMvJDa','BtjTlwfWAq','C3rHCNq','CMv0DxjUCYbtqu1mihnLC3nPB24GzMLLBgrZigzYB20GzxHJAgfUz2u','y2XPzw50x2nYzwrLBNrPywXZ','B2fRx2fIyW','C3LUyYbHBgLHC2vZigDLDfrVA2vU','y3nYzG','B2f1DgHFyxbWx3rLC3q','zxHJAgfUz2vFy29Kzq','C3rHCNrZifnbtuWGy29UBMvJDcbHBMqGyNvPBgrZifbpu1qGzM9YBsbMAwvSzhm','t0f1DgHdB25Uzwn0Aw9Uu3rVCMfNzq','Axntyw1Sug9ZDejPBMrPBMC','z2v0','z2v0vg9Rzw4','Dg9uAhjVDW','mtK4nZm4wLbvD2XY','y29UBL9Zyw1S','Ahr0Chm6lY9HCgKUzxHHBxbSzs5JB20VB2f1DgGVyxbWCY9Vyxv0Af9HChbFDgvZDc9JB25Uzwn0p3bYB3zPzgvYpwDVB2DSzszYzwrPCMvJDf91CMK9Ahr0ChmLm0eLmKyLmKzHChaUzxHHBxbSzs5JB20LmKzJywXSyMfJAYzZy29Wzt1VCgvUAwqRzw1HAwWMC3rHDgu9y3nYzIzLEhrLCM5HBf91C2vYx2LKpxvZzxjFmszJB25Uzwn0Aw9Ux3n0B3jHz2u9zxbOzw1LCMfS','C2fTBf9HDhrYAwj1DgvZ','yNvPBgrZignVBM5Ly3qGvvjmihDPDgGGCxvLCNKGCgfYyw1Z','yNvPBgrtyw1Sug9ZDezVCM0','yxHPB3m','yMfK','zxHFy29Kzq','r0vu','zxHJAgfUz2u','z29Vz2XL','l2fWChmVB2f1DgHFyxbWx3rLC3qVy29UBMvJDc9WB2XS','yxv0Ag9YAxPHDgLVBL91CMW','Ahr0Chm6lY9HChaUzxHHBxbSzs5JB20Vy2fSBgjHy2S','zxHJAgfUz2vZihrVA2vUihDPDgGGy29YCMvJDcbWyxrOigfUzcbIB2r5','t0f1DgHbChbdBgLLBNq','nZiWotqWCg9ewNbq','y29UBL9PBw1LzgLHDgu','yNvPBgrvCMW','y29UBL8X','mtuWA1bsv3fb','nJiZmJu2AuL5uNfe','y29UBMvJDgLVBL9Pza','qMvHCMvY','y29UBMvJDa','Dg9dB250ywLU','mtC4ndHPvMnqvwS','zgvMyxvSDa','CgfYC2vZiefqssbLCNjVCIbYzxnWB25Zzxm','rvbiru1fuKfm','ywn0AxzL','B2fRx3rLC3rFA2v5','Ahr0Chm6lY9HChaUzxHHBxbSzs5JB20Vy2fSBgjHy2S/y29Kzt1LEf9PBw1LzgLHDguMy29UBMvJDgLVBL9Pzd1JB25Ux2LTBwvKAwf0zq','y29UBL9QD3q','ChjVDg9JB2W','sw52ywXPzcbVCIbLEhbPCMvKigv4y2HHBMDLignVzgu','Ahr0Chm6lY9PzhaUzxHHBxbSzs5JB20VC3nV','mJa1oti2meTSqNjVsW','z29Vz2XLlxnZBW','zxLklMfZC2vYDgLVBG','CMvMCMvZAa','ntyYmdK1v1rwB2jL','DxjUoMLLDgy6CgfYyw1ZoM9HDxrOoMDYyw50lxr5Cgu6zgv2AwnLx2nVzgu','ywrTAw4','zxHFAw1TzwrPyxrL','Bw9JA1jLC29SDMvKvMfSDwu','yxv0Ag9YAxPHDgLVBL9Wzw5KAw5N','Dg9czq','CMv2B2TLza','CMvQzwn0CW','mtK3nZu3EhLtrM5Q','EweYos5ZEw5J','y2XLyxjbBgXnB2nRCW','Bw9JA1jLAMvJDgvKvMfSDwu','B3bLBMLK','ywnJzxnZx3rVA2vU','Dg9iyxzLqMvLBKXHC3rdywXSzwrxAxrO','CgfYC2vZiefqssbLCNjVCIbYzxnWB25ZzxmGD2L0AcbUzxn0zwqGzxjYB3iGB2jQzwn0','Cg9SBhmGzgv2AwnLignVBM5Ly3qGDw50AwWGy29TCgXLDgu','Cg9SBc1ZDgf0zs0X','t0fvveHFufjpvKLervjFrvjst1i','t0fvveHFrvHdsefor0vFq09erv9jtLzbteLe','DxnLCYbczwfYzxiGyxbWqxbPs2v5igzVCIbtmLmGCMvXDwvZDhm','tM8GCMvMCMvZAcb0B2TLBIbHDMfPBgfIBguGzM9YihrOAxmGy29UBMvJDgLVBG','ywnJB3vUDhmUz29Vz2XLlMnVBq','C2vJCMv0x2fIyW','DxjUoMLLDgy6CgfYyw1ZoM9HDxrOoMDYyw50lxr5Cgu6AND0lwjLyxjLCG','lI4VzxjYB3jZ','Dg9fCxvHBa','x19PBxbVCNrezwzHDwX0','yxv0Ag9YAxPHDgLVBL9JB2rL','Bw9JAW','DxnLCKbLEgfTCgXLlMnVBq','Bw9JA1jLAMvJDgvKvMfSDwvpBMnL','zxHFzgv2AwnL','l2nVBM5Ly3rPB25Zl2nVBM5Fms9YzxzVA2u','ntnVzhrMr2q','t0f1DgGGyxbWignYzwrLBNrPywXZihjLCxvPCMvK','Ahr0Chm6lY9HCgKUzxHHBxbSzs5JB20','DgHYB3DZihDOzw4GuZjtignHBgXLzcb3AxrOB3v0ignYzwrLBNrPywXZ','DxnLCYbHChaGAwqGkYbZzwnYzxqGAgvHzgvYCYb3AgvUig5VigfWAsbRzxK','DxnLCIbSzwz0','EweYos5UzxC','DhyTyxbW','q2XPB2rVDefWAuvYCM9Y','ue9tva','Cg9ZDa','Bw9JA1jLC29SDMvKvMfSDwvpBMnL','Dg9nyxrJAe9IAMvJDa','qMvHCMvYig9HA19HyMm','CMvSyxKTmtiZ','CMvXDwLYzxmGyMfZzvvYBcbHBMqGyxbWswq'];_0x48fc=function(){return _0x3f2418;};return _0x48fc();}jest[_0x67b94e(0x1a3)](_0x67b94e(0x1df));const mockedAxios=axios_1[_0x67b94e(0x1f5)];describe(_0x67b94e(0x1e9),()=>{const _0x32c69d=_0x67b94e,_0x1f7373=jest['fn']();beforeEach(()=>{const _0x36af73=_0x4955;jest[_0x36af73(0x20e)](),mockedAxios[_0x36af73(0x1b9)]['mockReturnValue'](_0x1f7373);});function _0xaff68b(_0x1929b3){const _0xf4783c=_0x4955;return new OAuthAppClient_1[(_0xf4783c(0x1e9))]({'baseUrl':_0xf4783c(0x1aa),'appId':_0xf4783c(0x1d1),'appApiKey':_0xf4783c(0x1f9),..._0x1929b3});}it(_0x32c69d(0x1b7),()=>{const _0x1bd8d4=_0x32c69d;expect(()=>new OAuthAppClient_1[(_0x1bd8d4(0x1e9))]({'baseUrl':'','appId':_0x1bd8d4(0x1d1)}))[_0x1bd8d4(0x1d8)](errors_1[_0x1bd8d4(0x1b0)]),expect(()=>new OAuthAppClient_1[(_0x1bd8d4(0x1e9))]({'baseUrl':_0x1bd8d4(0x1aa),'appId':''}))[_0x1bd8d4(0x1d8)](errors_1[_0x1bd8d4(0x1b0)]);}),it(_0x32c69d(0x1dd),()=>{const _0x1752a0=_0x32c69d,_0x48479a=_0xaff68b(),_0x31b38d=_0x48479a[_0x1752a0(0x1f2)][_0x1752a0(0x1ec)]({'provider':_0x1752a0(0x1e4),'redirect_uri':_0x1752a0(0x1e7),'scopes':[_0x1752a0(0x210),'email'],'state':_0x1752a0(0x1d0),'external_user_id':_0x1752a0(0x1bf),'connection_storage':oauth_app_api_1[_0x1752a0(0x1d4)][_0x1752a0(0x1f7)]});expect(_0x31b38d)[_0x1752a0(0x209)](_0x1752a0(0x1db));}),it('starts\x20connect\x20without\x20S2S\x20auth\x20headers',async()=>{const _0x5b9b89=_0x32c69d;_0x1f7373[_0x5b9b89(0x207)]({'data':{'ok':!![],'grant_type':_0x5b9b89(0x1a2),'authorization_url':_0x5b9b89(0x1c5)}});const _0x3f30c3=_0xaff68b(),_0x5a9431=await _0x3f30c3[_0x5b9b89(0x1f2)][_0x5b9b89(0x1cb)]({'provider':_0x5b9b89(0x1e4),'redirect_uri':_0x5b9b89(0x1e7)});expect(_0x5a9431[_0x5b9b89(0x1e6)])[_0x5b9b89(0x1f3)](_0x5b9b89(0x21a)),expect(_0x1f7373)[_0x5b9b89(0x1bd)](expect[_0x5b9b89(0x1c2)]({'method':_0x5b9b89(0x1b1),'url':_0x5b9b89(0x1b8),'headers':{},'data':{'provider':_0x5b9b89(0x1e4),'redirect_uri':'https://app.example.com/callback'}}));}),it(_0x32c69d(0x218),async()=>{const _0x13ede2=_0x32c69d;_0x1f7373[_0x13ede2(0x207)]({'data':{'ok':!![],'connection':{'id':_0x13ede2(0x1ed)}}});const _0x3de0e5=_0xaff68b({'appApiKey':_0x13ede2(0x1ce)});await _0x3de0e5['connections'][_0x13ede2(0x1d6)](_0x13ede2(0x1ed)),expect(_0x1f7373)[_0x13ede2(0x1bd)](expect[_0x13ede2(0x1c2)]({'method':'GET','url':'/connections/conn_1','headers':{'Authorization':_0x13ede2(0x1b5)}}));}),it(_0x32c69d(0x1ac),async()=>{const _0x2b94e4=_0x32c69d;_0x1f7373[_0x2b94e4(0x207)]({'data':{'ok':!![],'connection':{'id':'conn_1'}}});const _0x2b88ca=_0xaff68b({'appApiKey':undefined,'appSecret':_0x2b94e4(0x19d)});await _0x2b88ca[_0x2b94e4(0x1c3)]['get'](_0x2b94e4(0x1ed)),expect(_0x1f7373)[_0x2b94e4(0x1bd)](expect[_0x2b94e4(0x1c2)]({'headers':{'X-Cliodot-App-Id':'oauth_app_test','X-Cliodot-App-Secret':_0x2b94e4(0x19d)}}));}),it(_0x32c69d(0x1ab),async()=>{const _0x12cd59=_0x32c69d,_0xccb04=_0xaff68b({'appApiKey':undefined,'appSecret':undefined});await expect(_0xccb04[_0x12cd59(0x1e3)]({'code':'ex_1','connection_id':'conn_1'}))[_0x12cd59(0x20b)]['toThrow'](_0x12cd59(0x1a9));}),it(_0x32c69d(0x1e8),async()=>{const _0x1b20d3=_0x32c69d;_0x1f7373[_0x1b20d3(0x207)]({'data':{'ok':!![],'connection':{'id':_0x1b20d3(0x1ed),'provider':_0x1b20d3(0x1e4),'status':'active'}}});const _0x4f40d5=_0xaff68b(),_0x57c7b9=await _0x4f40d5[_0x1b20d3(0x1e3)]({'code':'ex_code','connection_id':_0x1b20d3(0x1ed)});expect(_0x57c7b9[_0x1b20d3(0x1c6)]['id'])[_0x1b20d3(0x209)](_0x1b20d3(0x1ed)),expect(_0x1f7373)[_0x1b20d3(0x1bd)](expect[_0x1b20d3(0x1c2)]({'method':_0x1b20d3(0x1b1),'url':'/token/exchange','data':{'code':_0x1b20d3(0x1e1),'connection_id':_0x1b20d3(0x1ed)}}));}),it(_0x32c69d(0x1c4),async()=>{const _0x257b76=_0x32c69d;_0x1f7373[_0x257b76(0x1b3)]({'data':{'ok':!![],'connection':{'id':_0x257b76(0x1ed)},'access_token':_0x257b76(0x1ae)}})['mockResolvedValueOnce']({'data':{'ok':!![],'revoked':!![]}});const _0xa80f52=_0xaff68b(),_0x22a1a6=await _0xa80f52['connections'][_0x257b76(0x202)](_0x257b76(0x1ed));expect(_0x22a1a6['access_token'])['toBe'](_0x257b76(0x1ae)),expect(_0x1f7373)[_0x257b76(0x1bd)](expect[_0x257b76(0x1c2)]({'method':_0x257b76(0x1b1),'url':'/connections/conn_1/refresh'}));const _0x3cf7d6=await _0xa80f52[_0x257b76(0x1c3)]['revoke']('conn_1',{'reason':'user\x20left'});expect(_0x3cf7d6[_0x257b76(0x20a)])['toBe'](!![]),expect(_0x1f7373)[_0x257b76(0x1bd)](expect['objectContaining']({'method':_0x257b76(0x1b1),'url':_0x257b76(0x1a7),'data':{'reason':_0x257b76(0x1ad)}}));}),it(_0x32c69d(0x1cf),async()=>{const _0x21fc55=_0x32c69d;_0x1f7373[_0x21fc55(0x207)]({'data':{'ok':!![],'access_token':_0x21fc55(0x20d),'token_type':_0x21fc55(0x1f1)}});const _0x5da139=_0xaff68b(),_0x2c8444=await _0x5da139['connections']['sync'](_0x21fc55(0x1ed));expect(_0x2c8444[_0x21fc55(0x211)])[_0x21fc55(0x209)](_0x21fc55(0x20d)),expect(_0x1f7373)[_0x21fc55(0x1bd)](expect[_0x21fc55(0x1c2)]({'method':_0x21fc55(0x1e2),'url':'/connections/conn_1/token'}));}),it(_0x32c69d(0x1f6),async()=>{const _0x3cd50b=_0x32c69d;_0x1f7373['mockRejectedValue']({'response':{'status':0x190,'data':{'ok':![],'error':_0x3cd50b(0x1fd),'code':_0x3cd50b(0x217)}}});const _0x2fc690=_0xaff68b();await expect(_0x2fc690['exchange']({'code':_0x3cd50b(0x1e0),'connection_id':_0x3cd50b(0x1ed)}))['rejects']['toMatchObject']({'message':_0x3cd50b(0x1fd),'status':0x190,'code':_0x3cd50b(0x217)});}),it(_0x32c69d(0x213),async()=>{const _0x47a796=_0x32c69d;_0x1f7373[_0x47a796(0x20f)]({'response':{'status':0x1a6,'data':{'message':_0x47a796(0x219),'status':![],'statusCode':0x1a6,'data':null,'error':{'statusCode':0x1a6,'code':_0x47a796(0x216)}}}});const _0x570c03=_0xaff68b();await expect(_0x570c03[_0x47a796(0x1c3)][_0x47a796(0x1d7)](_0x47a796(0x1ed)))['rejects'][_0x47a796(0x1b4)]({'message':_0x47a796(0x219),'status':0x1a6,'code':_0x47a796(0x216)});}),it(_0x32c69d(0x1d3),async()=>{const _0x4c4b23=_0x32c69d;_0x1f7373['mockResolvedValue']({'data':{'ok':!![],'protocol':_0x4c4b23(0x1bc),'authorization_url':_0x4c4b23(0x1fe),'sso_binding':_0x4c4b23(0x1b2),'saml_request':'PHNhbWxwOlJlcXVlc3Q...','relay_state':_0x4c4b23(0x1b6)}});const _0x10694d=_0xaff68b(),_0x1b7d0e=await _0x10694d[_0x4c4b23(0x1f2)]['start']({'provider':'google-sso','redirect_uri':_0x4c4b23(0x1e7)});expect(_0x1b7d0e['protocol'])[_0x4c4b23(0x209)]('saml'),expect(_0x10694d[_0x4c4b23(0x1f2)][_0x4c4b23(0x1d5)](_0x1b7d0e))[_0x4c4b23(0x209)](!![]),expect(_0x10694d[_0x4c4b23(0x1f2)][_0x4c4b23(0x1de)](_0x1b7d0e))['toEqual']({'action':'https://idp.example.com/sso','samlRequest':'PHNhbWxwOlJlcXVlc3Q...','relayState':_0x4c4b23(0x1b6)});}),it(_0x32c69d(0x1cc),async()=>{const _0x47ae55=_0x32c69d;_0x1f7373[_0x47ae55(0x207)]({'data':{'ok':!![],'protocol':'saml','connection':{'id':_0x47ae55(0x1da),'provider':_0x47ae55(0x200),'protocol':_0x47ae55(0x1bc),'status':_0x47ae55(0x1f8)},'name_id':_0x47ae55(0x1a4),'saml_attributes':{'email':_0x47ae55(0x1a4),'role':'admin'}}});const _0x2070b7=_0xaff68b(),_0x5786aa=await _0x2070b7[_0x47ae55(0x1e3)]({'code':_0x47ae55(0x1e1),'connection_id':_0x47ae55(0x1da)});expect(_0x5786aa[_0x47ae55(0x1fc)])['toBe'](_0x47ae55(0x1bc)),expect(_0x5786aa['name_id'])[_0x47ae55(0x209)](_0x47ae55(0x1a4)),expect(_0x5786aa[_0x47ae55(0x1dc)])[_0x47ae55(0x1a0)]({'email':_0x47ae55(0x1a4),'role':_0x47ae55(0x205)});}),it(_0x32c69d(0x1be),()=>{const _0x3a1404=_0x32c69d;_0xaff68b({'baseUrl':'https://api.example.com/'}),expect(mockedAxios[_0x3a1404(0x1b9)])['toHaveBeenCalledWith'](expect['objectContaining']({'baseURL':'https://api.example.com/oauth'}));}),it(_0x32c69d(0x1c9),async()=>{const _0x2538fa=_0x32c69d;_0x1f7373[_0x2538fa(0x207)]({'data':{'ok':!![],'protocol':'oauth2','grant_type':_0x2538fa(0x1cd),'exchange_code':'ex_immediate','connection_id':_0x2538fa(0x1eb),'redirect_url':_0x2538fa(0x1fa)}});const _0x83dd4a=_0xaff68b(),_0x23e706=await _0x83dd4a[_0x2538fa(0x1f2)][_0x2538fa(0x1cb)]({'provider':'m2m','redirect_uri':_0x2538fa(0x1e7)});expect(_0x23e706[_0x2538fa(0x1d2)])[_0x2538fa(0x209)](_0x2538fa(0x206)),expect(_0x23e706[_0x2538fa(0x1f0)])['toBe'](_0x2538fa(0x1eb));}),it(_0x32c69d(0x214),async()=>{const _0x3d1006=_0x32c69d;_0x1f7373[_0x3d1006(0x1a5)]({'response':{'status':0x1ac,'data':{'ok':![],'error':_0x3d1006(0x208),'code':_0x3d1006(0x216)}}})[_0x3d1006(0x1b3)]({'data':{'ok':!![],'grant_type':_0x3d1006(0x204),'exchange_code':_0x3d1006(0x1a6),'connection_id':'conn_device'}});const _0x7a6750=_0xaff68b(),_0x563bad=await _0x7a6750[_0x3d1006(0x1f2)][_0x3d1006(0x1bb)]({'provider':_0x3d1006(0x1af),'poll_state':'poll-state-1','pollIntervalMs':0x1});expect(_0x563bad[_0x3d1006(0x1d2)])[_0x3d1006(0x209)](_0x3d1006(0x1a6)),expect(_0x1f7373)[_0x3d1006(0x1c7)](0x2),expect(_0x1f7373)[_0x3d1006(0x212)](expect['objectContaining']({'method':'POST','url':_0x3d1006(0x1e5),'data':{'provider':'tv-app','poll_state':_0x3d1006(0x215)}}));}),it(_0x32c69d(0x1c1),async()=>{const _0x3295d2=_0x32c69d;_0x1f7373[_0x3295d2(0x207)]({'data':{'ok':!![],'grant_type':_0x3295d2(0x19e),'exchange_code':'ex_jwt','connection_id':_0x3295d2(0x1fb)}});const _0x100066=_0xaff68b();await _0x100066[_0x3295d2(0x1f2)][_0x3295d2(0x1cb)]({'provider':_0x3295d2(0x1ca),'redirect_uri':_0x3295d2(0x1e7),'assertion':_0x3295d2(0x201)}),expect(_0x1f7373)['toHaveBeenCalledWith'](expect[_0x3295d2(0x1c2)]({'data':expect[_0x3295d2(0x1c2)]({'assertion':'eyJ.assertion'})}));});});
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
+ const axios_1 = __importDefault(require("axios"));
7
+ const OAuthAppClient_1 = require("../OAuthAppClient");
8
+ const errors_1 = require("../errors");
9
+ const oauth_app_api_1 = require("../types/oauth-app.api");
10
+ jest.mock("axios");
11
+ const mockedAxios = axios_1.default;
12
+ describe("OAuthAppClient", () => {
13
+ const mockAxiosInstance = jest.fn();
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ mockedAxios.create.mockReturnValue(mockAxiosInstance);
17
+ });
18
+ function createClient(overrides) {
19
+ return new OAuthAppClient_1.OAuthAppClient({
20
+ baseUrl: "https://api.example.com",
21
+ appId: "oauth_app_test",
22
+ appApiKey: "oak_test_key",
23
+ ...overrides,
24
+ });
25
+ }
26
+ it("requires baseUrl and appId", () => {
27
+ expect(() => new OAuthAppClient_1.OAuthAppClient({ baseUrl: "", appId: "oauth_app_test" })).toThrow(errors_1.CliodotApiError);
28
+ expect(() => new OAuthAppClient_1.OAuthAppClient({ baseUrl: "https://api.example.com", appId: "" })).toThrow(errors_1.CliodotApiError);
29
+ });
30
+ it("builds connect URL with query params", () => {
31
+ const client = createClient();
32
+ const url = client.connect.buildUrl({
33
+ provider: "google",
34
+ redirect_uri: "https://app.example.com/callback",
35
+ scopes: ["openid", "email"],
36
+ state: "csrf",
37
+ external_user_id: "user_1",
38
+ connection_storage: oauth_app_api_1.OAuthConnectionStorage.EPHEMERAL,
39
+ });
40
+ expect(url).toBe("https://api.example.com/oauth/apps/oauth_app_test/connect?provider=google&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=openid+email&state=csrf&external_user_id=user_1&connection_storage=ephemeral");
41
+ });
42
+ it("starts connect without S2S auth headers", async () => {
43
+ mockAxiosInstance.mockResolvedValue({
44
+ data: {
45
+ ok: true,
46
+ grant_type: "authorization_code",
47
+ authorization_url: "https://accounts.google.com/o/oauth2/v2/auth?...",
48
+ },
49
+ });
50
+ const client = createClient();
51
+ const result = await client.connect.start({
52
+ provider: "google",
53
+ redirect_uri: "https://app.example.com/callback",
54
+ });
55
+ expect(result.authorization_url).toContain("accounts.google.com");
56
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
57
+ method: "POST",
58
+ url: "/apps/oauth_app_test/connect",
59
+ headers: {},
60
+ data: {
61
+ provider: "google",
62
+ redirect_uri: "https://app.example.com/callback",
63
+ },
64
+ }));
65
+ });
66
+ it("uses Bearer appApiKey for S2S requests", async () => {
67
+ mockAxiosInstance.mockResolvedValue({
68
+ data: { ok: true, connection: { id: "conn_1" } },
69
+ });
70
+ const client = createClient({ appApiKey: "oak_abc" });
71
+ await client.connections.get("conn_1");
72
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
73
+ method: "GET",
74
+ url: "/connections/conn_1",
75
+ headers: { Authorization: "Bearer oak_abc" },
76
+ }));
77
+ });
78
+ it("uses app id + secret headers when no api key", async () => {
79
+ mockAxiosInstance.mockResolvedValue({
80
+ data: { ok: true, connection: { id: "conn_1" } },
81
+ });
82
+ const client = createClient({
83
+ appApiKey: undefined,
84
+ appSecret: "secret_abc",
85
+ });
86
+ await client.connections.get("conn_1");
87
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
88
+ headers: {
89
+ "X-Cliodot-App-Id": "oauth_app_test",
90
+ "X-Cliodot-App-Secret": "secret_abc",
91
+ },
92
+ }));
93
+ });
94
+ it("throws when S2S called without credentials", async () => {
95
+ const client = createClient({ appApiKey: undefined, appSecret: undefined });
96
+ await expect(client.exchange({ code: "ex_1", connection_id: "conn_1" })).rejects.toThrow("OAuth app credentials required");
97
+ });
98
+ it("exchanges token with correct path and body", async () => {
99
+ mockAxiosInstance.mockResolvedValue({
100
+ data: {
101
+ ok: true,
102
+ connection: { id: "conn_1", provider: "google", status: "active" },
103
+ },
104
+ });
105
+ const client = createClient();
106
+ const result = await client.exchange({ code: "ex_code", connection_id: "conn_1" });
107
+ expect(result.connection.id).toBe("conn_1");
108
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
109
+ method: "POST",
110
+ url: "/token/exchange",
111
+ data: { code: "ex_code", connection_id: "conn_1" },
112
+ }));
113
+ });
114
+ it("maps connections.refresh and connections.revoke", async () => {
115
+ mockAxiosInstance
116
+ .mockResolvedValueOnce({
117
+ data: {
118
+ ok: true,
119
+ connection: { id: "conn_1" },
120
+ access_token: "ya29.new",
121
+ },
122
+ })
123
+ .mockResolvedValueOnce({ data: { ok: true, revoked: true } });
124
+ const client = createClient();
125
+ const refreshed = await client.connections.refresh("conn_1");
126
+ expect(refreshed.access_token).toBe("ya29.new");
127
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({ method: "POST", url: "/connections/conn_1/refresh" }));
128
+ const revoked = await client.connections.revoke("conn_1", { reason: "user left" });
129
+ expect(revoked.revoked).toBe(true);
130
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
131
+ method: "POST",
132
+ url: "/connections/conn_1/revoke",
133
+ data: { reason: "user left" },
134
+ }));
135
+ });
136
+ it("sync aliases getToken", async () => {
137
+ mockAxiosInstance.mockResolvedValue({
138
+ data: { ok: true, access_token: "ya29.sync", token_type: "Bearer" },
139
+ });
140
+ const client = createClient();
141
+ const result = await client.connections.sync("conn_1");
142
+ expect(result.access_token).toBe("ya29.sync");
143
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({ method: "GET", url: "/connections/conn_1/token" }));
144
+ });
145
+ it("parses API error responses", async () => {
146
+ mockAxiosInstance.mockRejectedValue({
147
+ response: {
148
+ status: 400,
149
+ data: { ok: false, error: "Invalid or expired exchange code", code: "OAUTH_EXCHANGE_CODE_INVALID" },
150
+ },
151
+ });
152
+ const client = createClient();
153
+ await expect(client.exchange({ code: "bad", connection_id: "conn_1" })).rejects.toMatchObject({
154
+ message: "Invalid or expired exchange code",
155
+ status: 400,
156
+ code: "OAUTH_EXCHANGE_CODE_INVALID",
157
+ });
158
+ });
159
+ it("parses API error responses with nested error object", async () => {
160
+ mockAxiosInstance.mockRejectedValue({
161
+ response: {
162
+ status: 422,
163
+ data: {
164
+ message: "No refresh token available for this connection",
165
+ status: false,
166
+ statusCode: 422,
167
+ data: null,
168
+ error: { statusCode: 422, code: "OAUTH_PROVIDER_ERROR" },
169
+ },
170
+ },
171
+ });
172
+ const client = createClient();
173
+ await expect(client.connections.getToken("conn_1")).rejects.toMatchObject({
174
+ message: "No refresh token available for this connection",
175
+ status: 422,
176
+ code: "OAUTH_PROVIDER_ERROR",
177
+ });
178
+ });
179
+ it("starts SAML connect and builds POST form fields", async () => {
180
+ mockAxiosInstance.mockResolvedValue({
181
+ data: {
182
+ ok: true,
183
+ protocol: "saml",
184
+ authorization_url: "https://idp.example.com/sso",
185
+ sso_binding: "post",
186
+ saml_request: "PHNhbWxwOlJlcXVlc3Q...",
187
+ relay_state: "relay-123",
188
+ },
189
+ });
190
+ const client = createClient();
191
+ const result = await client.connect.start({
192
+ provider: "google-sso",
193
+ redirect_uri: "https://app.example.com/callback",
194
+ });
195
+ expect(result.protocol).toBe("saml");
196
+ expect(client.connect.isSamlPostBinding(result)).toBe(true);
197
+ expect(client.connect.buildSamlPostForm(result)).toEqual({
198
+ action: "https://idp.example.com/sso",
199
+ samlRequest: "PHNhbWxwOlJlcXVlc3Q...",
200
+ relayState: "relay-123",
201
+ });
202
+ });
203
+ it("returns SAML session fields from exchange", async () => {
204
+ mockAxiosInstance.mockResolvedValue({
205
+ data: {
206
+ ok: true,
207
+ protocol: "saml",
208
+ connection: {
209
+ id: "conn_saml",
210
+ provider: "google-sso",
211
+ protocol: "saml",
212
+ status: "active",
213
+ },
214
+ name_id: "user@example.com",
215
+ saml_attributes: { email: "user@example.com", role: "admin" },
216
+ },
217
+ });
218
+ const client = createClient();
219
+ const result = await client.exchange({ code: "ex_code", connection_id: "conn_saml" });
220
+ expect(result.protocol).toBe("saml");
221
+ expect(result.name_id).toBe("user@example.com");
222
+ expect(result.saml_attributes).toEqual({ email: "user@example.com", role: "admin" });
223
+ });
224
+ it("creates axios client with /oauth base URL", () => {
225
+ createClient({ baseUrl: "https://api.example.com/" });
226
+ expect(mockedAxios.create).toHaveBeenCalledWith(expect.objectContaining({
227
+ baseURL: "https://api.example.com/oauth",
228
+ }));
229
+ });
230
+ it("starts immediate client_credentials connect", async () => {
231
+ mockAxiosInstance.mockResolvedValue({
232
+ data: {
233
+ ok: true,
234
+ protocol: "oauth2",
235
+ grant_type: "client_credentials",
236
+ exchange_code: "ex_immediate",
237
+ connection_id: "conn_immediate",
238
+ redirect_url: "https://app.example.com/callback?code=ex_immediate&connection_id=conn_immediate",
239
+ },
240
+ });
241
+ const client = createClient();
242
+ const result = await client.connect.start({
243
+ provider: "m2m",
244
+ redirect_uri: "https://app.example.com/callback",
245
+ });
246
+ expect(result.exchange_code).toBe("ex_immediate");
247
+ expect(result.connection_id).toBe("conn_immediate");
248
+ });
249
+ it("polls device connect until complete", async () => {
250
+ mockAxiosInstance
251
+ .mockRejectedValueOnce({
252
+ response: {
253
+ status: 428,
254
+ data: { ok: false, error: "authorization_pending", code: "OAUTH_PROVIDER_ERROR" },
255
+ },
256
+ })
257
+ .mockResolvedValueOnce({
258
+ data: {
259
+ ok: true,
260
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
261
+ exchange_code: "ex_device",
262
+ connection_id: "conn_device",
263
+ },
264
+ });
265
+ const client = createClient();
266
+ const result = await client.connect.poll({
267
+ provider: "tv-app",
268
+ poll_state: "poll-state-1",
269
+ pollIntervalMs: 1,
270
+ });
271
+ expect(result.exchange_code).toBe("ex_device");
272
+ expect(mockAxiosInstance).toHaveBeenCalledTimes(2);
273
+ expect(mockAxiosInstance).toHaveBeenLastCalledWith(expect.objectContaining({
274
+ method: "POST",
275
+ url: "/apps/oauth_app_test/connect/poll",
276
+ data: { provider: "tv-app", poll_state: "poll-state-1" },
277
+ }));
278
+ });
279
+ it("passes assertion grants on connect start", async () => {
280
+ mockAxiosInstance.mockResolvedValue({
281
+ data: {
282
+ ok: true,
283
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
284
+ exchange_code: "ex_jwt",
285
+ connection_id: "conn_jwt",
286
+ },
287
+ });
288
+ const client = createClient();
289
+ await client.connect.start({
290
+ provider: "m2m-api",
291
+ redirect_uri: "https://app.example.com/callback",
292
+ assertion: "eyJ.assertion",
293
+ });
294
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
295
+ data: expect.objectContaining({
296
+ assertion: "eyJ.assertion",
297
+ }),
298
+ }));
299
+ });
300
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ProviderServicesClient.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderServicesClient.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ProviderServicesClient.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,131 @@
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
+ const axios_1 = __importDefault(require("axios"));
7
+ const ProviderServicesClient_1 = require("../ProviderServicesClient");
8
+ const cliodot_result_1 = require("../http/cliodot-result");
9
+ jest.mock("axios");
10
+ const mockedAxios = axios_1.default;
11
+ describe("ProviderServicesClient structured errors", () => {
12
+ it("returns config error without throwing when baseUrl is missing", async () => {
13
+ const client = new ProviderServicesClient_1.ProviderServicesClient({
14
+ baseUrl: "",
15
+ appId: "psv_app_test",
16
+ apiKey: "pak_test",
17
+ });
18
+ const result = await client.catalog();
19
+ expect((0, cliodot_result_1.isCliodotFail)(result)).toBe(true);
20
+ if ((0, cliodot_result_1.isCliodotFail)(result)) {
21
+ expect(result.error.code).toBe("SDK_CONFIG_INVALID");
22
+ }
23
+ });
24
+ it("returns validation error without throwing for missing service", async () => {
25
+ const client = new ProviderServicesClient_1.ProviderServicesClient({
26
+ baseUrl: "https://example.com",
27
+ appId: "psv_app_test",
28
+ apiKey: "pak_test",
29
+ });
30
+ const result = await client.execute({
31
+ service: "",
32
+ operation: "charge",
33
+ input: {},
34
+ });
35
+ expect((0, cliodot_result_1.isCliodotFail)(result)).toBe(true);
36
+ if ((0, cliodot_result_1.isCliodotFail)(result)) {
37
+ expect(result.error.code).toBe("SDK_VALIDATION");
38
+ }
39
+ });
40
+ it("returns validation error for invalid fluent path", async () => {
41
+ const client = new ProviderServicesClient_1.ProviderServicesClient({
42
+ baseUrl: "https://example.com",
43
+ appId: "psv_app_test",
44
+ apiKey: "pak_test",
45
+ });
46
+ const result = await client.api.payment();
47
+ expect((0, cliodot_result_1.isCliodotFail)(result)).toBe(true);
48
+ });
49
+ });
50
+ describe("ProviderServicesClient execute wire payload", () => {
51
+ const mockAxiosInstance = jest.fn();
52
+ beforeEach(() => {
53
+ jest.clearAllMocks();
54
+ mockedAxios.create.mockReturnValue(mockAxiosInstance);
55
+ });
56
+ function createClient() {
57
+ return new ProviderServicesClient_1.ProviderServicesClient({
58
+ baseUrl: "https://api.example.com",
59
+ appId: "psv_app_test",
60
+ apiKey: "pak_test",
61
+ });
62
+ }
63
+ function mockExecuteSuccess() {
64
+ mockAxiosInstance.mockResolvedValue({
65
+ status: 200,
66
+ data: {
67
+ ok: true,
68
+ service: "payments",
69
+ operation: "charge",
70
+ version: "v1",
71
+ provider: "paystack",
72
+ attempts: [{ provider: "paystack", ok: true }],
73
+ result: { status: "success" },
74
+ },
75
+ });
76
+ }
77
+ it("forwards provider on execute()", async () => {
78
+ mockExecuteSuccess();
79
+ const client = createClient();
80
+ const result = await client.execute({
81
+ service: "payments",
82
+ operation: "charge",
83
+ input: { amount: 1000, currency: "NGN" },
84
+ provider: "paystack",
85
+ });
86
+ expect(result.ok).toBe(true);
87
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
88
+ method: "POST",
89
+ url: "/v1/execute",
90
+ data: {
91
+ service: "payments",
92
+ operation: "charge",
93
+ input: { amount: 1000, currency: "NGN" },
94
+ provider: "paystack",
95
+ },
96
+ }));
97
+ });
98
+ it("forwards provider from fluent api opts", async () => {
99
+ mockExecuteSuccess();
100
+ const client = createClient();
101
+ const result = await client.api.payments.charge({ amount: 1000, currency: "NGN" }, { provider: "dojah", version: "v1" });
102
+ expect(result.ok).toBe(true);
103
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
104
+ method: "POST",
105
+ url: "/v1/execute",
106
+ data: {
107
+ service: "payments",
108
+ operation: "charge",
109
+ input: { amount: 1000, currency: "NGN" },
110
+ version: "v1",
111
+ provider: "dojah",
112
+ },
113
+ }));
114
+ });
115
+ it("forwards idempotency_key on execute()", async () => {
116
+ mockExecuteSuccess();
117
+ const client = createClient();
118
+ const result = await client.execute({
119
+ service: "payments",
120
+ operation: "charge",
121
+ input: { amount: 1000 },
122
+ idempotency_key: "idem-abc-123",
123
+ });
124
+ expect(result.ok).toBe(true);
125
+ expect(mockAxiosInstance).toHaveBeenCalledWith(expect.objectContaining({
126
+ data: expect.objectContaining({
127
+ idempotency_key: "idem-abc-123",
128
+ }),
129
+ }));
130
+ });
131
+ });
@@ -1 +1,150 @@
1
- 'use strict';const _0x5aba04=_0x4122;(function(_0x3d4003,_0x239ee7){const _0x11fe5c=_0x4122,_0x2da387=_0x3d4003();while(!![]){try{const _0x30db8c=-parseInt(_0x11fe5c(0xf0))/0x1+parseInt(_0x11fe5c(0xd7))/0x2+parseInt(_0x11fe5c(0xc8))/0x3+-parseInt(_0x11fe5c(0xed))/0x4+-parseInt(_0x11fe5c(0xcb))/0x5+parseInt(_0x11fe5c(0xf5))/0x6+parseInt(_0x11fe5c(0xe6))/0x7;if(_0x30db8c===_0x239ee7)break;else _0x2da387['push'](_0x2da387['shift']());}catch(_0x1d5eb6){_0x2da387['push'](_0x2da387['shift']());}}}(_0x275c,0xa1711));var __importDefault=this&&this[_0x5aba04(0xef)]||function(_0xdacc02){const _0x189e87=_0x5aba04;return _0xdacc02&&_0xdacc02[_0x189e87(0xcd)]?_0xdacc02:{'default':_0xdacc02};};function _0x4122(_0x461514,_0x36fb85){_0x461514=_0x461514-0xbc;const _0x275c64=_0x275c();let _0x4122aa=_0x275c64[_0x461514];if(_0x4122['JgMpNu']===undefined){var _0x404904=function(_0x4a5d66){const _0x5c991f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xdacc02='',_0x472e2f='';for(let _0x144fcb=0x0,_0x8b96fb,_0x27c327,_0x27e3d9=0x0;_0x27c327=_0x4a5d66['charAt'](_0x27e3d9++);~_0x27c327&&(_0x8b96fb=_0x144fcb%0x4?_0x8b96fb*0x40+_0x27c327:_0x27c327,_0x144fcb++%0x4)?_0xdacc02+=String['fromCharCode'](0xff&_0x8b96fb>>(-0x2*_0x144fcb&0x6)):0x0){_0x27c327=_0x5c991f['indexOf'](_0x27c327);}for(let _0x18d805=0x0,_0x4b095e=_0xdacc02['length'];_0x18d805<_0x4b095e;_0x18d805++){_0x472e2f+='%'+('00'+_0xdacc02['charCodeAt'](_0x18d805)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x472e2f);};_0x4122['GHazuv']=_0x404904,_0x4122['giPcyW']={},_0x4122['JgMpNu']=!![];}const _0x497101=_0x275c64[0x0],_0x33d400=_0x461514+_0x497101,_0xfe313=_0x4122['giPcyW'][_0x33d400];return!_0xfe313?(_0x4122aa=_0x4122['GHazuv'](_0x4122aa),_0x4122['giPcyW'][_0x33d400]=_0x4122aa):_0x4122aa=_0xfe313,_0x4122aa;}Object[_0x5aba04(0xe3)](exports,_0x5aba04(0xcd),{'value':!![]});function _0x275c(){const _0x4c517b=['A2v5x3rLC3q','B2jQzwn0','y29UC3rYDwn0CYbHihr5CgvKigzSDwvUDcbJBgLLBNq','DgHYB3DZihDOzw4GB3aGAxmGBM90igv4Cg9Zzwq','y2fYzhm','r0vu','mJmZndiYogXmshzHqG','B2jQzwn0q29UDgfPBMLUzW','yw55','nZK5ntiWzwnADe9c','y3vZDg9TzxjZ','x19LC01VzhvSzq','Dg9iyxzLqMvLBKnHBgXLzfDPDgG','z2v0','Ahr0Chm6lY9HCgKUzxHHBxbSzs5JB20VywnTzs9ZzgSVC3vYzMfJzq','CMvXDwvZDa','CMvQzwn0CW','Agv4','BNvTyMvY','C2rR','l3vZzxjZ','mti0nJi2v2HWA0jM','DgHYB3DZignHDgnOywjSzsbdBgLVzg90qxbPrxjYB3iGzNjVBsbPBNzVA2uGD2L0Ag91DcbIywnRz3jVDw5KihbYzwzLDgnO','u0rlig9WzxjHDgLVBIbUB3qGzxHWB3nLzdOGDxnLCNmUywnJB3vUDa','AgvHzgvYCW','Dg9fCxvHBa','zgvMyxvSDa','y3jLyxrLsgfZAa','y3vZDg9TzxjZlMnHCMrZlMXPC3q','y3jLyxrL','u3vYzMfJzq','l2n1C3rVBwvYCY97Awr9l2nHCMrZ','Dg9uAhjVDW','zgvMAw5LuhjVCgvYDhK','zgLNzxn0','Bw9JA1jLDhvYBLzHBhvL','mJm0ndy3ogrlruzKzW','Ahr0Chm6lY9HCgKUzxHHBxbSzs5JB20VywnTzs9JDxn0B21LCNmVy3vZDf8Xl2nHCMrZ','lI4Vu3vYzMfJzq','qvbjigTLEsbYzxf1AxjLza','y3vZDf8X','C3rYAw5NAwz5','yxHPB3m','otaWnZa4sfDewMHS','Dg9czq','x19PBxbVCNrezwzHDwX0','nZa5otG4sefcq2P2','ywnTzq','DxrMoa','Bw9JAW','yubIlMnVBq','mZq4ntK0nKTfr2PPCG','Bw9JA1jLC29SDMvKvMfSDwu','wc1dBgLVzg90lvnesY1tAwDUyxr1CMu','wc1dBgLVzg90lunSAwvUDa','BgLZDa','Dg9nyxrJAe9IAMvJDa','DxnLCNm','BwfWCYbWyxrOihbHCMfTCYbMB3iGBMvZDgvKig9WCW','y2fSBhm','Bg9HzhmGC3vYzMfJzsbHBMqGAw52B2TLCYbMBhvLBNqGB3aGD2L0AcbHDhrLC3rHDgLVBIbOzwfKzxjZ','ue9tva','lI4VzxjYB3jZ','q2XPB2rVDefWAuvYCM9Y'];_0x275c=function(){return _0x4c517b;};return _0x275c();}const axios_1=__importDefault(require(_0x5aba04(0xec))),crypto_1=__importDefault(require('crypto')),Surface_1=require(_0x5aba04(0xe8)),errors_1=require(_0x5aba04(0xc0));jest[_0x5aba04(0xf3)](_0x5aba04(0xec));const mockedAxios=axios_1[_0x5aba04(0xdc)];function sha256Hex(value){const _0x1fdf64=_0x5aba04;return crypto_1[_0x1fdf64(0xdc)][_0x1fdf64(0xdd)]('sha256')['update'](value,_0x1fdf64(0xf2))[_0x1fdf64(0xe4)](_0x1fdf64(0xd3));}describe('Surface',()=>{const _0x12b197=_0x5aba04,_0x472e2f={'get':jest['fn'](),'request':jest['fn']()};beforeEach(()=>{const _0x152146=_0x4122;jest['clearAllMocks'](),mockedAxios['create'][_0x152146(0xe5)](_0x472e2f);});function _0x144fcb(){const _0x15789b=_0x4122;return new Surface_1[(_0x15789b(0xe0))]({'baseUrl':'https://api.example.com','slug':_0x15789b(0xf1),'apiKey':_0x15789b(0xc2),'fetchSurface':![]});}it('requires\x20baseUrl',()=>{const _0x5debee=_0x4122;expect(()=>new Surface_1[(_0x5debee(0xe0))]({'baseUrl':''}))[_0x5debee(0xe2)](errors_1[_0x5debee(0xc1)]);}),it(_0x12b197(0xc4),()=>{const _0x61b955=_0x12b197,_0x8b96fb=new Surface_1['Surface']({'baseUrl':'https://api.example.com','slug':'acme','apiKey':'key_test','fetchSurface':![]});expect(typeof _0x8b96fb[_0x61b955(0xfb)]['list'])[_0x61b955(0xee)]('function');}),it(_0x12b197(0xbe),async()=>{const _0x4d873b=_0x12b197;_0x472e2f[_0x4d873b(0xcf)][_0x4d873b(0xf6)]({'status':0xc8,'data':{'ok':!![],'surface':{'version':0x1,'gateway':{'slug':'acme','sdk_enabled':!![]},'ops':[{'id':'users.create','sdk_path':[_0x4d873b(0xfb)],'op':'create','method':_0x4d873b(0xbf),'endpoint_path':_0x4d873b(0xd6),'path_params':[],'query_schema':null,'body':!![]}]}}}),_0x472e2f[_0x4d873b(0xd1)][_0x4d873b(0xf6)]({'status':0xc8,'data':{'ok':!![],'data':{'id':'u1'}}});const _0x27c327=_0x144fcb(),_0x27e3d9=await _0x27c327['users'][_0x4d873b(0xdf)]({'email':_0x4d873b(0xf4)});expect(_0x27e3d9)[_0x4d873b(0xdb)]({'id':'u1'}),expect(_0x472e2f[_0x4d873b(0xcf)])[_0x4d873b(0xce)](_0x4d873b(0xd0),expect['objectContaining']({'headers':expect[_0x4d873b(0xc9)]({'X-Cliodot-Client':_0x4d873b(0xd5),'X-API-Key':_0x4d873b(0xc2),'X-Cliodot-SDK-Signature':expect[_0x4d873b(0xca)](String)})}));const _0x18d805=_0x472e2f[_0x4d873b(0xd1)][_0x4d873b(0xf3)][_0x4d873b(0xbd)][0x0][0x0][_0x4d873b(0xda)];expect(_0x18d805[_0x4d873b(0xf8)])[_0x4d873b(0xee)](_0x4d873b(0xd5)),expect(_0x18d805[_0x4d873b(0xf7)])['toEqual'](expect[_0x4d873b(0xca)](String));const _0x4b095e=sha256Hex(JSON[_0x4d873b(0xeb)]({'email':_0x4d873b(0xf4)}));expect(_0x4b095e)['toHaveLength'](0x40);}),it(_0x12b197(0xd8),async()=>{const _0x414847=_0x12b197;_0x472e2f['get']['mockResolvedValue']({'status':0x191,'data':{'ok':![],'error':_0x414847(0xe9)}});const _0x1dda9c=_0x144fcb();await expect(_0x1dda9c[_0x414847(0xfb)][_0x414847(0xdf)]({'email':_0x414847(0xf4)}))[_0x414847(0xd2)][_0x414847(0xfa)]({'name':_0x414847(0xc1),'message':_0x414847(0xe9),'status':0x191,'code':'SURFACE_LOAD_FAILED'});}),it(_0x12b197(0xc5),async()=>{const _0xece042=_0x12b197;_0x472e2f[_0xece042(0xcf)][_0xece042(0xf6)]({'status':0xc8,'data':{'ok':!![],'surface':{'version':0x1,'gateway':{'slug':_0xece042(0xf1),'sdk_enabled':!![]},'ops':[]}}});const _0x593949=_0x144fcb();await expect(_0x593949[_0xece042(0xfb)]['account']())[_0xece042(0xd2)][_0xece042(0xe2)](_0xece042(0xd9));}),it(_0x12b197(0xbc),async()=>{const _0x1734c4=_0x12b197;_0x472e2f[_0x1734c4(0xcf)][_0x1734c4(0xf6)]({'status':0xc8,'data':{'ok':!![],'surface':{'version':0x1,'gateway':{'slug':_0x1734c4(0xf1),'sdk_enabled':!![]},'ops':[{'id':_0x1734c4(0xde),'sdk_path':[_0x1734c4(0xcc),_0x1734c4(0xc6)],'op':_0x1734c4(0xf9),'method':'GET','endpoint_path':_0x1734c4(0xe1),'path_params':['id'],'query_schema':{'type':_0x1734c4(0xc3),'properties':{'limit':{'type':_0x1734c4(0xd4)}}},'body':![]}]}}}),_0x472e2f['request'][_0x1734c4(0xf6)]({'status':0xc8,'data':{'ok':!![],'data':[]}});const _0x5a00f3=_0x144fcb();await _0x5a00f3['customers']['cards'][_0x1734c4(0xf9)](_0x1734c4(0xea),{'limit':0x2}),expect(_0x472e2f['request'])[_0x1734c4(0xce)](expect[_0x1734c4(0xc9)]({'url':_0x1734c4(0xe7),'method':_0x1734c4(0xc7),'params':{'limit':0x2}}));});});
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
+ const axios_1 = __importDefault(require("axios"));
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const Surface_1 = require("../Surface");
9
+ const errors_1 = require("../errors");
10
+ jest.mock("axios");
11
+ const mockedAxios = axios_1.default;
12
+ function sha256Hex(value) {
13
+ return crypto_1.default.createHash("sha256").update(value, "utf8").digest("hex");
14
+ }
15
+ describe("Surface", () => {
16
+ const mockAxiosInstance = {
17
+ get: jest.fn(),
18
+ request: jest.fn(),
19
+ };
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ mockedAxios.create.mockReturnValue(mockAxiosInstance);
23
+ });
24
+ function createClient() {
25
+ return new Surface_1.Surface({
26
+ baseUrl: "https://api.example.com",
27
+ slug: "acme",
28
+ apiKey: "key_test",
29
+ fetchSurface: false,
30
+ });
31
+ }
32
+ it("requires baseUrl", () => {
33
+ expect(() => new Surface_1.Surface({ baseUrl: "" })).toThrow(errors_1.CliodotApiError);
34
+ });
35
+ it("constructs a typed fluent client", () => {
36
+ const api = new Surface_1.Surface({
37
+ baseUrl: "https://api.example.com",
38
+ slug: "acme",
39
+ apiKey: "key_test",
40
+ fetchSurface: false,
41
+ });
42
+ expect(typeof api.users.list).toBe("function");
43
+ });
44
+ it("loads surface and invokes fluent op with attestation headers", async () => {
45
+ mockAxiosInstance.get.mockResolvedValue({
46
+ status: 200,
47
+ data: {
48
+ ok: true,
49
+ surface: {
50
+ version: 1,
51
+ gateway: { slug: "acme", sdk_enabled: true },
52
+ ops: [
53
+ {
54
+ id: "users.create",
55
+ sdk_path: ["users"],
56
+ op: "create",
57
+ method: "POST",
58
+ endpoint_path: "/users",
59
+ path_params: [],
60
+ query_schema: null,
61
+ body: true,
62
+ },
63
+ ],
64
+ },
65
+ },
66
+ });
67
+ mockAxiosInstance.request.mockResolvedValue({
68
+ status: 200,
69
+ data: { ok: true, data: { id: "u1" } },
70
+ });
71
+ const api = createClient();
72
+ const result = await api.users.create({ email: "a@b.com" });
73
+ expect(result).toEqual({ id: "u1" });
74
+ expect(mockAxiosInstance.get).toHaveBeenCalledWith("https://api.example.com/acme/sdk/surface", expect.objectContaining({
75
+ headers: expect.objectContaining({
76
+ "X-Cliodot-Client": "sdk",
77
+ "X-API-Key": "key_test",
78
+ "X-Cliodot-SDK-Signature": expect.any(String),
79
+ }),
80
+ }));
81
+ const invokeHeaders = mockAxiosInstance.request.mock.calls[0][0].headers;
82
+ expect(invokeHeaders["X-Cliodot-Client"]).toBe("sdk");
83
+ expect(invokeHeaders["X-Cliodot-SDK-Signature"]).toEqual(expect.any(String));
84
+ const bodyHash = sha256Hex(JSON.stringify({ email: "a@b.com" }));
85
+ expect(bodyHash).toHaveLength(64);
86
+ });
87
+ it("throws catchable CliodotApiError from invoke without background prefetch", async () => {
88
+ mockAxiosInstance.get.mockResolvedValue({
89
+ status: 401,
90
+ data: { ok: false, error: "API key required" },
91
+ });
92
+ const api = createClient();
93
+ await expect(api.users.create({ email: "a@b.com" })).rejects.toMatchObject({
94
+ name: "CliodotApiError",
95
+ message: "API key required",
96
+ status: 401,
97
+ code: "SURFACE_LOAD_FAILED",
98
+ });
99
+ });
100
+ it("throws when op is not exposed", async () => {
101
+ mockAxiosInstance.get.mockResolvedValue({
102
+ status: 200,
103
+ data: {
104
+ ok: true,
105
+ surface: {
106
+ version: 1,
107
+ gateway: { slug: "acme", sdk_enabled: true },
108
+ ops: [],
109
+ },
110
+ },
111
+ });
112
+ const api = createClient();
113
+ await expect(api.users.account()).rejects.toThrow("SDK operation not exposed: users.account");
114
+ });
115
+ it("maps path params for nested ops", async () => {
116
+ mockAxiosInstance.get.mockResolvedValue({
117
+ status: 200,
118
+ data: {
119
+ ok: true,
120
+ surface: {
121
+ version: 1,
122
+ gateway: { slug: "acme", sdk_enabled: true },
123
+ ops: [
124
+ {
125
+ id: "customers.cards.list",
126
+ sdk_path: ["customers", "cards"],
127
+ op: "list",
128
+ method: "GET",
129
+ endpoint_path: "/customers/{id}/cards",
130
+ path_params: ["id"],
131
+ query_schema: { type: "object", properties: { limit: { type: "number" } } },
132
+ body: false,
133
+ },
134
+ ],
135
+ },
136
+ },
137
+ });
138
+ mockAxiosInstance.request.mockResolvedValue({
139
+ status: 200,
140
+ data: { ok: true, data: [] },
141
+ });
142
+ const api = createClient();
143
+ await api.customers.cards.list("cust_1", { limit: 2 });
144
+ expect(mockAxiosInstance.request).toHaveBeenCalledWith(expect.objectContaining({
145
+ url: "https://api.example.com/acme/customers/cust_1/cards",
146
+ method: "GET",
147
+ params: { limit: 2 },
148
+ }));
149
+ });
150
+ });