@vacbo/opencode-anthropic-fix 0.0.39 → 0.0.41
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.
|
@@ -5563,8 +5563,8 @@ function buildAnthropicBillingHeader(claudeCliVersion, messages) {
|
|
|
5563
5563
|
if (firstUserMsg) {
|
|
5564
5564
|
const text = firstUserMsg.content;
|
|
5565
5565
|
const salt = "59cf53e54c78";
|
|
5566
|
-
const picked = [4, 7, 20].map((i) => i < text.length ? text[i] : "").join("");
|
|
5567
|
-
const hash = createHash2("sha256").update(salt + picked).digest("hex");
|
|
5566
|
+
const picked = [4, 7, 20].map((i) => i < text.length ? text[i] : "0").join("");
|
|
5567
|
+
const hash = createHash2("sha256").update(salt + picked + claudeCliVersion).digest("hex");
|
|
5568
5568
|
versionSuffix = `.${hash.slice(0, 3)}`;
|
|
5569
5569
|
}
|
|
5570
5570
|
}
|
package/package.json
CHANGED
|
@@ -207,12 +207,12 @@ describe("CC 2.1.98 — Billing header", () => {
|
|
|
207
207
|
const messages = [{ role: "user", content: "Hello world from a test" }];
|
|
208
208
|
const header = buildAnthropicBillingHeader(CC_VERSION, messages);
|
|
209
209
|
|
|
210
|
-
// Replicate the documented algorithm: SHA-256(salt + chars[4,7,20])
|
|
210
|
+
// Replicate the documented algorithm: SHA-256(salt + chars[4,7,20] + version)
|
|
211
211
|
const text = "Hello world from a test";
|
|
212
212
|
const salt = "59cf53e54c78";
|
|
213
|
-
const picked = [4, 7, 20].map((i) => (i < text.length ? text[i] : "")).join("");
|
|
213
|
+
const picked = [4, 7, 20].map((i) => (i < text.length ? text[i] : "0")).join("");
|
|
214
214
|
const expectedHash = createHash("sha256")
|
|
215
|
-
.update(salt + picked)
|
|
215
|
+
.update(salt + picked + CC_VERSION)
|
|
216
216
|
.digest("hex")
|
|
217
217
|
.slice(0, 3);
|
|
218
218
|
|
package/src/headers/billing.ts
CHANGED
|
@@ -19,9 +19,9 @@ export function buildAnthropicBillingHeader(claudeCliVersion: string, messages:
|
|
|
19
19
|
if (firstUserMsg) {
|
|
20
20
|
const text = firstUserMsg.content as string;
|
|
21
21
|
const salt = "59cf53e54c78";
|
|
22
|
-
const picked = [4, 7, 20].map((i) => (i < text.length ? text[i] : "")).join("");
|
|
22
|
+
const picked = [4, 7, 20].map((i) => (i < text.length ? text[i] : "0")).join("");
|
|
23
23
|
const hash = createHash("sha256")
|
|
24
|
-
.update(salt + picked)
|
|
24
|
+
.update(salt + picked + claudeCliVersion)
|
|
25
25
|
.digest("hex");
|
|
26
26
|
versionSuffix = `.${hash.slice(0, 3)}`;
|
|
27
27
|
}
|