@sasjs/adapter 4.19.3 → 5.1.0

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 (419) hide show
  1. package/ContextManager.js +290 -0
  2. package/DISCLOSURE +45 -0
  3. package/README.md +1 -1
  4. package/SAS9ApiClient.d.ts +1 -1
  5. package/SAS9ApiClient.js +90 -0
  6. package/SASViyaApiClient.js +918 -0
  7. package/SASjs.js +794 -0
  8. package/SASjsApiClient.d.ts +1 -0
  9. package/SASjsApiClient.js +132 -0
  10. package/SessionManager.js +353 -0
  11. package/api/viya/executeOnComputeApi.js +198 -0
  12. package/api/viya/getFileStream.js +32 -0
  13. package/api/viya/pollJobState.js +247 -0
  14. package/api/viya/saveLog.js +45 -0
  15. package/api/viya/uploadTables.js +45 -0
  16. package/api/viya/writeStream.js +25 -0
  17. package/auth/AuthManager.js +305 -0
  18. package/auth/getAccessTokenForSasjs.js +43 -0
  19. package/auth/getAccessTokenForViya.js +54 -0
  20. package/auth/getTokenRequestErrorPrefix.js +70 -0
  21. package/auth/getTokens.js +110 -0
  22. package/auth/index.js +20 -0
  23. package/auth/isAuthorizeFormRequired.js +7 -0
  24. package/auth/isLoginRequired.js +9 -0
  25. package/auth/loginHeader.js +87 -0
  26. package/auth/openWebPage.js +31 -0
  27. package/auth/refreshTokensForSasjs.js +42 -0
  28. package/auth/refreshTokensForViya.js +53 -0
  29. package/auth/verifySas9Login.js +32 -0
  30. package/auth/verifySasViyaLogin.js +44 -0
  31. package/dist/minified_sas9.js +10892 -0
  32. package/dist/sasjs-adapter.js +19569 -0
  33. package/file/generateFileUploadForm.js +43 -0
  34. package/file/generateTableUploadForm.js +38 -0
  35. package/index.js +9 -80376
  36. package/job-execution/ComputeJobExecutor.js +55 -0
  37. package/job-execution/FileUploader.js +114 -0
  38. package/job-execution/JesJobExecutor.js +55 -0
  39. package/job-execution/JobExecutor.js +40 -0
  40. package/job-execution/Sas9JobExecutor.d.ts +1 -1
  41. package/job-execution/Sas9JobExecutor.js +115 -0
  42. package/job-execution/SasjsJobExecutor.js +100 -0
  43. package/job-execution/WebJobExecutor.js +254 -0
  44. package/job-execution/index.js +23 -0
  45. package/minified/sas9/SASjs.js +198 -0
  46. package/minified/sas9/WebJobExecutor.js +105 -0
  47. package/minified/sas9/index.js +22 -0
  48. package/node/index.d.ts +2 -9
  49. package/node/index.js +1 -30570
  50. package/package.json +41 -12
  51. package/request/RequestClient.d.ts +1 -1
  52. package/request/RequestClient.js +717 -0
  53. package/request/Sas9RequestClient.d.ts +1 -1
  54. package/request/Sas9RequestClient.js +121 -0
  55. package/request/SasjsRequestClient.js +77 -0
  56. package/types/Context.js +2 -0
  57. package/types/CsrfToken.js +2 -0
  58. package/types/ExecuteScript.js +2 -0
  59. package/types/File.js +2 -0
  60. package/types/FileResource.js +2 -0
  61. package/types/Folder.js +2 -0
  62. package/types/Job.js +2 -0
  63. package/types/JobDefinition.js +2 -0
  64. package/types/JobResult.js +2 -0
  65. package/types/Link.js +2 -0
  66. package/types/LogStatistics.js +2 -0
  67. package/types/Login.js +2 -0
  68. package/types/PollOptions.js +2 -0
  69. package/types/RequestClient.js +2 -0
  70. package/types/SASjsConfig.d.ts +1 -1
  71. package/types/SASjsConfig.js +91 -0
  72. package/types/Session.js +14 -0
  73. package/types/Tables.js +28 -0
  74. package/types/UploadFile.js +2 -0
  75. package/types/WriteStream.d.ts +1 -1
  76. package/types/WriteStream.js +2 -0
  77. package/types/errors/ArgumentError.js +12 -0
  78. package/types/errors/AuthorizeError.js +13 -0
  79. package/types/errors/CertificateError.js +12 -0
  80. package/types/errors/ComputeJobExecutionError.js +13 -0
  81. package/types/errors/ErrorResponse.js +23 -0
  82. package/types/errors/InternalServerError.js +11 -0
  83. package/types/errors/InvalidJsonError.js +11 -0
  84. package/types/errors/InvalidSASjsCsrfError.js +12 -0
  85. package/types/errors/JobExecutionError.js +14 -0
  86. package/types/errors/JobStatePollError.js +12 -0
  87. package/types/errors/JsonParseArrayError.js +11 -0
  88. package/types/errors/LoginRequiredError.js +14 -0
  89. package/types/errors/NoSessionStateError.js +14 -0
  90. package/types/errors/NotFoundError.js +12 -0
  91. package/types/errors/RootFolderNotFoundError.js +22 -0
  92. package/types/errors/SAS9AuthError.js +11 -0
  93. package/types/errors/WeboutResponseError.js +12 -0
  94. package/types/errors/index.js +31 -0
  95. package/types/index.js +34 -0
  96. package/utils/appendExtraResponseAttributes.js +25 -0
  97. package/utils/asyncForEach.js +20 -0
  98. package/utils/compareTimestamps.js +11 -0
  99. package/utils/convertToCsv.js +154 -0
  100. package/utils/createAxiosInstance.d.ts +1 -1
  101. package/utils/createAxiosInstance.js +9 -0
  102. package/utils/delay.js +5 -0
  103. package/{src/utils/extractWeboutBlob.ts → utils/extractWeboutBlob.js} +19 -20
  104. package/utils/fetchLogByChunks.js +56 -0
  105. package/utils/formatDataForRequest.js +39 -0
  106. package/utils/getFormData.js +10 -0
  107. package/{node/utils/getUserLanguage.d.ts → utils/getUserLanguage.js} +5 -1
  108. package/utils/getValidJson.js +27 -0
  109. package/utils/host.d.ts +24 -0
  110. package/utils/host.js +36 -0
  111. package/utils/index.js +41 -0
  112. package/utils/isIeOrEdge.js +30 -0
  113. package/utils/isNode.js +7 -0
  114. package/utils/isRelativePath.js +5 -0
  115. package/utils/isUri.js +9 -0
  116. package/utils/isUrl.js +20 -0
  117. package/utils/loginPrompt/index.js +180 -0
  118. package/utils/needsRetry.js +14 -0
  119. package/utils/parseGeneratedCode.js +10 -0
  120. package/utils/parseSasViyaLog.js +17 -0
  121. package/utils/parseSourceCode.js +9 -0
  122. package/utils/parseViyaDebugResponse.js +46 -0
  123. package/utils/parseViyaLogDebugResponse.js +32 -0
  124. package/utils/parseWeboutResponse.js +22 -0
  125. package/utils/sas9/extractUserLongNameSas9.js +30 -0
  126. package/utils/serialize.js +20 -0
  127. package/utils/splitChunks.js +13 -0
  128. package/utils/validateInput.js +83 -0
  129. package/.env.example +0 -2
  130. package/.git-hooks/commit-msg +0 -39
  131. package/.git-hooks/pre-commit +0 -12
  132. package/.gitattributes +0 -1
  133. package/.pre-commit-config.yaml +0 -25
  134. package/.vscode/settings.json +0 -3
  135. package/SASViyaApiClient.spec.d.ts +0 -1
  136. package/__mocks__/axios.d.ts +0 -3
  137. package/api/viya/spec/executeScript.spec.d.ts +0 -1
  138. package/api/viya/spec/getFileStream.spec.d.ts +0 -1
  139. package/api/viya/spec/mockResponses.d.ts +0 -10
  140. package/api/viya/spec/pollJobState.spec.d.ts +0 -1
  141. package/api/viya/spec/saveLog.spec.d.ts +0 -1
  142. package/api/viya/spec/uploadTables.spec.d.ts +0 -1
  143. package/api/viya/spec/writeStream.spec.d.ts +0 -1
  144. package/auth/spec/AuthManager.spec.d.ts +0 -4
  145. package/auth/spec/getAccessTokenForSasjs.spec.d.ts +0 -1
  146. package/auth/spec/getAccessTokenForViya.spec.d.ts +0 -1
  147. package/auth/spec/getTokenRequestErrorPrefix.spec.d.ts +0 -1
  148. package/auth/spec/getTokens.spec.d.ts +0 -1
  149. package/auth/spec/loginHeader.spec.d.ts +0 -4
  150. package/auth/spec/mockResponses.d.ts +0 -23
  151. package/auth/spec/openWebPage.spec.d.ts +0 -1
  152. package/auth/spec/refreshTokensForSasjs.spec.d.ts +0 -1
  153. package/auth/spec/refreshTokensForViya.spec.d.ts +0 -1
  154. package/auth/spec/verifySas9Login.spec.d.ts +0 -1
  155. package/auth/spec/verifySasViyaLogin.spec.d.ts +0 -1
  156. package/checkNodeVersion.js +0 -16
  157. package/createTSDocs.js +0 -35
  158. package/cypress.config.js +0 -18
  159. package/example.html +0 -109
  160. package/file/spec/generateFileUploadForm.spec.d.ts +0 -1
  161. package/file/spec/generateTableUploadForm.spec.d.ts +0 -1
  162. package/index-dev.js +0 -80394
  163. package/job-execution/spec/ComputeJobExecutor.spec.d.ts +0 -1
  164. package/job-execution/spec/JesJobExecutor.spec.d.ts +0 -1
  165. package/job-execution/spec/Sas9JobExecutor.spec.d.ts +0 -1
  166. package/job-execution/spec/SasjsJobExecutor.spec.d.ts +0 -1
  167. package/job-execution/spec/WebJobExecutor.debug.spec.d.ts +0 -1
  168. package/job-execution/spec/WebJobExecutor.spec.d.ts +0 -1
  169. package/job-execution/spec/executionTasks.spec.d.ts +0 -1
  170. package/minified_sas9.js +0 -14039
  171. package/node/ContextManager.d.ts +0 -41
  172. package/node/SAS9ApiClient.d.ts +0 -30
  173. package/node/SASViyaApiClient.d.ts +0 -298
  174. package/node/SASjs.d.ts +0 -387
  175. package/node/SASjsApiClient.d.ts +0 -65
  176. package/node/SessionManager.d.ts +0 -115
  177. package/node/api/viya/executeOnComputeApi.d.ts +0 -21
  178. package/node/api/viya/getFileStream.d.ts +0 -2
  179. package/node/api/viya/pollJobState.d.ts +0 -57
  180. package/node/api/viya/saveLog.d.ts +0 -15
  181. package/node/api/viya/uploadTables.d.ts +0 -13
  182. package/node/api/viya/writeStream.d.ts +0 -2
  183. package/node/auth/AuthManager.d.ts +0 -49
  184. package/node/auth/getAccessTokenForSasjs.d.ts +0 -11
  185. package/node/auth/getAccessTokenForViya.d.ts +0 -10
  186. package/node/auth/getTokenRequestErrorPrefix.d.ts +0 -44
  187. package/node/auth/getTokens.d.ts +0 -22
  188. package/node/auth/index.d.ts +0 -4
  189. package/node/auth/isAuthorizeFormRequired.d.ts +0 -1
  190. package/node/auth/isLoginRequired.d.ts +0 -1
  191. package/node/auth/loginHeader.d.ts +0 -17
  192. package/node/auth/openWebPage.d.ts +0 -6
  193. package/node/auth/refreshTokensForSasjs.d.ts +0 -10
  194. package/node/auth/refreshTokensForViya.d.ts +0 -11
  195. package/node/auth/verifySas9Login.d.ts +0 -3
  196. package/node/auth/verifySasViyaLogin.d.ts +0 -4
  197. package/node/file/generateFileUploadForm.d.ts +0 -11
  198. package/node/file/generateTableUploadForm.d.ts +0 -5
  199. package/node/job-execution/ComputeJobExecutor.d.ts +0 -8
  200. package/node/job-execution/FileUploader.d.ts +0 -9
  201. package/node/job-execution/JesJobExecutor.d.ts +0 -9
  202. package/node/job-execution/JobExecutor.d.ts +0 -17
  203. package/node/job-execution/Sas9JobExecutor.d.ts +0 -19
  204. package/node/job-execution/SasjsJobExecutor.d.ts +0 -9
  205. package/node/job-execution/WebJobExecutor.d.ts +0 -18
  206. package/node/job-execution/index.d.ts +0 -7
  207. package/node/request/RequestClient.d.ts +0 -125
  208. package/node/request/Sas9RequestClient.d.ts +0 -25
  209. package/node/request/SasjsRequestClient.d.ts +0 -12
  210. package/node/types/Context.d.ts +0 -42
  211. package/node/types/CsrfToken.d.ts +0 -4
  212. package/node/types/ExecuteScript.d.ts +0 -4
  213. package/node/types/File.d.ts +0 -7
  214. package/node/types/FileResource.d.ts +0 -32
  215. package/node/types/Folder.d.ts +0 -7
  216. package/node/types/Job.d.ts +0 -14
  217. package/node/types/JobDefinition.d.ts +0 -3
  218. package/node/types/JobResult.d.ts +0 -3
  219. package/node/types/Link.d.ts +0 -7
  220. package/node/types/LogStatistics.d.ts +0 -4
  221. package/node/types/Login.d.ts +0 -14
  222. package/node/types/PollOptions.d.ts +0 -8
  223. package/node/types/RequestClient.d.ts +0 -46
  224. package/node/types/SASjsConfig.d.ts +0 -94
  225. package/node/types/Session.d.ts +0 -30
  226. package/node/types/Tables.d.ts +0 -7
  227. package/node/types/UploadFile.d.ts +0 -8
  228. package/node/types/WriteStream.d.ts +0 -7
  229. package/node/types/errors/ArgumentError.d.ts +0 -4
  230. package/node/types/errors/AuthorizeError.d.ts +0 -5
  231. package/node/types/errors/CertificateError.d.ts +0 -3
  232. package/node/types/errors/ComputeJobExecutionError.d.ts +0 -6
  233. package/node/types/errors/ErrorResponse.d.ts +0 -9
  234. package/node/types/errors/InternalServerError.d.ts +0 -3
  235. package/node/types/errors/InvalidJsonError.d.ts +0 -3
  236. package/node/types/errors/InvalidSASjsCsrfError.d.ts +0 -3
  237. package/node/types/errors/JobExecutionError.d.ts +0 -6
  238. package/node/types/errors/JobStatePollError.d.ts +0 -4
  239. package/node/types/errors/JsonParseArrayError.d.ts +0 -3
  240. package/node/types/errors/LoginRequiredError.d.ts +0 -3
  241. package/node/types/errors/NoSessionStateError.d.ts +0 -6
  242. package/node/types/errors/NotFoundError.d.ts +0 -4
  243. package/node/types/errors/RootFolderNotFoundError.d.ts +0 -3
  244. package/node/types/errors/SAS9AuthError.d.ts +0 -3
  245. package/node/types/errors/WeboutResponseError.d.ts +0 -4
  246. package/node/types/errors/index.d.ts +0 -15
  247. package/node/types/index.d.ts +0 -18
  248. package/node/utils/appendExtraResponseAttributes.d.ts +0 -2
  249. package/node/utils/asyncForEach.d.ts +0 -1
  250. package/node/utils/compareTimestamps.d.ts +0 -6
  251. package/node/utils/convertToCsv.d.ts +0 -12
  252. package/node/utils/createAxiosInstance.d.ts +0 -2
  253. package/node/utils/delay.d.ts +0 -1
  254. package/node/utils/extractWeboutBlob.d.ts +0 -13
  255. package/node/utils/fetchLogByChunks.d.ts +0 -20
  256. package/node/utils/formatDataForRequest.d.ts +0 -1
  257. package/node/utils/getFormData.d.ts +0 -2
  258. package/node/utils/getValidJson.d.ts +0 -5
  259. package/node/utils/index.d.ts +0 -25
  260. package/node/utils/isNode.d.ts +0 -1
  261. package/node/utils/isRelativePath.d.ts +0 -1
  262. package/node/utils/isUri.d.ts +0 -5
  263. package/node/utils/isUrl.d.ts +0 -5
  264. package/node/utils/loginPrompt/index.d.ts +0 -1
  265. package/node/utils/needsRetry.d.ts +0 -1
  266. package/node/utils/parseGeneratedCode.d.ts +0 -1
  267. package/node/utils/parseSasViyaLog.d.ts +0 -5
  268. package/node/utils/parseSourceCode.d.ts +0 -1
  269. package/node/utils/parseViyaDebugResponse.d.ts +0 -12
  270. package/node/utils/parseViyaLogDebugResponse.d.ts +0 -8
  271. package/node/utils/parseWeboutResponse.d.ts +0 -1
  272. package/node/utils/sas9/extractUserLongNameSas9.d.ts +0 -6
  273. package/node/utils/serialize.d.ts +0 -1
  274. package/node/utils/splitChunks.d.ts +0 -1
  275. package/node/utils/validateInput.d.ts +0 -14
  276. package/request/spec/SasjsRequestClient.spec.d.ts +0 -1
  277. package/screenshots/session-manager-first-request.png +0 -0
  278. package/screenshots/subsequent-session-request.png +0 -0
  279. package/spec/SAS9ApiClient.spec.d.ts +0 -1
  280. package/spec/SASjs.startComputeJob.spec.d.ts +0 -1
  281. package/spec/SASjsApiClient.spec.d.ts +0 -1
  282. package/src/ContextManager.ts +0 -454
  283. package/src/SAS9ApiClient.ts +0 -100
  284. package/src/SASViyaApiClient.ts +0 -1417
  285. package/src/SASjs.ts +0 -1268
  286. package/src/SASjsApiClient.ts +0 -177
  287. package/src/SessionManager.ts +0 -465
  288. package/src/__mocks__/axios.ts +0 -7
  289. package/src/api/viya/executeOnComputeApi.ts +0 -307
  290. package/src/api/viya/getFileStream.ts +0 -17
  291. package/src/api/viya/pollJobState.ts +0 -393
  292. package/src/api/viya/saveLog.ts +0 -55
  293. package/src/api/viya/spec/mockResponses.ts +0 -75
  294. package/src/api/viya/uploadTables.ts +0 -41
  295. package/src/api/viya/writeStream.ts +0 -16
  296. package/src/auth/AuthManager.ts +0 -387
  297. package/src/auth/getAccessTokenForSasjs.ts +0 -48
  298. package/src/auth/getAccessTokenForViya.ts +0 -61
  299. package/src/auth/getTokenRequestErrorPrefix.ts +0 -88
  300. package/src/auth/getTokens.ts +0 -127
  301. package/src/auth/index.ts +0 -4
  302. package/src/auth/isAuthorizeFormRequired.ts +0 -3
  303. package/src/auth/isLoginRequired.ts +0 -5
  304. package/src/auth/loginHeader.ts +0 -97
  305. package/src/auth/openWebPage.ts +0 -40
  306. package/src/auth/refreshTokensForSasjs.ts +0 -45
  307. package/src/auth/refreshTokensForViya.ts +0 -66
  308. package/src/auth/spec/mockResponses.ts +0 -53
  309. package/src/auth/verifySas9Login.ts +0 -25
  310. package/src/auth/verifySasViyaLogin.ts +0 -43
  311. package/src/file/generateFileUploadForm.ts +0 -48
  312. package/src/file/generateTableUploadForm.ts +0 -50
  313. package/src/index.ts +0 -9
  314. package/src/job-execution/ComputeJobExecutor.ts +0 -76
  315. package/src/job-execution/FileUploader.ts +0 -152
  316. package/src/job-execution/JesJobExecutor.ts +0 -78
  317. package/src/job-execution/JobExecutor.ts +0 -63
  318. package/src/job-execution/Sas9JobExecutor.ts +0 -137
  319. package/src/job-execution/SasjsJobExecutor.ts +0 -152
  320. package/src/job-execution/WebJobExecutor.ts +0 -341
  321. package/src/job-execution/index.ts +0 -7
  322. package/src/minified/sas9/SASjs.ts +0 -274
  323. package/src/minified/sas9/WebJobExecutor.ts +0 -156
  324. package/src/minified/sas9/index.ts +0 -3
  325. package/src/request/RequestClient.ts +0 -941
  326. package/src/request/Sas9RequestClient.ts +0 -132
  327. package/src/request/SasjsRequestClient.ts +0 -82
  328. package/src/test/SAS_server_app.ts +0 -47
  329. package/src/types/Context.ts +0 -39
  330. package/src/types/CsrfToken.ts +0 -4
  331. package/src/types/ExecuteScript.ts +0 -4
  332. package/src/types/File.ts +0 -8
  333. package/src/types/FileResource.ts +0 -33
  334. package/src/types/Folder.ts +0 -8
  335. package/src/types/Job.ts +0 -15
  336. package/src/types/JobDefinition.ts +0 -3
  337. package/src/types/JobResult.ts +0 -3
  338. package/src/types/Link.ts +0 -7
  339. package/src/types/LogStatistics.ts +0 -4
  340. package/src/types/Login.ts +0 -15
  341. package/src/types/PollOptions.ts +0 -9
  342. package/src/types/Process.d.ts +0 -5
  343. package/src/types/RequestClient.ts +0 -55
  344. package/src/types/SASjsConfig.ts +0 -95
  345. package/src/types/Session.ts +0 -34
  346. package/src/types/Tables.ts +0 -29
  347. package/src/types/UploadFile.ts +0 -8
  348. package/src/types/WriteStream.ts +0 -10
  349. package/src/types/errors/ArgumentError.ts +0 -7
  350. package/src/types/errors/AuthorizeError.ts +0 -10
  351. package/src/types/errors/CertificateError.ts +0 -12
  352. package/src/types/errors/ComputeJobExecutionError.ts +0 -12
  353. package/src/types/errors/ErrorResponse.ts +0 -28
  354. package/src/types/errors/InternalServerError.ts +0 -9
  355. package/src/types/errors/InvalidJsonError.ts +0 -7
  356. package/src/types/errors/InvalidSASjsCsrfError.ts +0 -9
  357. package/src/types/errors/JobExecutionError.ts +0 -11
  358. package/src/types/errors/JobStatePollError.ts +0 -14
  359. package/src/types/errors/JsonParseArrayError.ts +0 -7
  360. package/src/types/errors/LoginRequiredError.ts +0 -11
  361. package/src/types/errors/NoSessionStateError.ts +0 -15
  362. package/src/types/errors/NotFoundError.ts +0 -7
  363. package/src/types/errors/RootFolderNotFoundError.ts +0 -24
  364. package/src/types/errors/SAS9AuthError.ts +0 -9
  365. package/src/types/errors/WeboutResponseError.ts +0 -7
  366. package/src/types/errors/index.ts +0 -15
  367. package/src/types/index.ts +0 -18
  368. package/src/types/system/global.d.ts +0 -1
  369. package/src/utils/appendExtraResponseAttributes.ts +0 -22
  370. package/src/utils/asyncForEach.ts +0 -5
  371. package/src/utils/compareTimestamps.ts +0 -9
  372. package/src/utils/convertToCsv.ts +0 -198
  373. package/src/utils/createAxiosInstance.ts +0 -7
  374. package/src/utils/delay.ts +0 -2
  375. package/src/utils/fetchLogByChunks.ts +0 -63
  376. package/src/utils/formatDataForRequest.ts +0 -48
  377. package/src/utils/getFormData.ts +0 -5
  378. package/src/utils/getUserLanguage.ts +0 -10
  379. package/src/utils/getValidJson.ts +0 -23
  380. package/src/utils/index.ts +0 -25
  381. package/src/utils/isIeOrEdge.ts +0 -34
  382. package/src/utils/isNode.ts +0 -4
  383. package/src/utils/isRelativePath.ts +0 -2
  384. package/src/utils/isUri.ts +0 -5
  385. package/src/utils/isUrl.ts +0 -17
  386. package/src/utils/loginPrompt/index.ts +0 -177
  387. package/src/utils/needsRetry.ts +0 -14
  388. package/src/utils/parseGeneratedCode.ts +0 -7
  389. package/src/utils/parseSasViyaLog.ts +0 -12
  390. package/src/utils/parseSourceCode.ts +0 -6
  391. package/src/utils/parseViyaDebugResponse.ts +0 -46
  392. package/src/utils/parseViyaLogDebugResponse.ts +0 -22
  393. package/src/utils/parseWeboutResponse.ts +0 -20
  394. package/src/utils/sas9/extractUserLongNameSas9.ts +0 -31
  395. package/src/utils/serialize.ts +0 -15
  396. package/src/utils/splitChunks.ts +0 -12
  397. package/src/utils/validateInput.ts +0 -93
  398. package/test/ContextManager.spec.d.ts +0 -1
  399. package/test/FileUploader.spec.d.ts +0 -4
  400. package/test/FolderOperations.spec.d.ts +0 -1
  401. package/test/RequestClient.spec.d.ts +0 -1
  402. package/test/SAS_server_app.d.ts +0 -10
  403. package/test/SessionManager.spec.d.ts +0 -1
  404. package/test/getJobsInFolder.spec.d.ts +0 -1
  405. package/test/utils/formatDataForRequest.spec.d.ts +0 -1
  406. package/test/utils/getValidJson.spec.d.ts +0 -1
  407. package/test/utils/isUrl.spec.d.ts +0 -1
  408. package/test/utils/parseGeneratedCode.spec.d.ts +0 -1
  409. package/test/utils/parseSourceCode.spec.d.ts +0 -1
  410. package/types/Tables.spec.d.ts +0 -1
  411. package/types/errors/RootFolderNotFoundError.spec.d.ts +0 -1
  412. package/types/errors/spec/SAS9AuthError.spec.d.ts +0 -1
  413. package/utils/spec/convertToCsv.spec.d.ts +0 -1
  414. package/utils/spec/extractUserLongNameSas9.spec.d.ts +0 -1
  415. package/utils/spec/getFormData.spec.d.ts +0 -1
  416. package/utils/spec/parseSasViyaLog.spec.d.ts +0 -1
  417. package/utils/spec/parseViyaDebugResponse.spec.d.ts +0 -1
  418. package/utils/spec/parseViyaLogDebugResponse.spec.d.ts +0 -1
  419. package/utils/spec/validateInput.spec.d.ts +0 -1
@@ -1,88 +0,0 @@
1
- import { ServerType } from '@sasjs/utils/types'
2
-
3
- type Server = ServerType.SasViya | ServerType.Sasjs
4
- type Operation = 'fetching access token' | 'refreshing tokens'
5
-
6
- const getServerName = (server: Server) =>
7
- server === ServerType.SasViya ? 'Viya' : 'Sasjs'
8
-
9
- const getResponseTitle = (server: Server) =>
10
- `Response from ${getServerName(server)} is below.`
11
-
12
- /**
13
- * Forms error prefix for requests related to token operations.
14
- * @param operation - string describing operation ('fetching access token' or 'refreshing tokens').
15
- * @param funcName - name of the function sent the request.
16
- * @param server - server type (SASVIYA or SASJS).
17
- * @param url - endpoint used to send the request.
18
- * @param data - request payload.
19
- * @param headers - request headers.
20
- * @param clientId - client ID to authenticate with.
21
- * @param clientSecret - client secret to authenticate with.
22
- * @returns - string containing request information. Example:
23
- * Error while fetching access token from /SASLogon/oauth/token
24
- * Thrown by the @sasjs/adapter getAccessTokenForViya function.
25
- * Payload:
26
- * {
27
- * "grant_type": "authorization_code",
28
- * "code": "example_code"
29
- * }
30
- * Headers:
31
- * {
32
- * "Authorization": "Basic NEdMQXBwOjRHTEFwcDE=",
33
- * "Accept": "application/json"
34
- * }
35
- * ClientId: exampleClientId
36
- * ClientSecret: exampleClientSecret
37
- *
38
- * Response from Viya is below.
39
- * Auth error: {
40
- * "error": "invalid_token",
41
- * "error_description": "No scopes were granted"
42
- * }
43
- */
44
- export const getTokenRequestErrorPrefix = (
45
- operation: Operation,
46
- funcName: string,
47
- server: Server,
48
- url: string,
49
- data?: {},
50
- headers?: {},
51
- clientId?: string,
52
- clientSecret?: string
53
- ) => {
54
- const stringify = (obj: {}) => JSON.stringify(obj, null, 2)
55
-
56
- const lines = [
57
- `Error while ${operation} from ${url}`,
58
- `Thrown by the @sasjs/adapter ${funcName} function.`
59
- ]
60
-
61
- if (data) {
62
- lines.push('Payload:')
63
- lines.push(stringify(data))
64
- }
65
- if (headers) {
66
- lines.push('Headers:')
67
- lines.push(stringify(headers))
68
- }
69
- if (clientId) lines.push(`ClientId: ${clientId}`)
70
- if (clientSecret) lines.push(`ClientSecret: ${clientSecret}`)
71
-
72
- lines.push('')
73
- lines.push(`${getResponseTitle(server)}`)
74
- lines.push('')
75
-
76
- return lines.join(`\n`)
77
- }
78
-
79
- /**
80
- * Parse error prefix to get response payload.
81
- * @param prefix - error prefix generated by getTokenRequestErrorPrefix function.
82
- * @param server - server type (SASVIYA or SASJS).
83
- * @returns - response payload.
84
- */
85
- export const getTokenRequestErrorPrefixResponse = (
86
- prefix: string,
87
- server: ServerType.SasViya | ServerType.Sasjs
88
- ) => prefix.split(`${getResponseTitle(server)}\n`).pop() as string
@@ -1,127 +0,0 @@
1
- import {
2
- isAccessTokenExpiring,
3
- isRefreshTokenExpiring,
4
- hasTokenExpired
5
- } from '@sasjs/utils/auth'
6
- import { AuthConfig, ServerType } from '@sasjs/utils/types'
7
- import { RequestClient } from '../request/RequestClient'
8
- import { refreshTokensForViya } from './refreshTokensForViya'
9
- import { refreshTokensForSasjs } from './refreshTokensForSasjs'
10
-
11
- /**
12
- * Callback invoked with the rotated token pair after a successful internal
13
- * refresh. Viya refresh tokens are single-use/rotating, so consumers that
14
- * persist tokens (e.g. the CLI writing `.env.{target}`) should pass a handler
15
- * wherever this is accepted to avoid the persisted pair going stale.
16
- */
17
- export type OnTokensRefreshed = (tokens: {
18
- access_token: string
19
- refresh_token: string
20
- }) => void | Promise<void>
21
-
22
- /**
23
- * Returns the auth configuration, refreshing the tokens if necessary.
24
- * This function can only be used by Node, if a server type is SASVIYA.
25
- * @param requestClient - the pre-configured HTTP request client
26
- * @param authConfig - an object containing a client ID, secret, access token and refresh token
27
- * @param serverType - server type for which refreshing the tokens, defaults to SASVIYA
28
- * @param onTokensRefreshed - optional callback invoked with the rotated token
29
- * pair after a successful internal refresh.
30
- */
31
- export async function getTokens(
32
- requestClient: RequestClient,
33
- authConfig: AuthConfig,
34
- serverType: ServerType = ServerType.SasViya,
35
- onTokensRefreshed?: OnTokensRefreshed
36
- ): Promise<AuthConfig> {
37
- const logger = process.logger || console
38
- // Note: client/secret are NOT mutated. The sas.cli public-client fallback
39
- // is applied only to the refresh call itself, so a caller that round-trips
40
- // the returned AuthConfig into persistent storage never ends up saving
41
- // fabricated CLIENT/SECRET values.
42
- let { access_token, refresh_token } = authConfig
43
- const { client, secret } = authConfig
44
-
45
- // Tokens are not always decodable JWTs - some servers issue opaque tokens.
46
- // jwt-decode throws InvalidTokenError for these; only in that case is the
47
- // token treated as still valid (the server is the authority on expiry and
48
- // will reject a genuinely expired token on use/refresh).
49
- // Use a 300 s (5 min) safety margin instead of the isAccessTokenExpiring
50
- // default of 3600 s (1 h). Some Viya estates issue access tokens with a
51
- // 1-hour TTL; with the 3600 s default a brand-new 1 h token is immediately
52
- // considered "expiring", causing a redundant refresh even when the CLI has
53
- // already refreshed the token moments earlier. 300 s is short enough that a
54
- // fresh 1 h token (TTL ≈ 3600 ≫ 300) is NOT considered expiring, yet long
55
- // enough to let a single API call complete before the token actually expires.
56
- // Long-running jobs are protected because pollJobState calls getTokens on
57
- // every poll, so a token that does expire mid-job is refreshed in-place.
58
- let isAccessTokenExpiringSoon = false
59
- try {
60
- isAccessTokenExpiringSoon = isAccessTokenExpiring(access_token, 300)
61
- } catch (e) {
62
- if ((e as Error).name !== 'InvalidTokenError') throw e
63
- }
64
-
65
- let isRefreshTokenExpired = false
66
- try {
67
- isRefreshTokenExpired = hasTokenExpired(refresh_token)
68
- } catch (e) {
69
- if ((e as Error).name !== 'InvalidTokenError') throw e
70
- }
71
-
72
- let isRefreshTokenExpiringSoon = false
73
- try {
74
- isRefreshTokenExpiringSoon = isRefreshTokenExpiring(refresh_token)
75
- } catch (e) {
76
- if ((e as Error).name !== 'InvalidTokenError') throw e
77
- }
78
-
79
- if (isAccessTokenExpiringSoon || isRefreshTokenExpiringSoon) {
80
- if (isRefreshTokenExpired) {
81
- const error =
82
- 'Unable to obtain new access token. Your refresh token has expired.'
83
-
84
- logger.error(error)
85
-
86
- throw new Error(error)
87
- }
88
-
89
- logger.info('Refreshing access and refresh tokens.')
90
-
91
- // Tokens minted without a registered OAuth client (e.g. via the
92
- // password grant against the built-in public client) can still be
93
- // refreshed using that same secret-less client. A configured client
94
- // with a missing secret is treated as a public client (empty secret).
95
- const tokens =
96
- serverType === ServerType.SasViya
97
- ? await refreshTokensForViya(
98
- requestClient,
99
- client || 'sas.cli',
100
- secret || '',
101
- refresh_token
102
- )
103
- : await refreshTokensForSasjs(requestClient, refresh_token)
104
- ;({ access_token, refresh_token } = tokens)
105
-
106
- // Viya refresh tokens are single-use/rotating. Callers throughout the
107
- // compute-execution chain (executeOnComputeApi, pollJobState's poll
108
- // loop, executeComputeJob -> executeJob, etc.) share this same
109
- // authConfig object by reference and call getTokens again later in the
110
- // same execution - update it in place so a later call in the same chain
111
- // refreshes with the token that was just issued, not the one that was
112
- // just consumed. client/secret are deliberately left untouched (see
113
- // note above).
114
- authConfig.access_token = access_token
115
- authConfig.refresh_token = refresh_token
116
-
117
- // A failing persistence handler must not turn a successful refresh into
118
- // an auth failure - log the error and return the fresh pair regardless.
119
- try {
120
- await onTokensRefreshed?.({ access_token, refresh_token })
121
- } catch (e) {
122
- logger.error('onTokensRefreshed handler failed:', e)
123
- }
124
- }
125
-
126
- return { access_token, refresh_token, client, secret }
127
- }
package/src/auth/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './AuthManager'
2
- export * from './isAuthorizeFormRequired'
3
- export * from './isLoginRequired'
4
- export * from './loginHeader'
@@ -1,3 +0,0 @@
1
- export const isAuthorizeFormRequired = (response: string): boolean => {
2
- return /<form.+action="(.*Logon\/oauth\/authorize[^"]*).*>/gm.test(response)
3
- }
@@ -1,5 +0,0 @@
1
- export const isLogInRequired = (response: string): boolean => {
2
- const pattern: RegExp = /<form.+action="(.*(Logon)|(login)[^"]*).*>/gm
3
- const matches = pattern.test(response)
4
- return matches
5
- }
@@ -1,97 +0,0 @@
1
- import { ServerType } from '@sasjs/utils/types'
2
- import { getUserLanguage } from '../utils'
3
-
4
- const enLoginSuccessHeader = 'You have signed in.'
5
-
6
- export const defaultSuccessHeaderKey = 'default'
7
-
8
- // The following headers provided by https://github.com/sasjs/adapter/issues/835#issuecomment-2177818601
9
- export const loginSuccessHeaders: { [key: string]: string } = {
10
- es: `Ya se ha iniciado la sesi\u00f3n.`,
11
- th: `\u0e04\u0e38\u0e13\u0e25\u0e07\u0e0a\u0e37\u0e48\u0e2d\u0e40\u0e02\u0e49\u0e32\u0e43\u0e0a\u0e49\u0e41\u0e25\u0e49\u0e27`,
12
- ja: `\u30b5\u30a4\u30f3\u30a4\u30f3\u3057\u307e\u3057\u305f\u3002`,
13
- nb: `Du har logget deg p\u00e5.`,
14
- sl: `Prijavili ste se.`,
15
- ar: `\u0644\u0642\u062f \u0642\u0645\u062a `,
16
- sk: `Prihl\u00e1sili ste sa.`,
17
- zh_HK: `\u60a8\u5df2\u767b\u5165\u3002`,
18
- zh_CN: `\u60a8\u5df2\u767b\u5f55\u3002`,
19
- it: `L'utente si \u00e8 connesso.`,
20
- sv: `Du har loggat in.`,
21
- he: `\u05e0\u05db\u05e0\u05e1\u05ea `,
22
- nl: `U hebt zich aangemeld.`,
23
- pl: `Zosta\u0142e\u015b zalogowany.`,
24
- ko: `\ub85c\uadf8\uc778\ud588\uc2b5\ub2c8\ub2e4.`,
25
- zh_TW: `\u60a8\u5df2\u767b\u5165\u3002`,
26
- tr: `Oturum a\u00e7t\u0131n\u0131z.`,
27
- iw: `\u05e0\u05db\u05e0\u05e1\u05ea `,
28
- fr: `Vous \u00eates connect\u00e9.`,
29
- uk: `\u0412\u0438 \u0432\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u043e\u0431\u043b\u0456\u043a\u043e\u0432\u0438\u0439 \u0437\u0430\u043f\u0438\u0441.`,
30
- pt_BR: `Voc\u00ea se conectou.`,
31
- no: `Du har logget deg p\u00e5.`,
32
- cs: `Jste p\u0159ihl\u00e1\u0161eni.`,
33
- fi: `Olet kirjautunut sis\u00e4\u00e4n.`,
34
- ru: `\u0412\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0432\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443.`,
35
- el: `\u0388\u03c7\u03b5\u03c4\u03b5 \u03c3\u03c5\u03bd\u03b4\u03b5\u03b8\u03b5\u03af.`,
36
- hr: `Prijavili ste se.`,
37
- da: `Du er logget p\u00e5.`,
38
- de: `Sie sind jetzt angemeldet.`,
39
- sh: `Prijavljeni ste.`,
40
- pt: `Iniciou sess\u00e3o.`,
41
- hu: `Bejelentkezett.`,
42
- sr: `Prijavljeni ste.`,
43
- en: enLoginSuccessHeader,
44
- [defaultSuccessHeaderKey]: enLoginSuccessHeader
45
- }
46
-
47
- /**
48
- * Provides expected login header based on language settings of the browser.
49
- * @returns - expected header as a string.
50
- */
51
- export const getExpectedLogInSuccessHeader = (): string => {
52
- // get default success header
53
- let successHeader = loginSuccessHeaders[defaultSuccessHeaderKey]
54
-
55
- // get user language based on language settings of the browser
56
- const userLang = getUserLanguage()
57
-
58
- if (userLang) {
59
- // get success header on exact match of the language code
60
- let userLangSuccessHeader = loginSuccessHeaders[userLang]
61
-
62
- // handle case when there is no exact match of the language code
63
- if (!userLangSuccessHeader) {
64
- // get all supported language codes
65
- const headerLanguages = Object.keys(loginSuccessHeaders)
66
-
67
- // find language code on partial match
68
- const headerLanguage = headerLanguages.find((language) =>
69
- new RegExp(language, 'i').test(userLang)
70
- )
71
-
72
- // reassign success header if partial match was found
73
- if (headerLanguage) {
74
- successHeader = loginSuccessHeaders[headerLanguage]
75
- }
76
- } else {
77
- successHeader = userLangSuccessHeader
78
- }
79
- }
80
-
81
- return successHeader
82
- }
83
-
84
- /**
85
- * Checks if Login success header is present in the response based on language settings of the browser.
86
- * @param serverType - server type.
87
- * @param response - response object.
88
- * @returns - boolean indicating if Login success header is present.
89
- */
90
- export const isLogInSuccessHeaderPresent = (
91
- serverType: ServerType,
92
- response: any
93
- ): boolean => {
94
- if (serverType === ServerType.Sasjs) return response?.loggedIn
95
-
96
- return new RegExp(getExpectedLogInSuccessHeader(), 'gm').test(response)
97
- }
@@ -1,40 +0,0 @@
1
- import { openLoginPrompt } from '../utils/loginPrompt'
2
-
3
- interface WindowFeatures {
4
- width: number
5
- height: number
6
- }
7
-
8
- const defaultWindowFeatures: WindowFeatures = { width: 500, height: 600 }
9
-
10
- export async function openWebPage(
11
- url: string,
12
- windowName: string = '',
13
- WindowFeatures: WindowFeatures = defaultWindowFeatures,
14
- onLoggedOut?: () => Promise<Boolean>
15
- ): Promise<Window | null> {
16
- const { width, height } = WindowFeatures
17
- const left = screen.width / 2 - width / 2
18
- const top = screen.height / 2 - height / 2
19
-
20
- const loginPopup = window.open(
21
- url,
22
- windowName,
23
- `toolbar=0,location=0,menubar=0,width=${width},height=${height},left=${left},top=${top}`
24
- )
25
-
26
- if (!loginPopup) {
27
- const getUserAction: () => Promise<Boolean> = onLoggedOut ?? openLoginPrompt
28
-
29
- const doLogin = await getUserAction()
30
- return doLogin
31
- ? window.open(
32
- url,
33
- windowName,
34
- `toolbar=0,location=0,menubar=0,width=${width},height=${height},left=${left},top=${top}`
35
- )
36
- : null
37
- }
38
-
39
- return loginPopup
40
- }
@@ -1,45 +0,0 @@
1
- import { prefixMessage } from '@sasjs/utils/error'
2
- import { RequestClient } from '../request/RequestClient'
3
- import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
4
- import { ServerType } from '@sasjs/utils/types'
5
-
6
- /**
7
- * Exchanges the refresh token for an access token for the given client.
8
- * @param requestClient - the pre-configured HTTP request client
9
- * @param refreshToken - the refresh token received from the server.
10
- */
11
- export async function refreshTokensForSasjs(
12
- requestClient: RequestClient,
13
- refreshToken: string
14
- ) {
15
- const url = '/SASjsApi/auth/refresh'
16
- const headers = {
17
- Authorization: 'Bearer ' + refreshToken
18
- }
19
-
20
- const authResponse = await requestClient
21
- .post(url, undefined, undefined, undefined, headers)
22
- .then((res) => {
23
- const sasAuth = res.result as {
24
- accessToken: string
25
- refreshToken: string
26
- }
27
- return {
28
- access_token: sasAuth.accessToken,
29
- refresh_token: sasAuth.refreshToken
30
- }
31
- })
32
- .catch((err) => {
33
- throw prefixMessage(
34
- err,
35
- getTokenRequestErrorPrefix(
36
- 'refreshing tokens',
37
- 'refreshTokensForSasjs',
38
- ServerType.Sasjs,
39
- url
40
- )
41
- )
42
- })
43
-
44
- return authResponse
45
- }
@@ -1,66 +0,0 @@
1
- import { SasAuthResponse, ServerType } from '@sasjs/utils/types'
2
- import { prefixMessage } from '@sasjs/utils/error'
3
- import NodeFormData from 'form-data'
4
- import { RequestClient } from '../request/RequestClient'
5
- import { isNode } from '../utils'
6
- import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
7
-
8
- /**
9
- * Exchanges the refresh token for an access token for the given client.
10
- * This function can only be used by Node.
11
- * @param requestClient - the pre-configured HTTP request client
12
- * @param clientId - the client ID to authenticate with.
13
- * @param clientSecret - the client secret to authenticate with.
14
- * @param refreshToken - the refresh token received from the server.
15
- */
16
- export async function refreshTokensForViya(
17
- requestClient: RequestClient,
18
- clientId: string,
19
- clientSecret: string,
20
- refreshToken: string
21
- ) {
22
- if (!isNode()) {
23
- throw new Error(`Method 'refreshTokensForViya' can only be used by Node.`)
24
- }
25
-
26
- const url = '/SASLogon/oauth/token'
27
- const token =
28
- typeof Buffer === 'undefined'
29
- ? btoa(clientId + ':' + clientSecret)
30
- : Buffer.from(clientId + ':' + clientSecret).toString('base64')
31
-
32
- const headers = {
33
- Authorization: 'Basic ' + token
34
- }
35
-
36
- const formData = new NodeFormData()
37
- formData.append('grant_type', 'refresh_token')
38
- formData.append('refresh_token', refreshToken)
39
-
40
- const authResponse = await requestClient
41
- .post<SasAuthResponse>(
42
- url,
43
- formData,
44
- undefined,
45
- 'multipart/form-data; boundary=' + (formData as any)._boundary,
46
- headers
47
- )
48
- .then((res) => res.result)
49
- .catch((err) => {
50
- throw prefixMessage(
51
- err,
52
- getTokenRequestErrorPrefix(
53
- 'refreshing tokens',
54
- 'refreshTokensForViya',
55
- ServerType.SasViya,
56
- url,
57
- formData,
58
- headers,
59
- clientId,
60
- clientSecret
61
- )
62
- )
63
- })
64
-
65
- return authResponse
66
- }
@@ -1,53 +0,0 @@
1
- import { SasAuthResponse } from '@sasjs/utils/types'
2
-
3
- export const mockLoginAuthoriseRequiredResponse = `<form id="application_authorization" action="/SASLogon/oauth/authorize" method="POST"><input type="hidden" name="X-Uaa-Csrf" value="2nfuxIn6WaOURWL7tzTXCe"/>`
4
-
5
- export const mockAuthResponse: SasAuthResponse = {
6
- access_token: 'acc355',
7
- refresh_token: 'r3fr35h',
8
- id_token: 'id',
9
- token_type: 'bearer',
10
- expires_in: new Date().valueOf(),
11
- scope: 'default',
12
- jti: 'test'
13
- }
14
-
15
- export const mockSasjsAuthResponse = {
16
- access_token: 'acc355',
17
- refresh_token: 'r3fr35h'
18
- }
19
-
20
- export const generateToken = (timeToLiveSeconds: number): string => {
21
- const exp =
22
- new Date(new Date().getTime() + timeToLiveSeconds * 1000).getTime() / 1000
23
- const header = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9'
24
- const payload = Buffer.from(JSON.stringify({ exp })).toString('base64')
25
- const signature = '4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo'
26
- const token = `${header}.${payload}.${signature}`
27
- return token
28
- }
29
-
30
- export const mockedCurrentUserApi = (username: string) => ({
31
- creationTimeStamp: '2021-04-17T14:13:14.000Z',
32
- modifiedTimeStamp: '2021-08-31T22:08:07.000Z',
33
- id: username,
34
- type: 'user',
35
- name: 'Full User Name',
36
- links: [
37
- {
38
- method: 'GET',
39
- rel: 'self',
40
- href: `/identities/users/${username}`,
41
- uri: `/identities/users/${username}`,
42
- type: 'user'
43
- },
44
- {
45
- method: 'GET',
46
- rel: 'alternate',
47
- href: `/identities/users/${username}`,
48
- uri: `/identities/users/${username}`,
49
- type: 'application/vnd.sas.summary'
50
- }
51
- ],
52
- version: 2
53
- })
@@ -1,25 +0,0 @@
1
- import { delay } from '../utils'
2
- import { getExpectedLogInSuccessHeader } from './'
3
-
4
- export async function verifySas9Login(loginPopup: Window): Promise<{
5
- isLoggedIn: boolean
6
- }> {
7
- let isLoggedIn = false
8
- let startTime = new Date()
9
- let elapsedSeconds = 0
10
-
11
- do {
12
- await delay(1000)
13
- if (loginPopup.closed) break
14
-
15
- isLoggedIn =
16
- loginPopup.window.location.href.includes('SASLogon') &&
17
- loginPopup.window.document.body.innerText.includes(
18
- getExpectedLogInSuccessHeader()
19
- )
20
-
21
- elapsedSeconds = (new Date().valueOf() - startTime.valueOf()) / 1000
22
- } while (!isLoggedIn && elapsedSeconds < 5 * 60)
23
-
24
- return { isLoggedIn }
25
- }
@@ -1,43 +0,0 @@
1
- import { delay } from '../utils'
2
- import { getExpectedLogInSuccessHeader } from './'
3
-
4
- export async function verifySasViyaLogin(loginPopup: Window): Promise<{
5
- isLoggedIn: boolean
6
- }> {
7
- let isLoggedIn = false
8
- let startTime = new Date()
9
- let elapsedSeconds = 0
10
-
11
- do {
12
- await delay(1000)
13
-
14
- if (loginPopup.closed) break
15
-
16
- isLoggedIn = isLoggedInSASVIYA()
17
-
18
- elapsedSeconds = (new Date().valueOf() - startTime.valueOf()) / 1000
19
- } while (!isLoggedIn && elapsedSeconds < 5 * 60)
20
-
21
- let isAuthorized = false
22
-
23
- startTime = new Date()
24
-
25
- do {
26
- await delay(1000)
27
-
28
- if (loginPopup.closed) break
29
-
30
- isAuthorized =
31
- loginPopup.window.location.href.includes('SASLogon') ||
32
- loginPopup.window.document.body?.innerText?.includes(
33
- getExpectedLogInSuccessHeader()
34
- )
35
-
36
- elapsedSeconds = (new Date().valueOf() - startTime.valueOf()) / 1000
37
- } while (!isAuthorized && elapsedSeconds < 5 * 60)
38
-
39
- return { isLoggedIn: isLoggedIn && isAuthorized }
40
- }
41
-
42
- export const isLoggedInSASVIYA = () =>
43
- document.cookie.includes('Current-User') && document.cookie.includes('userId')
@@ -1,48 +0,0 @@
1
- import NodeFormData from 'form-data'
2
- import { convertToCSV } from '../utils/convertToCsv'
3
- import { isNode } from '../utils'
4
-
5
- /**
6
- * One of the approaches SASjs takes to send tables-formatted JSON (see README)
7
- * to SAS is as multipart form data, where each table is provided as a specially
8
- * formatted CSV file.
9
- * @param formData Different objects are used depending on whether the adapter is
10
- * running in the browser, or in the CLI
11
- * @param data Special, tables-formatted JSON (see README)
12
- * @returns Populated formData
13
- */
14
- export const generateFileUploadForm = (
15
- formData: FormData | NodeFormData,
16
- data: any
17
- ): FormData | NodeFormData => {
18
- for (const tableName in data) {
19
- if (!Array.isArray(data[tableName])) continue
20
-
21
- const name = tableName
22
- const csv = convertToCSV(data, tableName)
23
-
24
- if (csv === 'ERROR: LARGE STRING LENGTH') {
25
- throw new Error(
26
- 'The max length of a string value in SASjs is 32765 characters.'
27
- )
28
- }
29
-
30
- // INFO: unfortunately it is not possible to check if formData is instance of NodeFormData or FormData because it will return true for both
31
- if (isNode()) {
32
- // INFO: environment is Node and formData is instance of NodeFormData
33
- ;(formData as NodeFormData).append(name, csv, {
34
- filename: `${name}.csv`,
35
- contentType: 'application/csv'
36
- })
37
- } else {
38
- // INFO: environment is Browser and formData is instance of FormData
39
- const file = new Blob([csv], {
40
- type: 'application/csv'
41
- })
42
-
43
- formData.append(name, file, `${name}.csv`)
44
- }
45
- }
46
-
47
- return formData
48
- }