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