- 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
21 lines
616 B
TypeScript
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;
|
|
};
|