opencode-anthropic-multi-account 0.2.127 → 0.3.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/index.js +17 -22
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -929,6 +929,7 @@ var CredentialRefreshPatchSchema = v.object({
|
|
|
929
929
|
});
|
|
930
930
|
var StoredAccountSchema = v.object({
|
|
931
931
|
uuid: v.optional(v.string()),
|
|
932
|
+
credentialOwnerId: v.optional(v.string()),
|
|
932
933
|
accountId: v.optional(v.string()),
|
|
933
934
|
accountUuid: v.optional(v.string()),
|
|
934
935
|
deviceId: v.optional(v.string()),
|
|
@@ -1887,7 +1888,7 @@ async function checkAccountQuota(manager, account, client) {
|
|
|
1887
1888
|
}
|
|
1888
1889
|
const refreshResult = await manager.ensureValidToken(account.uuid, client);
|
|
1889
1890
|
if (!refreshResult.ok) {
|
|
1890
|
-
await manager.markAuthFailure(account.uuid, refreshResult);
|
|
1891
|
+
await manager.markAuthFailure(account.uuid, refreshResult, account);
|
|
1891
1892
|
await manager.refresh();
|
|
1892
1893
|
const updatedAccount = manager.getAccounts().find((candidate) => candidate.uuid === account.uuid);
|
|
1893
1894
|
if (!updatedAccount) {
|
|
@@ -3428,37 +3429,31 @@ var AccountRuntimeFactory = class {
|
|
|
3428
3429
|
if (latestAccessToken && accountToRefresh.expiresAt && !isTokenExpired({ accessToken: latestAccessToken, expiresAt: accountToRefresh.expiresAt })) {
|
|
3429
3430
|
return { accessToken: latestAccessToken, expiresAt: accountToRefresh.expiresAt };
|
|
3430
3431
|
}
|
|
3431
|
-
const
|
|
3432
|
-
|
|
3432
|
+
const { result, account: refreshedAccount } = await this.store.refreshAccountCredentials(
|
|
3433
|
+
uuid,
|
|
3434
|
+
accountToRefresh,
|
|
3435
|
+
(refreshTokenValue) => refreshToken(refreshTokenValue, uuid, this.client)
|
|
3436
|
+
);
|
|
3437
|
+
if (!result.ok) {
|
|
3433
3438
|
throw new TokenRefreshError(
|
|
3434
|
-
|
|
3435
|
-
|
|
3439
|
+
result.permanent,
|
|
3440
|
+
result.permanent ? TOKEN_REFRESH_PERMANENT_FAILURE_STATUS : void 0
|
|
3436
3441
|
);
|
|
3437
3442
|
}
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
if (refreshed.patch.refreshToken) account.refreshToken = refreshed.patch.refreshToken;
|
|
3442
|
-
if (refreshed.patch.uuid) account.uuid = refreshed.patch.uuid;
|
|
3443
|
-
if (refreshed.patch.accountId) account.accountId = refreshed.patch.accountId;
|
|
3444
|
-
if (refreshed.patch.accountUuid && !account.accountUuid) account.accountUuid = refreshed.patch.accountUuid;
|
|
3445
|
-
if (refreshed.patch.deviceId && !account.deviceId) account.deviceId = refreshed.patch.deviceId;
|
|
3446
|
-
if (refreshed.patch.email) account.email = refreshed.patch.email;
|
|
3447
|
-
account.consecutiveAuthFailures = 0;
|
|
3448
|
-
account.isAuthDisabled = false;
|
|
3449
|
-
account.authDisabledReason = void 0;
|
|
3450
|
-
});
|
|
3443
|
+
if (!refreshedAccount?.accessToken || !refreshedAccount.expiresAt) {
|
|
3444
|
+
throw new TokenRefreshError(false);
|
|
3445
|
+
}
|
|
3451
3446
|
this.client.auth.set({
|
|
3452
3447
|
path: { id: ANTHROPIC_OAUTH_ADAPTER.authProviderId },
|
|
3453
3448
|
body: {
|
|
3454
3449
|
type: "oauth",
|
|
3455
|
-
refresh:
|
|
3456
|
-
access:
|
|
3457
|
-
expires:
|
|
3450
|
+
refresh: refreshedAccount.refreshToken,
|
|
3451
|
+
access: refreshedAccount.accessToken,
|
|
3452
|
+
expires: refreshedAccount.expiresAt
|
|
3458
3453
|
}
|
|
3459
3454
|
}).catch(() => {
|
|
3460
3455
|
});
|
|
3461
|
-
return { accessToken:
|
|
3456
|
+
return { accessToken: refreshedAccount.accessToken, expiresAt: refreshedAccount.expiresAt };
|
|
3462
3457
|
}
|
|
3463
3458
|
buildOutboundHeaders(incomingHeaders, sessionId2, accessToken, modelId, excludedBetas2) {
|
|
3464
3459
|
const mergedBetas = deduplicateBetas(ensureOauthBeta([
|