refactor(oauth-providers): enable isolated declarations (#1201)
parent
f0475c7324
commit
641fd4c3de
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@hono/oauth-providers': patch
|
||||
---
|
||||
|
||||
Add explicit return types
|
|
@ -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: {
|
||||
|
|
|
@ -104,7 +104,7 @@ export class AuthFlow {
|
|||
}
|
||||
}
|
||||
|
||||
async getUserData() {
|
||||
async getUserData(): Promise<void> {
|
||||
await this.getTokenFromCode()
|
||||
|
||||
await this.getUserId()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -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' },
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -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' })
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -111,7 +111,7 @@ export class AuthFlow {
|
|||
}
|
||||
}
|
||||
|
||||
async getUserData() {
|
||||
async getUserData(): Promise<void> {
|
||||
await this.getTokenFromCode()
|
||||
|
||||
const parsedOptions = toQueryParams({
|
||||
|
|
|
@ -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"],
|
||||
|
|
Loading…
Reference in New Issue