Implement frontend session routing flow

- Validate and prepare access links in apps/frontend
- Add session, ended, and unauthorized routes with polling
- Copy full public access URLs from the admin links page
This commit is contained in:
user
2026-03-28 19:10:24 +02:00
parent 31a501f75b
commit 92deee1b2e
16 changed files with 392 additions and 119 deletions

View File

@@ -1,8 +1,3 @@
import { errAsync, ResultAsync } from "neverthrow";
import { nanoid } from "nanoid";
import { db } from "@pkg/db";
import { type Err } from "@pkg/result";
import { FlowExecCtx } from "@core/flow.execution.context";
import {
CreateLink,
Link,
@@ -10,8 +5,13 @@ import {
LinkWithDevice,
UpdateLink,
} from "./data";
import { FlowExecCtx } from "@core/flow.execution.context";
import { errAsync, ResultAsync } from "neverthrow";
import { LinkRepository } from "./repository";
import { type Err } from "@pkg/result";
import { linkErrors } from "./errors";
import { nanoid } from "nanoid";
import { db } from "@pkg/db";
export class LinkController {
constructor(private repo: LinkRepository) {}
@@ -26,9 +26,12 @@ export class LinkController {
/**
* Fetch a link by its URL token, including the joined device.
* Used by apps/front to validate and resolve an incoming link.
* Used by apps/frontend to validate and resolve an incoming link.
*/
getByToken(fctx: FlowExecCtx, token: string): ResultAsync<LinkWithDevice, Err> {
getByToken(
fctx: FlowExecCtx,
token: string,
): ResultAsync<LinkWithDevice, Err> {
return this.repo.getByToken(fctx, token);
}
@@ -36,7 +39,10 @@ export class LinkController {
* Validate a token: must exist, be active, and not be expired.
* Returns the resolved link+device on success.
*/
validate(fctx: FlowExecCtx, token: string): ResultAsync<LinkWithDevice, Err> {
validate(
fctx: FlowExecCtx,
token: string,
): ResultAsync<LinkWithDevice, Err> {
return this.repo.getByToken(fctx, token).andThen((l) => {
if (l.status !== LinkStatus.ACTIVE) {
return errAsync(linkErrors.linkNotActive(fctx, token));