[FIX]: tokenType까지 검사하여 OAuth Flow인지 확인

This commit is contained in:
KMINGON 2025-06-04 17:01:32 +09:00
commit 1bc442b1d3

View file

@ -151,7 +151,26 @@ private extractTokenFromText(text: string): string | null {
'session_token'
];
// 정규표현식 패턴 리스트 생성
const tokenTypeKeys = [
'token_type',
'tokenType'
];
// 정규표현식 토큰 타입 유무 패턴 리스트 생성
const tokenTypeRegexes: RegExp[] = [];
for (const key of tokenTypeKeys) {
// JSON 형식: "token_type": "Bearer"
tokenTypeRegexes.push(new RegExp(`"${key}"\\s*:\\s*"bearer"`, 'i'));
// 일반 key=value 형식: token_type=Bearer
tokenTypeRegexes.push(new RegExp(`${key}[=:]\\s*bearer`, 'i'));
// 공백 있는 형식: token_type : Bearer
tokenTypeRegexes.push(new RegExp(`${key}\\s*:\\s*bearer`, 'i'));
}
// token_type=bearer 형태 중 하나라도 포함되는지 확인
const hasTokenTypeBearer = tokenTypeRegexes.some(rx => rx.test(text));
// 정규표현식 토큰 유무 패턴 리스트 생성
const tokenPatterns: RegExp[] = [];
for (const key of tokenKeys) {
@ -169,9 +188,11 @@ private extractTokenFromText(text: string): string | null {
for (const pattern of tokenPatterns) {
const match = pattern.exec(text);
if (match && match[1]) {
if(hasTokenTypeBearer){
return match[1];
}
}
}
return null;
}