refactor(oauth-providers): enable isolated declarations (#1201)

pull/1206/head
Jonathan Haines 2025-06-09 19:33:23 +10:00 committed by GitHub
parent f0475c7324
commit 641fd4c3de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 21 additions and 15 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/oauth-providers': patch
---
Add explicit return types

View File

@ -113,7 +113,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
const response = (await fetch('https://discord.com/api/oauth2/@me', {
headers: {

View File

@ -104,7 +104,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
await this.getUserId()

View File

@ -49,7 +49,7 @@ export class AuthFlow {
this.granted_scopes = undefined
}
redirect() {
redirect(): string {
const url = 'https://github.com/login/oauth/authorize?'
const queryParams = toQueryParams({
@ -114,7 +114,7 @@ export class AuthFlow {
return email as string
}
async getUserData() {
async getUserData(): Promise<void> {
if (!this.token?.token) {
await this.getTokenFromCode()
}

View File

@ -82,7 +82,7 @@ export class AuthFlow {
return `https://accounts.google.com/o/oauth2/v2/auth?${parsedOptions}`
}
async getTokenFromCode() {
async getTokenFromCode(): Promise<void> {
const response = (await fetch('https://oauth2.googleapis.com/token', {
method: 'POST',
headers: {
@ -112,7 +112,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
const response = (await fetch('https://www.googleapis.com/oauth2/v2/userinfo', {

View File

@ -1,4 +1,4 @@
export async function revokeToken(token: string) {
export async function revokeToken(token: string): Promise<boolean> {
const response = await fetch(`https://oauth2.googleapis.com/revoke?token=${token}`, {
method: 'POST',
headers: { 'Content-type': 'application/x-www-form-urlencoded' },

View File

@ -97,7 +97,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
if (!this.token) {
await this.getTokenFromCode()
}
@ -117,7 +117,7 @@ export class AuthFlow {
}
}
async getAppToken() {
async getAppToken(): Promise<void> {
const params = toQueryParams({
grant_type: 'client_credentials',
client_id: this.client_id,

View File

@ -70,7 +70,7 @@ export class AuthFlow {
return `https://login.microsoft.com/${this.tenant_id}/oauth2/v2.0/authorize?${parsedOptions}`
}
async getTokenFromCode() {
async getTokenFromCode(): Promise<void> {
const parsedOptions = toQueryParams({
client_id: this.client_id,
client_secret: this.client_secret,
@ -104,7 +104,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
//TODO: add support for extra fields
const response = (await fetch('https://graph.microsoft.com/v1.0/me', {

View File

@ -12,7 +12,7 @@ export async function refreshToken({
client_secret: string
tenant_id: string
refresh_token: string
}) {
}): Promise<MSEntraTokenResponse> {
if (!refresh_token) {
throw new HTTPException(400, { message: 'missing refresh token' })
}

View File

@ -108,7 +108,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
const response = (await fetch('https://api.twitch.tv/helix/users', {
headers: {

View File

@ -111,7 +111,7 @@ export class AuthFlow {
}
}
async getUserData() {
async getUserData(): Promise<void> {
await this.getTokenFromCode()
const parsedOptions = toQueryParams({

View File

@ -4,7 +4,8 @@
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
"emitDeclarationOnly": false
"emitDeclarationOnly": false,
"isolatedDeclarations": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],