dsh-keys-manager 0.3.3 → 0.3.4

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
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to dsh-keys-manager are documented here. Assembled from `.changes/unreleased/` fragments by the release-prep workflow.
4
4
 
5
+ ## [0.3.4] - 2026-11-11
6
+
7
+ ### Fixed
8
+
9
+ - Cool the managed key behind a fallback chain after a quota or rate failure, so the next turn switches to another key instead of reusing the one that just failed.
10
+
5
11
  ## [0.3.3] - 2026-11-11
6
12
 
7
13
  ### Changed
package/lib/index.js CHANGED
@@ -9012,6 +9012,7 @@ export class KeysManagerService {
9012
9012
  if (sessionId === undefined)
9013
9013
  return;
9014
9014
  const entry = {
9015
+ providerId,
9015
9016
  keyId,
9016
9017
  usedManagedKey,
9017
9018
  at: Date.now(),
@@ -9092,6 +9093,25 @@ export class KeysManagerService {
9092
9093
  }
9093
9094
  const record = this.store.provider(providerId);
9094
9095
  if (record === undefined || this.bindingState(record) === 'mismatch') {
9096
+ // A virtual route (FallbacksChain) has no provider row of its own, so the
9097
+ // payload's provider cannot attribute the failure. The linked attempt
9098
+ // names the real provider that served the inner request: cool that key so
9099
+ // the next turn stops reusing it, and keep the binding as it is. The
9100
+ // delegated action may be a retry, so the branch settles any projection
9101
+ // demotion the cooling queued before it hands the request on.
9102
+ const realProvider = linked?.providerId;
9103
+ if (linked?.usedManagedKey === true &&
9104
+ realProvider !== undefined &&
9105
+ linked.keyId !== undefined &&
9106
+ this.store.settings.autoSwitch &&
9107
+ shouldFailover(payload.failure?.code) &&
9108
+ this.store.provider(realProvider) !== undefined) {
9109
+ this.markFailure(realProvider, linked.keyId, payload.failure);
9110
+ // markFailure may have queued an OAuth projection demotion. A delegated
9111
+ // retry re-derives the projection, so waiting keeps the retry from
9112
+ // serving the grant that just failed — the managed path waits too.
9113
+ await this.settleProjectionDemotion(realProvider);
9114
+ }
9095
9115
  dropPin();
9096
9116
  return next();
9097
9117
  }