Skip to content

Commit

Permalink
fix(ts): make OAuth profile overrideable (#2682)
Browse files Browse the repository at this point in the history
* fix(ts): make OAuth profile overrideable

* fix(ts): default to empty object

* fix(ts): use relative import
  • Loading branch information
balazsorban44 authored Sep 6, 2021
1 parent 3b23cfe commit 0989acc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/providers/auth0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export default function Auth0(options: OAuthUserConfig): OAuthConfig {
}
},
options,
} as any
}
}
10 changes: 5 additions & 5 deletions src/providers/facebook.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Profile } from "src"
import { Profile } from ".."
import { OAuthConfig, OAuthUserConfig } from "./oauth"

export interface FacebookProfile extends Profile {
id: string
picture: { data: { url: string } }
}

export default function Facebook<P extends FacebookProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
export default function Facebook<
P extends Record<string, any> = FacebookProfile
>(options: OAuthUserConfig<P>): OAuthConfig<P> {
return {
id: "facebook",
name: "Facebook",
Expand All @@ -27,7 +27,7 @@ export default function Facebook<P extends FacebookProfile>(
})
},
},
profile(profile) {
profile(profile: P) {
return {
id: profile.id,
name: profile.name,
Expand Down
6 changes: 3 additions & 3 deletions src/providers/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export interface GoogleProfile extends Profile {
picture: string
}

export default function Google<P extends GoogleProfile>(
options: OAuthUserConfig
export default function Google<P extends Record<string, any> = GoogleProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "google",
Expand All @@ -17,7 +17,7 @@ export default function Google<P extends GoogleProfile>(
authorization: { params: { scope: "openid email profile" } },
idToken: true,
checks: ["pkce", "state"],
profile(profile) {
profile(profile: P) {
return {
id: profile.sub,
name: profile.name,
Expand Down
4 changes: 2 additions & 2 deletions src/providers/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type EndpointHandler<P extends UrlParams, C = any, R = any> =
| string
| AdvancedEndpointHandler<P, C, R>

export interface OAuthConfig<P extends Record<string, unknown> = Profile>
export interface OAuthConfig<P extends Record<string, any> = {}>
extends CommonProviderOptions,
PartialIssuer {
/**
Expand Down Expand Up @@ -138,7 +138,7 @@ export interface OAuthConfig<P extends Record<string, unknown> = Profile>
options?: OAuthUserConfig<P>
}

export type OAuthUserConfig<P extends Record<string, unknown> = Profile> = Omit<
export type OAuthUserConfig<P = {}> = Omit<
Partial<OAuthConfig<P>>,
"options" | "type"
> &
Expand Down

0 comments on commit 0989acc

Please sign in to comment.