From 8192f69f67a4f31b10050dcd66f924c62f1d693b Mon Sep 17 00:00:00 2001 From: Krishna Acondy Date: Tue, 18 Aug 2020 08:25:40 +0100 Subject: [PATCH 1/3] fix(*): do not use polyfill when running on Node.js --- src/SASjs.ts | 4 +++- src/utils/isIeOrEdge.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SASjs.ts b/src/SASjs.ts index 9167280..583e78c 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -2,7 +2,9 @@ import { isIEorEdgeOrOldFirefox } from "./utils/isIeOrEdge"; import * as e6p from "es6-promise"; (e6p as any).polyfill(); if (isIEorEdgeOrOldFirefox()) { - window.fetch = undefined as any; // ensure the polyfill runs + if (window) { + window.fetch = undefined as any; // ensure the polyfill runs + } } // tslint:disable-next-line require("isomorphic-fetch"); diff --git a/src/utils/isIeOrEdge.ts b/src/utils/isIeOrEdge.ts index 59400da..2a57ac3 100644 --- a/src/utils/isIeOrEdge.ts +++ b/src/utils/isIeOrEdge.ts @@ -1,4 +1,7 @@ export function isIEorEdgeOrOldFirefox() { + if (typeof window === "undefined") { + return false; + } const ua = window.navigator.userAgent; if (ua.indexOf("Firefox") > 0) { From 005f10bb47383e5a3757efc64108f484c27c5868 Mon Sep 17 00:00:00 2001 From: Allan Bowe <4420615+allanbowe@users.noreply.github.com> Date: Tue, 18 Aug 2020 11:24:30 +0200 Subject: [PATCH 2/3] Update CONTRIBUTING.md --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 135d8de..fff2908 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -70,6 +70,14 @@ parmcards4; %webout(CLOSE) ;;;; %mp_createwebservice(path=/Public/app/common,name=sendArr) +filename ft15f001 temp; +parmcards4; +If you can keep your head when all about you + Are losing theirs and blaming it on you, +If you can trust yourself when all men doubt you, + But make allowance for their doubting too; +;;;; +%mp_createwebservice(path=/Public/app/common,name=makeErr) ``` The above services will return anything you send. To run the tests simply launch `npm run cypress`. From 0479a5d6517d3c3166bf6fbd63e6fd7921a79fe2 Mon Sep 17 00:00:00 2001 From: Mihajlo Medjedovic Date: Tue, 18 Aug 2020 13:17:29 +0200 Subject: [PATCH 3/3] fix: csrfTokenWeb setter callback --- src/FileUploader.ts | 5 ++++- src/SASjs.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/FileUploader.ts b/src/FileUploader.ts index e2ccd7d..b659276 100644 --- a/src/FileUploader.ts +++ b/src/FileUploader.ts @@ -9,7 +9,8 @@ export class FileUploader { private appLoc: string, private serverUrl: string, private jobsPath: string, - private csrfToken: CsrfToken | null = null + private setCsrfTokenWeb: any, + private csrfToken: CsrfToken | null = null, ) {} private retryCount = 0; @@ -61,6 +62,8 @@ export class FileUploader { headerName: tokenHeader, value: token || "", }; + + this.setCsrfTokenWeb(this.csrfToken); } } } diff --git a/src/SASjs.ts b/src/SASjs.ts index 583e78c..7dc5401 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -399,8 +399,10 @@ export default class SASjs { this.sasjsConfig.appLoc, this.sasjsConfig.serverUrl, this.jobsPath, + this.setCsrfTokenWeb, this.csrfTokenWeb ); + return fileUploader.uploadFile(sasJob, files, params); } @@ -911,6 +913,10 @@ export default class SASjs { return sasjsWaitingRequest.requestPromise.promise; } + + private setCsrfTokenWeb = (csrfToken: CsrfToken) => { + this.csrfTokenWeb = csrfToken; + }; private setCsrfTokenApi = (csrfToken: CsrfToken) => { this.csrfTokenApi = csrfToken; @@ -1177,7 +1183,8 @@ export default class SASjs { this.fileUploader = new FileUploader( this.sasjsConfig.appLoc, this.sasjsConfig.serverUrl, - this.jobsPath + this.jobsPath, + this.setCsrfTokenWeb ); }