实现账号绑定、持久登录与跨设备对局恢复
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
@@ -141,3 +141,24 @@ test('live token ownership survives a duplicated tab, reload and reconnect', { t
|
||||
assert.equal(welcome.playerId, a.welcome.playerId);
|
||||
await assertOnline(h, [a2, b]);
|
||||
});
|
||||
|
||||
|
||||
test('explicit account tokens are tentative until welcome and do not overwrite the last established local identity', async () => {
|
||||
const old = '1'.repeat(32), selected = '2'.repeat(32), attached = '3'.repeat(32);
|
||||
const local = storage(), session = storage({ 'sp.token': old });
|
||||
const id = createIdentity({ local, session, channel: null });
|
||||
await id.init();
|
||||
id.saveToken(old);
|
||||
assert.equal(id.stageToken(selected), true);
|
||||
assert.equal(id.getToken(), selected);
|
||||
assert.deepEqual(id.getTokenClaim(), { noReplace: false });
|
||||
assert.equal(session.getItem('sp.token'), old);
|
||||
assert.deepEqual(JSON.parse(local.getItem('sp.tokens')), [old]);
|
||||
assert.equal(id.stageToken(''), false);
|
||||
assert.equal(id.getToken(), selected);
|
||||
id.saveToken(attached);
|
||||
assert.equal(session.getItem('sp.token'), attached);
|
||||
assert.equal(id.getToken(), attached);
|
||||
assert.ok(Number.isFinite(id.getTokenClaim().claimAt));
|
||||
assert.equal(JSON.parse(local.getItem('sp.tokens')).includes(selected), false, 'only the rotated welcome token is remembered');
|
||||
});
|
||||
Reference in new issue
Block a user