create token where the current document is located?

Hello,
is it possible to create a session token / persistent token where the current document is located?

For example:
const docPath = app.activeDocument.path;
const docPathShort = docPath.substr(0,docPath.lastIndexOf("/"));
localStorage.setItem(“session-token”, await fs.createSessionToken(docPathShort));

Thank you guys for your help.
Best regards