From 0989accf23d19c0cbc9cb52a32275634219104cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Mon, 6 Sep 2021 23:42:03 +0200 Subject: [PATCH] fix(ts): make OAuth profile overrideable (#2682) * fix(ts): make OAuth profile overrideable * fix(ts): default to empty object * fix(ts): use relative import --- src/providers/auth0.ts | 2 +- src/providers/facebook.ts | 10 +++++----- src/providers/google.ts | 6 +++--- src/providers/oauth.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/providers/auth0.ts b/src/providers/auth0.ts index 71617a87b7..c2427c94cb 100644 --- a/src/providers/auth0.ts +++ b/src/providers/auth0.ts @@ -18,5 +18,5 @@ export default function Auth0(options: OAuthUserConfig): OAuthConfig { } }, options, - } as any + } } diff --git a/src/providers/facebook.ts b/src/providers/facebook.ts index 3fb89dc318..d55513b0fe 100644 --- a/src/providers/facebook.ts +++ b/src/providers/facebook.ts @@ -1,4 +1,4 @@ -import { Profile } from "src" +import { Profile } from ".." import { OAuthConfig, OAuthUserConfig } from "./oauth" export interface FacebookProfile extends Profile { @@ -6,9 +6,9 @@ export interface FacebookProfile extends Profile { picture: { data: { url: string } } } -export default function Facebook

( - options: OAuthUserConfig

-): OAuthConfig

{ +export default function Facebook< + P extends Record = FacebookProfile +>(options: OAuthUserConfig

): OAuthConfig

{ return { id: "facebook", name: "Facebook", @@ -27,7 +27,7 @@ export default function Facebook

( }) }, }, - profile(profile) { + profile(profile: P) { return { id: profile.id, name: profile.name, diff --git a/src/providers/google.ts b/src/providers/google.ts index b307d8510b..b65d1f8a8f 100644 --- a/src/providers/google.ts +++ b/src/providers/google.ts @@ -6,8 +6,8 @@ export interface GoogleProfile extends Profile { picture: string } -export default function Google

( - options: OAuthUserConfig +export default function Google

= GoogleProfile>( + options: OAuthUserConfig

): OAuthConfig

{ return { id: "google", @@ -17,7 +17,7 @@ export default function Google

( authorization: { params: { scope: "openid email profile" } }, idToken: true, checks: ["pkce", "state"], - profile(profile) { + profile(profile: P) { return { id: profile.sub, name: profile.name, diff --git a/src/providers/oauth.ts b/src/providers/oauth.ts index 99b7703d77..6ae4b97597 100644 --- a/src/providers/oauth.ts +++ b/src/providers/oauth.ts @@ -55,7 +55,7 @@ type EndpointHandler

= | string | AdvancedEndpointHandler -export interface OAuthConfig

= Profile> +export interface OAuthConfig

= {}> extends CommonProviderOptions, PartialIssuer { /** @@ -138,7 +138,7 @@ export interface OAuthConfig

= Profile> options?: OAuthUserConfig

} -export type OAuthUserConfig

= Profile> = Omit< +export type OAuthUserConfig

= Omit< Partial>, "options" | "type" > &