@eyepop.ai/eyepop 3.25.6 → 3.25.7

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.
@@ -1472,8 +1472,8 @@ declare class Endpoint<T extends Endpoint<T>> {
1472
1472
  private exchange;
1473
1473
  private storeExchangedToken;
1474
1474
  /**
1475
- * A token that already carries an account, or that the compute API refuses as an exchanged
1476
- * token ("API key or user login required"), is used as is. Any other refusal is raised.
1475
+ * A token that already carries an account, or that the compute API refuses to exchange
1476
+ * (see NOT_EXCHANGEABLE), is used as is. Any other refusal is raised.
1477
1477
  */
1478
1478
  private exchangeLoginToken;
1479
1479
  private currentAccessToken;
@@ -1472,8 +1472,8 @@ declare class Endpoint<T extends Endpoint<T>> {
1472
1472
  private exchange;
1473
1473
  private storeExchangedToken;
1474
1474
  /**
1475
- * A token that already carries an account, or that the compute API refuses as an exchanged
1476
- * token ("API key or user login required"), is used as is. Any other refusal is raised.
1475
+ * A token that already carries an account, or that the compute API refuses to exchange
1476
+ * (see NOT_EXCHANGEABLE), is used as is. Any other refusal is raised.
1477
1477
  */
1478
1478
  private exchangeLoginToken;
1479
1479
  private currentAccessToken;
@@ -9045,7 +9045,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9045
9045
 
9046
9046
  // endpoint.ts
9047
9047
  var ACCOUNT_CLAIM = "https://ident.eyepop.ai/account-uuid";
9048
- var M2M_REFUSAL = "API key or user login required";
9048
+ var NOT_EXCHANGEABLE = ["API key or user login required", "API key authentication required for token refresh"];
9049
9049
  function carriesAccount(token) {
9050
9050
  try {
9051
9051
  const payload = (token.split(".")[1] ?? "").replace(/-/g, "+").replace(/_/g, "/");
@@ -9242,13 +9242,14 @@ var Endpoint = class {
9242
9242
  this._expire_token_time = now + token.expires_in - 60;
9243
9243
  }
9244
9244
  /**
9245
- * A token that already carries an account, or that the compute API refuses as an exchanged
9246
- * token ("API key or user login required"), is used as is. Any other refusal is raised.
9245
+ * A token that already carries an account, or that the compute API refuses to exchange
9246
+ * (see NOT_EXCHANGEABLE), is used as is. Any other refusal is raised.
9247
9247
  */
9248
9248
  async exchangeLoginToken(client, loginToken, validUntil, now) {
9249
9249
  if (!carriesAccount(loginToken)) {
9250
9250
  const response = await this.exchange(client, loginToken, this._options.accountId);
9251
- if (response.status != 401 || !(await response.clone().text()).includes(M2M_REFUSAL)) {
9251
+ const refusal = response.status == 401 ? await response.clone().text() : "";
9252
+ if (!NOT_EXCHANGEABLE.some((message) => refusal.includes(message))) {
9252
9253
  await this.storeExchangedToken(response, now);
9253
9254
  return;
9254
9255
  }