implement phase 5 และ fix bugs
This commit is contained in:
parent
f4b1c3e14b
commit
1bb850c6b8
40 changed files with 1507 additions and 429 deletions
|
|
@ -36,11 +36,17 @@ export function installFetchMock(
|
|||
return fetchMock;
|
||||
}
|
||||
|
||||
/** JWT ปลอมเพื่อ seed session — service อ่านแค่ claim `exp` */
|
||||
export function makeFakeJwt(expiresAtMs: number, subject = "user-1"): string {
|
||||
/** JWT ปลอมเพื่อ seed session — service อ่านแค่ claim `exp` / `sub` / `preferred_username` */
|
||||
export function makeFakeJwt(
|
||||
expiresAtMs: number,
|
||||
subject = "user-1",
|
||||
extraClaims: Record<string, unknown> = {}
|
||||
): string {
|
||||
const encode = (value: string): string =>
|
||||
btoa(value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
||||
const header = encode(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
||||
const payload = encode(JSON.stringify({ sub: subject, exp: Math.floor(expiresAtMs / 1000) }));
|
||||
const payload = encode(
|
||||
JSON.stringify({ sub: subject, exp: Math.floor(expiresAtMs / 1000), ...extraClaims })
|
||||
);
|
||||
return `${header}.${payload}.${encode("fake-signature")}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue