// ../../adapters/trusted-header/src/trusted-header.ts
var KNOWN_ROLES = /* @__PURE__ */ new Set(["author", "developer", "admin"]);
function isRole(value) {
  return KNOWN_ROLES.has(value);
}
function trustedHeaderIdentity(config = {}) {
  const userIdHeader = config.userIdHeader ?? "X-Forwarded-User";
  const rolesHeader = config.rolesHeader ?? "X-Forwarded-Roles";
  return {
    async authenticate(getHeader) {
      const userId = getHeader(userIdHeader);
      if (userId === void 0 || userId === "") return null;
      const rolesRaw = getHeader(rolesHeader) ?? "";
      const roles = rolesRaw.split(",").map((r) => r.trim().toLowerCase()).filter(isRole);
      return { userId, username: userId, roles };
    }
  };
}
export {
  trustedHeaderIdentity
};
