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.mjs CHANGED
@@ -518,7 +518,7 @@ function isDev() {
518
518
  }
519
519
  var Logger = class {
520
520
  constructor() {
521
- this.prefix = "[tenneo-auth-gateway-plugin]";
521
+ this.prefix = "[tenneo-auth-plugin]";
522
522
  }
523
523
  log(level, message, data) {
524
524
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
@@ -1190,7 +1190,7 @@ function storeTokens(tokenData) {
1190
1190
  }
1191
1191
  async function exchangeCodeForTokens(params) {
1192
1192
  try {
1193
- const { code, codeVerifier, clientId, redirectUri } = params;
1193
+ const { code, codeVerifier, clientId, redirectUri, tenantId } = params;
1194
1194
  const apiAuthBaseUrl = Config.getAuthServerUrl();
1195
1195
  const tokenUrl = `${apiAuthBaseUrl}/oauth/token`;
1196
1196
  const body = new URLSearchParams({
@@ -1202,7 +1202,10 @@ async function exchangeCodeForTokens(params) {
1202
1202
  });
1203
1203
  const response = await fetch(tokenUrl, {
1204
1204
  method: "POST",
1205
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
1205
+ headers: {
1206
+ "Content-Type": "application/x-www-form-urlencoded",
1207
+ "X-Tenant-Id": tenantId
1208
+ },
1206
1209
  body: body.toString()
1207
1210
  });
1208
1211
  if (!response.ok) {
@@ -1265,19 +1268,20 @@ async function refreshAccessToken() {
1265
1268
  });
1266
1269
  throw new Error("Cannot refresh token: missing required data");
1267
1270
  }
1268
- const apiAuthBaseUrl = Config.getAuthServerUrl();
1269
- const tokenUrl = `${apiAuthBaseUrl}/oauth/refresh`;
1271
+ const refreshTokenApiAuthBaseUrl = Config.getAuthServerUrl();
1272
+ const refreshtokenUrl = `${refreshTokenApiAuthBaseUrl}/oauth/refresh`;
1270
1273
  const body = new URLSearchParams({
1271
1274
  grant_type: DEFAULT_REFRESH_GRANT_TYPE,
1272
1275
  refresh_token: refreshToken,
1273
1276
  client_id: clientId.startsWith("public-") ? clientId : `public-${clientId}`,
1274
1277
  tenant_id: tenantId
1275
1278
  });
1276
- const response = await fetch(tokenUrl, {
1279
+ const response = await fetch(refreshtokenUrl, {
1277
1280
  method: "POST",
1278
1281
  headers: {
1279
1282
  "Content-Type": "application/x-www-form-urlencoded",
1280
- "Accept": "application/json"
1283
+ "Accept": "application/json",
1284
+ "X-Tenant-Id": tenantId
1281
1285
  },
1282
1286
  body: body.toString()
1283
1287
  });
@@ -1297,7 +1301,7 @@ async function refreshAccessToken() {
1297
1301
  status: response.status,
1298
1302
  statusText: response.statusText,
1299
1303
  responseData,
1300
- requestUrl: tokenUrl
1304
+ requestUrl: refreshtokenUrl
1301
1305
  });
1302
1306
  throw new Error(
1303
1307
  `Token refresh failed: ${response.status} ${response.statusText}${Object.keys(responseData).length ? ` - ${JSON.stringify(responseData)}` : ""}`