tenneo-auth-plugin 1.0.6 → 1.0.10

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 CHANGED
@@ -524,7 +524,7 @@ function isDev() {
524
524
  }
525
525
  var Logger = class {
526
526
  constructor() {
527
- this.prefix = "[tenneo-auth-gateway-plugin]";
527
+ this.prefix = "[tenneo-auth-plugin]";
528
528
  }
529
529
  log(level, message, data) {
530
530
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
@@ -1196,7 +1196,7 @@ function storeTokens(tokenData) {
1196
1196
  }
1197
1197
  async function exchangeCodeForTokens(params) {
1198
1198
  try {
1199
- const { code, codeVerifier, clientId, redirectUri } = params;
1199
+ const { code, codeVerifier, clientId, redirectUri, tenantId } = params;
1200
1200
  const apiAuthBaseUrl = Config.getAuthServerUrl();
1201
1201
  const tokenUrl = `${apiAuthBaseUrl}/oauth/token`;
1202
1202
  const body = new URLSearchParams({
@@ -1208,7 +1208,10 @@ async function exchangeCodeForTokens(params) {
1208
1208
  });
1209
1209
  const response = await fetch(tokenUrl, {
1210
1210
  method: "POST",
1211
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
1211
+ headers: {
1212
+ "Content-Type": "application/x-www-form-urlencoded",
1213
+ "X-Tenant-Id": tenantId
1214
+ },
1212
1215
  body: body.toString()
1213
1216
  });
1214
1217
  if (!response.ok) {
@@ -1271,19 +1274,20 @@ async function refreshAccessToken() {
1271
1274
  });
1272
1275
  throw new Error("Cannot refresh token: missing required data");
1273
1276
  }
1274
- const apiAuthBaseUrl = Config.getAuthServerUrl();
1275
- const tokenUrl = `${apiAuthBaseUrl}/oauth/refresh`;
1277
+ const refreshTokenApiAuthBaseUrl = Config.getAuthServerUrl();
1278
+ const refreshtokenUrl = `${refreshTokenApiAuthBaseUrl}/oauth/refresh`;
1276
1279
  const body = new URLSearchParams({
1277
1280
  grant_type: DEFAULT_REFRESH_GRANT_TYPE,
1278
1281
  refresh_token: refreshToken,
1279
1282
  client_id: clientId.startsWith("public-") ? clientId : `public-${clientId}`,
1280
1283
  tenant_id: tenantId
1281
1284
  });
1282
- const response = await fetch(tokenUrl, {
1285
+ const response = await fetch(refreshtokenUrl, {
1283
1286
  method: "POST",
1284
1287
  headers: {
1285
1288
  "Content-Type": "application/x-www-form-urlencoded",
1286
- "Accept": "application/json"
1289
+ "Accept": "application/json",
1290
+ "X-Tenant-Id": tenantId
1287
1291
  },
1288
1292
  body: body.toString()
1289
1293
  });
@@ -1303,7 +1307,7 @@ async function refreshAccessToken() {
1303
1307
  status: response.status,
1304
1308
  statusText: response.statusText,
1305
1309
  responseData,
1306
- requestUrl: tokenUrl
1310
+ requestUrl: refreshtokenUrl
1307
1311
  });
1308
1312
  throw new Error(
1309
1313
  `Token refresh failed: ${response.status} ${response.statusText}${Object.keys(responseData).length ? ` - ${JSON.stringify(responseData)}` : ""}`