It gets stuck in a login loop when clicked. This issue is actually in the interfaces component.
Suggested Fix
In magnifier-tool/index.js: drop the attachAuthentication / onProjectReady / CheckPermissions calls. The magnifier needs no project context and no auth — it operates purely on the imageElem it's handed.
New lifecycle:
connectedCallback() {
this.render()
this.addEventListeners()
}
disconnectedCallback() {
this.renderCleanup.run()
this.cleanup.run()
}
This kills the loop at the source and also makes MagnifierTool safely embeddable in any context (the workspace toolbar, Page-Viewer, future tools).
Additional Optional Fixes
components/simple-transcription/index.js:1146-1155 — don't call TPEN.login() from a postMessage handler.
#sendIdTokenToTool(targetWindow = ...) {
const idToken = TPEN.getAuthorization()
if (!idToken) {
TPEN.login() // <-- this nukes the parent window
return
}
...
}
Replace with a postMessage reply telling the tool no token is available, and let the tool decide what to do. Otherwise any future tool iframe that sends REQUEST_TPEN_ID_TOKEN while the parent's token is expired will trigger the same kind of redirect loop.
#sendIdTokenToTool(targetWindow = ...) {
const idToken = TPEN.getAuthorization()
if (!idToken) {
this.#postToTool({ type: 'TPEN_ID_TOKEN_UNAVAILABLE' }, targetWindow)
return
}
...
}
message-handler.js:55-57 — Page-Viewer is set up to receive REQUEST_TPEN_ID_TOKEN (a parent→tool message it would never get) rather than send it. The case is harmless but misleading. Either delete the case entirely, or replace it with a comment that Page-Viewer never sends or receives that message.
Not a bug — just dead code that sent me down the wrong trail earlier.
It gets stuck in a login loop when clicked. This issue is actually in the interfaces component.
Suggested Fix
In magnifier-tool/index.js: drop the attachAuthentication / onProjectReady / CheckPermissions calls. The magnifier needs no project context and no auth — it operates purely on the imageElem it's handed.
New lifecycle:
This kills the loop at the source and also makes MagnifierTool safely embeddable in any context (the workspace toolbar, Page-Viewer, future tools).
Additional Optional Fixes
components/simple-transcription/index.js:1146-1155 — don't call TPEN.login() from a postMessage handler.
Replace with a postMessage reply telling the tool no token is available, and let the tool decide what to do. Otherwise any future tool iframe that sends REQUEST_TPEN_ID_TOKEN while the parent's token is expired will trigger the same kind of redirect loop.
https://github.com/CenterForDigitalHumanities/Page-Viewer Minor Cleanup
message-handler.js:55-57 — Page-Viewer is set up to receive REQUEST_TPEN_ID_TOKEN (a parent→tool message it would never get) rather than send it. The case is harmless but misleading. Either delete the case entirely, or replace it with a comment that Page-Viewer never sends or receives that message.
Not a bug — just dead code that sent me down the wrong trail earlier.