fix(auth): atomically exchange gateway tokens

This commit is contained in:
2026-07-31 18:00:07 +00:00
parent 2596c47fc5
commit c29b40ba5a
4 changed files with 112 additions and 21 deletions
+6 -8
View File
@@ -309,8 +309,7 @@ describe('appRouter', () => {
throw new Error('ordinary exchange must not read the icon source');
});
const accessTokenStore = {
markGatewayTokenUsed: vi.fn(async () => true),
create: vi.fn(async () => ({
issueFromGateway: vi.fn(async () => ({
accessToken: 'ga_access',
expiresAt: '2099-01-01T01:00:00.000Z',
})),
@@ -342,14 +341,13 @@ describe('appRouter', () => {
const calls: string[] = [];
const revision = '2099-01-01T00:00:00.001Z';
const accessTokenStore = {
markGatewayTokenUsed: vi.fn(async () => {
issueFromGateway: vi.fn(async () => {
calls.push('mark-used');
return true;
return {
accessToken: 'ga_access',
expiresAt: '2099-01-01T01:00:00.000Z',
};
}),
create: vi.fn(async () => ({
accessToken: 'ga_access',
expiresAt: '2099-01-01T01:00:00.000Z',
})),
} as unknown as RedisAccessTokenStore;
const payload = buildAuth();
payload.issuedAt = '2099-01-01T00:00:00.000Z';