guniweb-sap-mcp 0.1.21 → 0.1.22
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.
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -986,7 +986,7 @@ var SapHttpClient = class {
|
|
|
986
986
|
const destHeaders = this.destination.headers ?? {};
|
|
987
987
|
let csrfHeaders = {};
|
|
988
988
|
if (isMutating) {
|
|
989
|
-
const csrf = await this.fetchCsrfToken({ ...destHeaders, ...authHeaders });
|
|
989
|
+
const csrf = await this.fetchCsrfToken({ ...destHeaders, ...authHeaders }, config.url);
|
|
990
990
|
if (csrf.token) {
|
|
991
991
|
csrfHeaders = { "x-csrf-token": csrf.token };
|
|
992
992
|
if (csrf.cookies) {
|
|
@@ -1059,7 +1059,10 @@ var SapHttpClient = class {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
if (isMutating && this.isCsrf403(error)) {
|
|
1061
1061
|
try {
|
|
1062
|
-
const freshCsrf = await this.fetchCsrfToken(
|
|
1062
|
+
const freshCsrf = await this.fetchCsrfToken(
|
|
1063
|
+
{ ...destHeaders, ...authHeaders },
|
|
1064
|
+
config.url
|
|
1065
|
+
);
|
|
1063
1066
|
const retryHeaders = { ...axiosConfig.headers };
|
|
1064
1067
|
if (freshCsrf.token) {
|
|
1065
1068
|
retryHeaders["x-csrf-token"] = freshCsrf.token;
|
|
@@ -1102,9 +1105,16 @@ var SapHttpClient = class {
|
|
|
1102
1105
|
return {};
|
|
1103
1106
|
}
|
|
1104
1107
|
}
|
|
1105
|
-
async fetchCsrfToken(authHeaders) {
|
|
1108
|
+
async fetchCsrfToken(authHeaders, requestPath) {
|
|
1106
1109
|
const baseUrl = this.destination.url;
|
|
1107
|
-
const urls = [
|
|
1110
|
+
const urls = [];
|
|
1111
|
+
if (requestPath) {
|
|
1112
|
+
const serviceRoot = requestPath.replace(/\/[^/]*$/, "/");
|
|
1113
|
+
if (serviceRoot !== "/" && serviceRoot !== requestPath) {
|
|
1114
|
+
urls.push(`${baseUrl}${serviceRoot}`);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
urls.push(`${baseUrl}/`, baseUrl);
|
|
1108
1118
|
for (const url of urls) {
|
|
1109
1119
|
try {
|
|
1110
1120
|
const csrfFetchHeaders = { ...authHeaders, "x-csrf-token": "fetch" };
|