@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.
@@ -8929,7 +8929,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
8929
8929
 
8930
8930
  // endpoint.ts
8931
8931
  var ACCOUNT_CLAIM = "https://ident.eyepop.ai/account-uuid";
8932
- var M2M_REFUSAL = "API key or user login required";
8932
+ var NOT_EXCHANGEABLE = ["API key or user login required", "API key authentication required for token refresh"];
8933
8933
  function carriesAccount(token) {
8934
8934
  try {
8935
8935
  const payload = (token.split(".")[1] ?? "").replace(/-/g, "+").replace(/_/g, "/");
@@ -9126,13 +9126,14 @@ var Endpoint = class {
9126
9126
  this._expire_token_time = now + token.expires_in - 60;
9127
9127
  }
9128
9128
  /**
9129
- * A token that already carries an account, or that the compute API refuses as an exchanged
9130
- * token ("API key or user login required"), is used as is. Any other refusal is raised.
9129
+ * A token that already carries an account, or that the compute API refuses to exchange
9130
+ * (see NOT_EXCHANGEABLE), is used as is. Any other refusal is raised.
9131
9131
  */
9132
9132
  async exchangeLoginToken(client, loginToken, validUntil, now) {
9133
9133
  if (!carriesAccount(loginToken)) {
9134
9134
  const response = await this.exchange(client, loginToken, this._options.accountId);
9135
- if (response.status != 401 || !(await response.clone().text()).includes(M2M_REFUSAL)) {
9135
+ const refusal = response.status == 401 ? await response.clone().text() : "";
9136
+ if (!NOT_EXCHANGEABLE.some((message) => refusal.includes(message))) {
9136
9137
  await this.storeExchangedToken(response, now);
9137
9138
  return;
9138
9139
  }