实现账号绑定、持久登录与跨设备对局恢复
CI / test (ubuntu-latest, node 22) (push) Failing after 33m10s
CI / test (ubuntu-latest, node 24) (push) Failing after 34m41s
CI / tooling (lint, imports, typecheck) (push) Failing after 36m11s
CI / test (windows-latest, node 22) (push) Canceled after 0s
CI / test (windows-latest, node 24) (push) Canceled after 0s
CI / test (ubuntu-latest, node 22) (push) Failing after 33m10s
CI / test (ubuntu-latest, node 24) (push) Failing after 34m41s
CI / tooling (lint, imports, typecheck) (push) Failing after 36m11s
CI / test (windows-latest, node 22) (push) Canceled after 0s
CI / test (windows-latest, node 24) (push) Canceled after 0s
This commit is contained in:
1 parent
488db49f11
commit
7c25c89992
62 files changed
+6855
-1005
No files matched your search
@@ -0,0 +1,22 @@
|
||||
// Account recovery describes only the selected role's live server-side seat. It never reads browser caches.
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
export function createAccountRecovery({ registry, lobby }) {
|
||||
const roomIds = new WeakMap();
|
||||
return {
|
||||
describe(playerId) {
|
||||
const session = playerId && registry.byId(playerId);
|
||||
if (!session || registry.isExpired(session, registry.now())) return null;
|
||||
const room = lobby.roomOf(session);
|
||||
if (!room || room.disposed) return null;
|
||||
if (!roomIds.has(room)) roomIds.set(room, randomUUID());
|
||||
return {
|
||||
// A selector, not a credential: a replaced room or a later match must not satisfy a stale recovery request.
|
||||
id: roomIds.get(room) + ':' + room.matchCount,
|
||||
name: session.name, code: room.code, mode: room.mode, difficulty: room.difficulty,
|
||||
inMatch: !!room.match, round: room.match?.round ?? 0,
|
||||
connected: session.connected, spectating: !!room.spectatorOf(playerId),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user