add-in: request docver token via /api/auth/token (short path)
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m22s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 5s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s

- ticketService.requestDocverToken fetches withBasePath("/api/auth/token")
  instead of /api/documents/token — same handler, shorter URL
- update referencing comments in authService/apiClient/config
- ticket-auth-flow test now asserts the actual URL hit, guarding a silent
  revert to the old path
- versioning endpoints (/api/documents/versions*) unchanged — no short-path
  equivalents exist

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Suphonchai Phoonsawat 2026-11-05 13:18:35 +07:00
parent 545c9d5703
commit 3162b0d947
5 changed files with 14 additions and 10 deletions

View file

@ -4,7 +4,8 @@
* - session store: localStorage key เดียว `wordaddin-auth` — userId/userName +
* map token ต่อ fid · webview block localStorage = fallback memory ต่อ session
* (pattern เดียวกับ versioningService)
* - requestDocverToken: POST same-origin /api/documents/token แบบ body ticket —
* - requestDocverToken: POST same-origin /api/auth/token แบบ body ticket
* (path สั้นของ /api/documents/token — endpoint ก้อนเดียวกัน เปลี่ยนมาใช้ 2026-11-05) —
* ไม่ผูกกับ config.apiBaseUrl (endpoint อยู่แอปนี้ ใช้ได้ทั้งช่วง mock และจริง) ·
* คืน discriminated result แยก network/http status/malformed ให้ caller
* ตัดสินตาม contract 400/401/403 (2026-11-04)
@ -93,7 +94,7 @@ export function isTokenExpired(entry: SessionTokenEntry): boolean {
}
// ---------------------------------------------------------------------------
// ขอ token จาก /api/documents/token (ทางเข้า ticket — PLAN-ADDIN-AUTH.md §3)
// ขอ token จาก /api/auth/token (ทางเข้า ticket — PLAN-ADDIN-AUTH.md §3)
// ---------------------------------------------------------------------------
interface TokenResponse {
@ -129,7 +130,7 @@ export type RequestDocverTokenResult =
/**
* ขอ access_token ด้วย ticket — คืน discriminated result ไม่โยน Error:
* caller (authService) แยกทางตาม contract ของทางเข้า ticket ของ
* /api/documents/token (2026-11-04: 200 ผ่าน / 400 ฟอร์แม็ต / 401 ลายเซ็น /
* /api/auth/token (2026-11-04: 200 ผ่าน / 400 ฟอร์แม็ต / 401 ลายเซ็น /
* 403 ลายเซ็นถูกแต่ ticket หมดอายุ — มี JWT เดิมของ fid ใน session ใช้ต่อได้)
*/
export async function requestDocverToken(
@ -138,7 +139,7 @@ export async function requestDocverToken(
): Promise<RequestDocverTokenResult> {
let response: Response;
try {
response = await fetch(withBasePath("/api/documents/token"), {
response = await fetch(withBasePath("/api/auth/token"), {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ ticket_data: ticketData, HmacSha256: ticketHmac }),