@better-auth/cimd 1.7.3 → 1.7.5

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.d.mts CHANGED
@@ -24,10 +24,10 @@ interface CimdClientRefreshedEvent {
24
24
  }
25
25
  interface CimdMetadataFetchPolicy {
26
26
  /**
27
- * Minimum time between metadata fetch starts for one exact client ID.
28
- * Fresh-cache hits and callers joining an in-flight fetch do not consume
29
- * this interval. Numeric values are seconds. Set to `0` to disable
30
- * per-client pacing.
27
+ * Minimum time before retrying a failed metadata fetch for one exact client
28
+ * ID. Successful fetches are governed by HTTP freshness and the origin/global
29
+ * fetch budgets. Numeric values are seconds. Set to `0` to disable failed-fetch
30
+ * pacing.
31
31
  *
32
32
  * @default 1
33
33
  */
package/dist/index.mjs CHANGED
@@ -605,6 +605,7 @@ function createCimdResolver(cimdOptions) {
605
605
  while (lastFetchStartAtMsByClientId.size >= maxCacheEntries) {
606
606
  let evicted = false;
607
607
  for (const [candidateClientId, candidateLastFetchStartAtMs] of lastFetchStartAtMsByClientId) {
608
+ if (inFlightResolutionByClientId.has(candidateClientId)) continue;
608
609
  if (fetchPolicy.minimumFetchIntervalMs > 0 && nowMs - candidateLastFetchStartAtMs < fetchPolicy.minimumFetchIntervalMs) continue;
609
610
  lastFetchStartAtMsByClientId.delete(candidateClientId);
610
611
  evicted = true;
@@ -692,11 +693,16 @@ function createCimdResolver(cimdOptions) {
692
693
  const nextEntry = createCacheEntry(metadata, fetched.status === "modified" ? fetched.cacheHeaders : mergeCacheHeaders(cachedEntry.responseCacheHeaders, fetched.cacheHeaders), metadataRevalidationInterval, Date.now());
693
694
  if (nextEntry) storeCacheEntry(clientId, nextEntry);
694
695
  else metadataCache.delete(clientId);
696
+ lastFetchStartAtMsByClientId.delete(clientId);
695
697
  return storedClient;
696
698
  })();
697
699
  inFlightResolutionByClientId.set(clientId, resolution);
698
700
  try {
699
701
  return await resolution;
702
+ } catch (error) {
703
+ lastFetchStartAtMsByClientId.delete(clientId);
704
+ lastFetchStartAtMsByClientId.set(clientId, Date.now());
705
+ throw error;
700
706
  } finally {
701
707
  if (inFlightResolutionByClientId.get(clientId) === resolution) inFlightResolutionByClientId.delete(clientId);
702
708
  releaseMetadataFetchPermit();
@@ -705,7 +711,7 @@ function createCimdResolver(cimdOptions) {
705
711
  }
706
712
  //#endregion
707
713
  //#region src/version.ts
708
- const PACKAGE_VERSION = "1.7.3";
714
+ const PACKAGE_VERSION = "1.7.5";
709
715
  //#endregion
710
716
  //#region src/index.ts
711
717
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/cimd",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "Client ID Metadata Document plugin for Better Auth",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -58,16 +58,16 @@
58
58
  "@modelcontextprotocol/server": "2.0.0",
59
59
  "listhen": "^1.9.0",
60
60
  "tsdown": "0.21.10",
61
- "@better-auth/core": "1.7.3",
62
- "@better-auth/mcp": "1.7.3",
63
- "@better-auth/oauth-provider": "1.7.3",
64
- "better-auth": "1.7.3"
61
+ "@better-auth/core": "1.7.5",
62
+ "@better-auth/mcp": "1.7.5",
63
+ "@better-auth/oauth-provider": "1.7.5",
64
+ "better-auth": "1.7.5"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "better-call": "1.4.0",
68
- "@better-auth/core": "^1.7.3",
69
- "@better-auth/oauth-provider": "^1.7.3",
70
- "better-auth": "^1.7.3"
68
+ "@better-auth/core": "^1.7.5",
69
+ "@better-auth/oauth-provider": "^1.7.5",
70
+ "better-auth": "^1.7.5"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",