@askalf/dario 2.8.6 → 2.8.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.
- package/dist/proxy.js +6 -9
- package/package.json +1 -1
package/dist/proxy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
|
-
import { randomUUID, timingSafeEqual, createHash } from 'node:crypto';
|
|
2
|
+
import { randomUUID, randomBytes, timingSafeEqual, createHash } from 'node:crypto';
|
|
3
3
|
import { execSync, spawn } from 'node:child_process';
|
|
4
4
|
import { readFileSync, readdirSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
5
5
|
import { join } from 'node:path';
|
|
@@ -43,12 +43,10 @@ function computeBuildTag(userMessage, version) {
|
|
|
43
43
|
const chars = [4, 7, 20].map(i => userMessage[i] || '0').join('');
|
|
44
44
|
return createHash('sha256').update(`${BILLING_SEED}${chars}${version}`).digest('hex').slice(0, 3);
|
|
45
45
|
}
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const chars = [4, 7, 20].map(i => userMessage[i] || '0').join('');
|
|
51
|
-
return createHash('sha256').update(`${BILLING_SEED}${version}${chars}`).digest('hex').slice(0, 5);
|
|
46
|
+
// Per-request cch: real Claude Code generates a random 5-char hex value each request.
|
|
47
|
+
// Confirmed via MITM: 10 identical requests → 10 unique cch values, no deterministic pattern.
|
|
48
|
+
function computeCch() {
|
|
49
|
+
return randomBytes(3).toString('hex').slice(0, 5);
|
|
52
50
|
}
|
|
53
51
|
// Detect installed Claude Code binary at startup (single exec for both version + availability)
|
|
54
52
|
let cliAvailable = false;
|
|
@@ -715,7 +713,7 @@ export async function startProxy(opts = {}) {
|
|
|
715
713
|
// Build per-request billing tag matching Claude Code binary
|
|
716
714
|
const userMsg = extractFirstUserMessage(r);
|
|
717
715
|
const buildTag = computeBuildTag(userMsg, cliVersion);
|
|
718
|
-
const cch = computeCch(
|
|
716
|
+
const cch = computeCch();
|
|
719
717
|
const fullVersion = `${cliVersion}.${buildTag}`;
|
|
720
718
|
const billingTag = `x-anthropic-billing-header: cc_version=${fullVersion}; cc_entrypoint=cli; cch=${cch};`;
|
|
721
719
|
// Structure system prompt as 3 blocks matching real Claude Code:
|
|
@@ -778,7 +776,6 @@ export async function startProxy(opts = {}) {
|
|
|
778
776
|
'Authorization': `Bearer ${accessToken}`,
|
|
779
777
|
'anthropic-version': req.headers['anthropic-version'] || '2023-06-01',
|
|
780
778
|
'anthropic-beta': beta,
|
|
781
|
-
'x-client-request-id': randomUUID(),
|
|
782
779
|
// Real Claude Code sends 600 on first request, 300 on subsequent
|
|
783
780
|
'x-stainless-timeout': requestCount <= 1 ? '600' : '300',
|
|
784
781
|
};
|