Browse Source

fix(api): reorder methods

pull/8478/head
KenTandrian 2 days ago
parent
commit
f7a4c2c143
  1. 26
      apps/api/src/app/endpoints/oauth/oauth-client.service.ts
  2. 24
      apps/api/src/app/endpoints/oauth/oauth-storage.service.ts

26
apps/api/src/app/endpoints/oauth/oauth-client.service.ts

@ -77,6 +77,19 @@ export class OAuthClientService {
}); });
} }
private isValidRedirectUri(uri: unknown): uri is string {
if (typeof uri !== 'string') {
return false;
}
try {
const parsed = new URL(uri);
return !parsed.hash;
} catch {
return false;
}
}
private matchesLoopbackRedirectUri( private matchesLoopbackRedirectUri(
registeredUri: string, registeredUri: string,
requestedUrl: URL requestedUrl: URL
@ -184,19 +197,6 @@ export class OAuthClientService {
}; };
} }
private isValidRedirectUri(uri: unknown): uri is string {
if (typeof uri !== 'string') {
return false;
}
try {
const parsed = new URL(uri);
return !parsed.hash;
} catch {
return false;
}
}
private parseStringArray(value: unknown, fieldName: string): string[] { private parseStringArray(value: unknown, fieldName: string): string[] {
if ( if (
!Array.isArray(value) || !Array.isArray(value) ||

24
apps/api/src/app/endpoints/oauth/oauth-storage.service.ts

@ -12,18 +12,6 @@ export class OAuthStorageService {
public constructor(private readonly redisCacheService: RedisCacheService) {} public constructor(private readonly redisCacheService: RedisCacheService) {}
public async storeAuthorizationCode(
code: string,
data: OAuthAuthorizationCode,
ttlMs: number = OAuthStorageService.DEFAULT_TTL_MS
): Promise<void> {
await this.redisCacheService.set(
this.getCodeKey(code),
JSON.stringify(data),
ttlMs
);
}
public async consumeAuthorizationCode( public async consumeAuthorizationCode(
code: string code: string
): Promise<OAuthAuthorizationCode | null> { ): Promise<OAuthAuthorizationCode | null> {
@ -43,6 +31,18 @@ export class OAuthStorageService {
} }
} }
public async storeAuthorizationCode(
code: string,
data: OAuthAuthorizationCode,
ttlMs: number = OAuthStorageService.DEFAULT_TTL_MS
): Promise<void> {
await this.redisCacheService.set(
this.getCodeKey(code),
JSON.stringify(data),
ttlMs
);
}
private getCodeKey(code: string): string { private getCodeKey(code: string): string {
return `${OAuthStorageService.CODE_KEY_PREFIX}${code}`; return `${OAuthStorageService.CODE_KEY_PREFIX}${code}`;
} }

Loading…
Cancel
Save