Files
EasyCLIProxyAPI/src/services/devinOAuth.ts
T
lzt404 0c37f4d1bb feat(providers): add Devin OAuth and quota support
- Add Devin login to standard and simplified modes
- Support credentials, model aliases, and exclusions
- Display daily and weekly quotas with reset times
- Validate callbacks and prevent stale login updates
- Add translations, theme support, and integration tests
2026-09-15 02:39:03 +08:00

21 lines
616 B
TypeScript

export const validateDevinCallback = (
input: string,
expectedState?: string,
): 'invalid' | 'state_mismatch' | undefined => {
let url: URL;
try {
url = new URL(input.trim());
} catch {
return 'invalid';
}
const params = url.searchParams;
if (!['http:', 'https:'].includes(url.protocol)
|| params.getAll('state').length !== 1
|| !params.get('state')?.trim()
|| !['code', 'error', 'error_description'].some((key) => params.get(key)?.trim())) {
return 'invalid';
}
if (!expectedState || params.get('state') !== expectedState) return 'state_mismatch';
return undefined;
};