fix(hocuspocus): include useful information in token validation errors (#22403)

Port of https://github.com/opf/op-blocknote-hocuspocus/pull/55

Co-authored-by: Markus Kahl <m.kahl@openproject.com>
This commit is contained in:
Kabiru Mwenja
2026-03-18 17:56:03 +03:00
committed by GitHub
parent c9d6a1df40
commit 8e7bca3b14
@@ -25,11 +25,11 @@ export async function decryptAndValidateToken(
} = decryptToken(encryptedToken);
if (requestOrigin && !tokenResourceUrl?.startsWith(requestOrigin)) {
throw new Error('Unauthorized: Token origin does not match request origin.');
throw new Error(`Unauthorized: Token origin does not match request origin. Expected ${tokenResourceUrl} to start with ${requestOrigin}.`);
}
if (tokenResourceUrl !== resourceUrl) {
throw new Error('Unauthorized: Token resource URL does not match document.');
throw new Error(`Unauthorized: Token resource URL does not match document. Expected ${tokenResourceUrl}, got ${resourceUrl}.`);
}
const response = await fetchResource(resourceUrl, oauth_token);