Skip to content

Commit efafbb9

Browse files
committed
feat: update fingerprint versioning to match current runtime version
1 parent d8b5ff8 commit efafbb9

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-antigravity-auth",
3-
"version": "1.5.4",
3+
"version": "1.5.5",
44
"description": "Google Antigravity IDE OAuth auth plugin for Opencode - access Gemini 3 Pro and Claude 4.6 using Google credentials",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/plugin/accounts.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { loadAccounts, saveAccounts, type AccountStorageV4, type AccountMetadata
33
import type { OAuthAuthDetails, RefreshParts } from "./types";
44
import type { AccountSelectionStrategy } from "./config/schema";
55
import { getHealthTracker, getTokenTracker, selectHybridAccount, type AccountWithMetrics } from "./rotation";
6-
import { generateFingerprint, type Fingerprint, type FingerprintVersion, MAX_FINGERPRINT_HISTORY } from "./fingerprint";
6+
import { generateFingerprint, updateFingerprintVersion, type Fingerprint, type FingerprintVersion, MAX_FINGERPRINT_HISTORY } from "./fingerprint";
77
import type { QuotaGroup, QuotaGroupSummary } from "./quota";
88
import { getModelFamily } from "./transform/model-resolver";
99
import { debugLogToFile } from "./debug";
@@ -371,6 +371,16 @@ export class AccountManager {
371371
})
372372
.filter((a): a is ManagedAccount => a !== null);
373373

374+
// Update fingerprint versions to match the current runtime version.
375+
// Saved fingerprints may carry an older version string; this ensures
376+
// they always reflect the latest fetched (or fallback) version.
377+
let fingerprintVersionChanged = false;
378+
for (const acc of this.accounts) {
379+
if (acc.fingerprint && updateFingerprintVersion(acc.fingerprint)) {
380+
fingerprintVersionChanged = true;
381+
}
382+
}
383+
374384
this.cursor = clampNonNegativeInt(stored.activeIndex, 0);
375385
if (this.accounts.length > 0) {
376386
this.cursor = this.cursor % this.accounts.length;
@@ -385,6 +395,11 @@ export class AccountManager {
385395
) % this.accounts.length;
386396
}
387397

398+
// Persist updated fingerprint versions to disk
399+
if (fingerprintVersionChanged) {
400+
this.requestSaveToDisk();
401+
}
402+
388403
return;
389404
}
390405

src/plugin/fingerprint.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ export function collectCurrentFingerprint(): Fingerprint {
137137
};
138138
}
139139

140+
/**
141+
* Update the version in a fingerprint's userAgent to match the current runtime version.
142+
* Called after version fetcher resolves so saved fingerprints always carry the latest version.
143+
* Returns true if the userAgent was changed.
144+
*/
145+
export function updateFingerprintVersion(fingerprint: Fingerprint): boolean {
146+
const currentVersion = getAntigravityVersion();
147+
const versionPattern = /^(antigravity\/)([\d.]+)/;
148+
const match = fingerprint.userAgent.match(versionPattern);
149+
150+
if (!match || match[2] === currentVersion) {
151+
return false;
152+
}
153+
154+
fingerprint.userAgent = fingerprint.userAgent.replace(versionPattern, `$1${currentVersion}`);
155+
return true;
156+
}
157+
140158
/**
141159
* Build HTTP headers from a fingerprint object.
142160
* These headers are used to identify the "device" making API requests.

0 commit comments

Comments
 (0)