@qoniai/qoni 0.5.0 → 0.5.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.1 - 2026-09-23
4
+
5
+ ### Fixed
6
+
7
+ - Recheck access-key scope policy at token exchange before every SDK product
8
+ operation, including repeated calls with the same delegation token. Removing
9
+ a scope now blocks the next SDK operation instead of leaving a cached product
10
+ token usable until expiry.
11
+
3
12
  ## 0.5.0 - 2026-09-17
4
13
 
5
14
  ### Added
package/README.md CHANGED
@@ -788,6 +788,9 @@ Common first-run errors:
788
788
  - Keep Qoni AK/SK on trusted servers only.
789
789
  - Do not expose delegation tokens to untrusted clients.
790
790
  - Request the smallest useful scope set for each Agent action.
791
+ - Product methods exchange the delegation token on every call, so a change to
792
+ the access key's allowed scopes is checked before the next SDK operation.
793
+ Product tokens already obtained outside the SDK remain valid until expiry.
791
794
  - Prefer `interactive` mode for browser control, site login, long-running monitors, and sensitive artifacts.
792
795
  - Store `auditId`, `requestId`, and `traceId` with product logs when later investigation matters.
793
796
  - Rotate AK/SK through Qoni Console if a credential might have been exposed.
package/README.zh-CN.md CHANGED
@@ -717,6 +717,8 @@ try {
717
717
  - AK/SK 只保存在可信服务端。
718
718
  - 不要把 delegation token 暴露给不可信客户端。
719
719
  - 每次 Agent 行动只申请必要 scope。
720
+ - SDK 的产品方法每次调用前都会重新兑换 delegation token,因此 AccessKey 的 scope
721
+ 变更会在下一次 SDK 调用前重新校验。已经在 SDK 外取得的产品 token 仍会持续有效至过期。
720
722
  - 浏览器接管、站点登录、长期监控、敏感产物访问优先使用 `interactive`。
721
723
  - 在业务日志中记录 `auditId`、`requestId`、`traceId`,方便后续审计。
722
724
  - 如果怀疑 AK/SK 泄露,应在 Qoni Console 中轮换密钥。
package/dist/index.cjs CHANGED
@@ -2114,7 +2114,6 @@ var Qoni = class {
2114
2114
  secretKey;
2115
2115
  host;
2116
2116
  runtimeConfigPromise;
2117
- productTokenCache = /* @__PURE__ */ new Map();
2118
2117
  genAuthAdminTokenCache;
2119
2118
  gumem;
2120
2119
  genauth;
@@ -2585,9 +2584,6 @@ var Qoni = class {
2585
2584
  const runtimeToken = requiredRuntimeToken(token);
2586
2585
  if (!isQoniDelegationToken(runtimeToken)) return runtimeToken;
2587
2586
  const scopes = [...requiredScopes || []].sort();
2588
- const cacheKey = [service, runtimeToken, scopes.join(" ")].join(":");
2589
- const cached = this.productTokenCache.get(cacheKey);
2590
- if (cached && cached.expiresAt > Date.now() + 3e4) return cached.token;
2591
2587
  const response = await this.signedPost("/api/v3/eak/token-exchange", {
2592
2588
  subjectToken: runtimeToken,
2593
2589
  resource: service === "gumem" ? "gumem" : "webagent",
@@ -2602,10 +2598,6 @@ var Qoni = class {
2602
2598
  "Qoni product token exchange response did not include an access token"
2603
2599
  );
2604
2600
  }
2605
- this.productTokenCache.set(cacheKey, {
2606
- token: accessToken,
2607
- expiresAt: Date.now() + Math.max(0, readExpiresIn(payload) ?? 3600) * 1e3
2608
- });
2609
2601
  return accessToken;
2610
2602
  }
2611
2603
  async genauthAdminTokenFor() {