From 630d818434c4c24f2e69ae9d4cac4f10cf5f15bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 15 Aug 2024 19:32:09 +0200 Subject: [PATCH] chore: fix --- packages/core/src/providers/wechat.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/core/src/providers/wechat.ts b/packages/core/src/providers/wechat.ts index 51d5e6f183..05ffde7849 100644 --- a/packages/core/src/providers/wechat.ts +++ b/packages/core/src/providers/wechat.ts @@ -8,13 +8,7 @@ * * @module providers/wechat */ -import type { - AuthorizationEndpointHandler, - OAuthConfig, - OAuthUserConfig, - TokenEndpointHandler, - UserinfoEndpointHandler, -} from "./" +import type { OAuthConfig, OAuthUserConfig } from "./index.js" /** @see [Get the authenticated user](https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Authorized_Interface_Calling_UnionID.html) */ export interface WeChatProfile { @@ -81,11 +75,11 @@ export interface WeChatProfile { * ::: */ -export default function WeChat

( - options: OAuthUserConfig

& { +export default function WeChat( + options: OAuthUserConfig & { platformType?: "OfficialAccount" | "WebsiteApp" } -): OAuthConfig

{ +): OAuthConfig { const { clientId, clientSecret, platformType = "OfficialAccount" } = options console.log(options) return { @@ -110,7 +104,7 @@ export default function WeChat

( token: { url: "https://api.weixin.qq.com/sns/oauth2/access_token", params: { appid: clientId, secret: clientSecret }, - conform: async (response) => { + async conform(response) { const data = await response.json() if (data.token_type === "bearer") { console.warn( @@ -123,7 +117,7 @@ export default function WeChat

( }, userinfo: { url: "https://api.weixin.qq.com/sns/userinfo", - request: async ({ tokens, provider }) => { + async request({ tokens, provider }) { const url = new URL(provider.userinfo?.url!) url.searchParams.set("access_token", tokens.access_token!) url.searchParams.set("openid", String(tokens.openid)) @@ -132,7 +126,7 @@ export default function WeChat

( return response.json() }, }, - profile: (profile: WeChatProfile) => { + profile(profile) { return { id: profile.unionid, name: profile.nickname,