mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
feat(api): remove Flutter client auth gates (#1513)
This commit is contained in:
1 parent
6a23ec30c6
commit
ec1182d34d
9 files changed
+4
-117
No files matched your search
@@ -2,15 +2,12 @@
|
||||
|
||||
import Bowser from 'bowser';
|
||||
import {Logger} from '../Logger';
|
||||
import {parseJsonRecord} from './JsonBoundaryUtils';
|
||||
|
||||
interface UserAgentInfo {
|
||||
clientOs: string;
|
||||
detectedPlatform: string;
|
||||
}
|
||||
|
||||
type FluxerClientProperties = Record<string, unknown>;
|
||||
|
||||
const UNKNOWN_LABEL = 'Unknown';
|
||||
|
||||
function formatName(name?: string | null): string {
|
||||
@@ -33,57 +30,6 @@ function parseUserAgentSafe(userAgentRaw: string): UserAgentInfo {
|
||||
}
|
||||
}
|
||||
|
||||
export function isFluxerFlutterClient(request: Request): boolean {
|
||||
const parsed = parseFluxerClientProperties(request);
|
||||
return parsed?.client_runtime === 'flutter';
|
||||
}
|
||||
|
||||
export function isFluxerFlutterAndroidClient(request: Request): boolean {
|
||||
return isFluxerFlutterPlatformClient(request, 'android');
|
||||
}
|
||||
|
||||
export function isFluxerFlutterIosClient(request: Request): boolean {
|
||||
return (
|
||||
isFluxerFlutterPlatformClient(request, 'ios') ||
|
||||
isFluxerFlutterPlatformClient(request, 'iphone') ||
|
||||
isFluxerFlutterPlatformClient(request, 'ipad') ||
|
||||
isFluxerFlutterPlatformClient(request, 'ipod')
|
||||
);
|
||||
}
|
||||
|
||||
function isFluxerFlutterPlatformClient(request: Request, platform: string): boolean {
|
||||
const platformCandidates = getFluxerFlutterPlatformCandidates(request);
|
||||
if (!platformCandidates) return false;
|
||||
const needle = platform.toLowerCase();
|
||||
return platformCandidates.some((value) => typeof value === 'string' && value.toLowerCase().includes(needle));
|
||||
}
|
||||
|
||||
function getFluxerFlutterPlatformCandidates(request: Request): Array<unknown> | null {
|
||||
const parsed = parseFluxerClientProperties(request);
|
||||
if (parsed?.client_runtime !== 'flutter') return null;
|
||||
return [
|
||||
parsed.client_os,
|
||||
parsed.os,
|
||||
parsed.operating_system,
|
||||
parsed.platform,
|
||||
parsed.device_platform,
|
||||
parsed.client_platform,
|
||||
parsed.user_agent,
|
||||
request.headers.get('user-agent'),
|
||||
];
|
||||
}
|
||||
|
||||
function parseFluxerClientProperties(request: Request): FluxerClientProperties | null {
|
||||
const encoded = request.headers.get('x-fluxer-client-properties');
|
||||
if (!encoded) return null;
|
||||
try {
|
||||
const decoded = Buffer.from(encoded, 'base64').toString('utf8');
|
||||
return parseJsonRecord(decoded);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveSessionClientInfo(args: {userAgent: string | null; isDesktopClient: boolean | null}): {
|
||||
clientOs: string;
|
||||
clientPlatform: string;
|
||||
|
||||
Reference in new issue
Block a user