diff --git a/apps/collab/src/auth.test.ts b/apps/collab/src/auth.test.ts index 457e5fc..8d9de9e 100644 --- a/apps/collab/src/auth.test.ts +++ b/apps/collab/src/auth.test.ts @@ -108,8 +108,12 @@ describe('collab authentication', () => { name: 'page-x', token: async () => { const [h, p, s = ''] = (await signCollabToken(claims, secret, 60)).split('.'); - // Flip the last character of the signature. - const flipped = s.slice(0, -1) + (s.endsWith('A') ? 'B' : 'A'); + // Flip the FIRST signature character — its bits are all significant. + // The last character is not: its low bits are base64url padding that + // decoders ignore, so a last-char flip of a signature ending in 'A' + // decodes to the same bytes and verifies (jose compares decoded + // bytes, unlike the pre-#188 code that compared encoded strings). + const flipped = (s.startsWith('A') ? 'B' : 'A') + s.slice(1); return `${h}.${p}.${flipped}`; }, },