mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-18 09:30:06 +00:00
fix: withXSRFToken instead of withCredentials
This commit is contained in:
23657
sasjs-tests/package-lock.json
generated
23657
sasjs-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@
|
||||
"homepage": ".",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@sasjs/adapter": "file:../build/sasjs-adapter-5.0.0.tgz",
|
||||
"@sasjs/test-framework": "1.5.7",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.41",
|
||||
@@ -13,11 +14,11 @@
|
||||
"react": "^16.0.1",
|
||||
"react-dom": "^16.0.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-scripts": "4.0.3",
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
|
||||
@@ -159,7 +159,7 @@ describe('AuthManager', () => {
|
||||
`/SASLogon/login`,
|
||||
loginParams,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Accept: '*/*'
|
||||
@@ -207,7 +207,7 @@ describe('AuthManager', () => {
|
||||
`/SASLogon/login`,
|
||||
loginParams,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Accept: '*/*'
|
||||
@@ -256,7 +256,7 @@ describe('AuthManager', () => {
|
||||
`/SASLogon/login`,
|
||||
loginParams,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Accept: '*/*'
|
||||
@@ -539,7 +539,7 @@ describe('AuthManager', () => {
|
||||
1,
|
||||
`http://test-server.com/identities/users/@currentUser`,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
responseType: 'text',
|
||||
transformResponse: undefined,
|
||||
headers: {
|
||||
@@ -573,7 +573,7 @@ describe('AuthManager', () => {
|
||||
1,
|
||||
`http://test-server.com/SASStoredProcess`,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
responseType: 'text',
|
||||
transformResponse: undefined,
|
||||
headers: {
|
||||
@@ -602,7 +602,7 @@ describe('AuthManager', () => {
|
||||
1,
|
||||
`http://test-server.com/identities/users/@currentUser`,
|
||||
{
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
responseType: 'text',
|
||||
transformResponse: undefined,
|
||||
headers: {
|
||||
@@ -621,7 +621,7 @@ describe('AuthManager', () => {
|
||||
})
|
||||
|
||||
const getHeadersJson = {
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
|
||||
@@ -160,7 +160,7 @@ export class RequestClient implements HttpClient {
|
||||
const requestConfig: AxiosRequestConfig = {
|
||||
headers,
|
||||
responseType: contentType === 'text/plain' ? 'text' : 'json',
|
||||
withCredentials: true
|
||||
withXSRFToken: true
|
||||
}
|
||||
|
||||
if (contentType === 'text/plain') {
|
||||
@@ -207,7 +207,7 @@ export class RequestClient implements HttpClient {
|
||||
return this.httpClient
|
||||
.post<T>(url, data, {
|
||||
headers,
|
||||
withCredentials: true,
|
||||
withXSRFToken: true,
|
||||
...additionalSettings
|
||||
})
|
||||
.then((response) => {
|
||||
@@ -234,7 +234,7 @@ export class RequestClient implements HttpClient {
|
||||
}
|
||||
|
||||
return this.httpClient
|
||||
.put<T>(url, data, { headers, withCredentials: true })
|
||||
.put<T>(url, data, { headers, withXSRFToken: true })
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
@@ -253,7 +253,7 @@ export class RequestClient implements HttpClient {
|
||||
const headers = this.getHeaders(accessToken, 'application/json')
|
||||
|
||||
return this.httpClient
|
||||
.delete<T>(url, { headers, withCredentials: true })
|
||||
.delete<T>(url, { headers, withXSRFToken: true })
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
@@ -271,7 +271,7 @@ export class RequestClient implements HttpClient {
|
||||
const headers = this.getHeaders(accessToken, 'application/json')
|
||||
|
||||
return this.httpClient
|
||||
.patch<T>(url, data, { headers, withCredentials: true })
|
||||
.patch<T>(url, data, { headers, withXSRFToken: true })
|
||||
.then((response) => {
|
||||
throwIfError(response)
|
||||
return this.parseResponse<T>(response)
|
||||
@@ -630,7 +630,7 @@ ${resHeaders}${parsedResBody ? `\n\n${parsedResBody}` : ''}
|
||||
// Fetching root and creating CSRF cookie
|
||||
await this.httpClient
|
||||
.get('/', {
|
||||
withCredentials: true
|
||||
withXSRFToken: true
|
||||
})
|
||||
.then((response) => {
|
||||
const cookie =
|
||||
|
||||
@@ -50,7 +50,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
const requestConfig: AxiosRequestConfig = {
|
||||
headers,
|
||||
responseType: contentType === 'text/plain' ? 'text' : 'json',
|
||||
withCredentials: true
|
||||
withXSRFToken: true
|
||||
}
|
||||
if (contentType === 'text/plain') {
|
||||
requestConfig.transformResponse = undefined
|
||||
@@ -103,7 +103,7 @@ export class Sas9RequestClient extends RequestClient {
|
||||
}
|
||||
|
||||
return this.httpClient
|
||||
.post<T>(url, data, { headers, withCredentials: true })
|
||||
.post<T>(url, data, { headers, withXSRFToken: true })
|
||||
.then(async (response) => {
|
||||
if (response.status === 302) {
|
||||
return await this.get(
|
||||
|
||||
@@ -24,7 +24,7 @@ const axiosActual = jest.requireActual('axios')
|
||||
jest
|
||||
.spyOn(axiosModules, 'createAxiosInstance')
|
||||
.mockImplementation((baseURL: string, httpsAgent?: https.Agent) =>
|
||||
axiosActual.create({ baseURL, httpsAgent, withCredentials: true })
|
||||
axiosActual.create({ baseURL, httpsAgent, withXSRFToken: true })
|
||||
)
|
||||
|
||||
jest.mock('util', () => {
|
||||
|
||||
Reference in New Issue
Block a user