@cortexkit/anthropic-auth-core 1.6.1 → 1.7.0

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/cch.d.ts CHANGED
@@ -24,12 +24,11 @@ export declare function signRequestBody(bodyString: string): Promise<string>;
24
24
  /**
25
25
  * Compute a stable 3-character suffix for cc_version.
26
26
  *
27
- * The previous implementation sampled the first user message, which could make
28
- * the system billing header change with conversation content. Keep this suffix
29
- * stable for a day so it resembles a rotating Claude Code fingerprint without
30
- * busting prompt-cache prefixes on every turn.
27
+ * The captured Claude Code version uses its observed build hash. Custom/future
28
+ * versions get a deterministic version-only suffix so date changes never rotate
29
+ * the billing header and bust prompt-cache prefixes.
31
30
  */
32
- export declare function computeVersionSuffix(version?: string, date?: Date): string;
31
+ export declare function computeVersionSuffix(version?: string, _date?: Date): string;
33
32
  /**
34
33
  * Build the billing header with a cch placeholder.
35
34
  * signRequestBody() must run after final request serialization to replace it.
package/dist/cch.js CHANGED
@@ -62,19 +62,14 @@ export async function signRequestBody(bodyString) {
62
62
  /**
63
63
  * Compute a stable 3-character suffix for cc_version.
64
64
  *
65
- * The previous implementation sampled the first user message, which could make
66
- * the system billing header change with conversation content. Keep this suffix
67
- * stable for a day so it resembles a rotating Claude Code fingerprint without
68
- * busting prompt-cache prefixes on every turn.
65
+ * The captured Claude Code version uses its observed build hash. Custom/future
66
+ * versions get a deterministic version-only suffix so date changes never rotate
67
+ * the billing header and bust prompt-cache prefixes.
69
68
  */
70
- export function computeVersionSuffix(version = CLAUDE_CODE_VERSION, date = new Date()) {
69
+ export function computeVersionSuffix(version = CLAUDE_CODE_VERSION, _date = new Date()) {
71
70
  if (version === CLAUDE_CODE_VERSION)
72
71
  return CLAUDE_CODE_BUILD_HASH;
73
- const dayStamp = date.toISOString().slice(0, 10);
74
- return createHash('sha256')
75
- .update(`${dayStamp}${version}`)
76
- .digest('hex')
77
- .slice(0, 3);
72
+ return createHash('sha256').update(version).digest('hex').slice(0, 3);
78
73
  }
79
74
  /**
80
75
  * Build the billing header with a cch placeholder.
package/dist/dump.js CHANGED
@@ -78,6 +78,15 @@ export function executeDumpCommand(input) {
78
78
  function shortAffinity(affinity) {
79
79
  return affinity.length <= 16 ? affinity : `${affinity.slice(0, 12)}…`;
80
80
  }
81
+ function dumpFileSessionSegment(affinity) {
82
+ const normalized = affinity
83
+ .trim()
84
+ .replace(/[^a-zA-Z0-9._-]+/g, '-')
85
+ .replace(/^-+|-+$/g, '');
86
+ if (!normalized)
87
+ return 'session-unknown';
88
+ return normalized.length <= 80 ? normalized : normalized.slice(0, 80);
89
+ }
81
90
  function hashText(value) {
82
91
  return createHash('sha256').update(value).digest('hex');
83
92
  }
@@ -184,7 +193,7 @@ export async function dumpRelayRequest(input) {
184
193
  if (!dumpEnabled)
185
194
  return;
186
195
  nextDumpId += 1;
187
- const id = `${new Date().toISOString().replace(/[:.]/g, '-')}-${String(nextDumpId).padStart(5, '0')}-${input.transport}-p${input.protocol}-${input.mode}`;
196
+ const id = `${new Date().toISOString().replace(/[:.]/g, '-')}-${String(nextDumpId).padStart(5, '0')}-${dumpFileSessionSegment(input.affinity)}-${input.transport}-p${input.protocol}-${input.mode}`;
188
197
  const dumpDir = getDumpDirectory();
189
198
  const prefix = join(dumpDir, id);
190
199
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",