aps-agent/server/entry/dev-identity.ts

20 lines
771 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* A1 阶段的临时身份解析:固定一个开发用户。
*
* A4.1 身份上下文落地后,这里换成:浏览器读 JMS 会话 Cookie、桌面端读授权令牌,
* 两者都解析成同一个 Subject(协议文档第 3 节)。现在不校验任何凭据,只区分客户端形态。
*/
import type { IncomingHttpHeaders } from 'node:http';
import type { Subject } from '../app/subject.js';
export function resolveSubject(headers: IncomingHttpHeaders): Subject {
const raw = headers['x-aps-client'];
const clientKind = String(Array.isArray(raw) ? raw[0] : (raw ?? '')).toLowerCase() === 'desktop' ? 'desktop' : 'browser';
return {
userId: 'dev-user',
tenantId: 'dev-tenant',
displayName: '开发用户',
clientKind,
};
}