Skip to content

Commit

Permalink
feat:bindWxByCode添加身份源标识
Browse files Browse the repository at this point in the history
  • Loading branch information
周雅风 committed Mar 8, 2024
1 parent 0117049 commit f32bd22
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"scripts": {
"prepare": "husky install",
"autoinstall": "npm ci && lerna run autoinstall",
"build:miniapp": "cd packages/miniapp && npm run autoinstall && npm run build",
"link": "lerna link",
"lint": "eslint --ext .ts packages/**/src/**",
Expand Down
19 changes: 5 additions & 14 deletions packages/miniapp/src/Authing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ export class Authing {
return returnSuccess(updateProfileRes)
}

async bindWxByCode(options: BindWxByCodeOptions) {
async bindWxByCode(data: BindWxByCodeOptions) {
const [error, loginState] = await this.getLoginState()

if (error) {
Expand All @@ -673,21 +673,12 @@ export class Authing {
})
}

const _data: {
code: string
options?: BindWxByCodeOptions
} = {
code
}

if (
options !== null &&
typeof options === 'object' &&
Object.keys(options).length > 0
) {
_data.options = options
const _data: BindWxByCodeOptions = {
code,
...data,
}


const [err, res] = await request({
method: 'POST',
url: `${this.options.host}/connections/social/wechat-miniprogram/bind`,
Expand Down
3 changes: 3 additions & 0 deletions packages/miniapp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,11 @@ export interface GerUserInfo {
}

export interface BindWxByCodeOptions {
code?:string,
iv?: string
encryptedData?: string
// wx.getUserInfo 返回的 rawData, 里面包含了原始用户数据
rawData?: string
/** 身份源唯一标识 */
extIdpConnidentifier?:string
}
6 changes: 4 additions & 2 deletions packages/web/src/Authing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ export class Authing {
// implicit flow
const idToken = paramDict.id_token
const accessToken = paramDict.access_token
const refreshToken = paramDict.refresh_token
// implict 模式没有refresh_token
// https://docs.authing.cn/v2/concepts/oidc/choose-flow.html#%E9%9A%90%E5%BC%8F%E6%A8%A1%E5%BC%8F
// const refreshToken = paramDict.refresh_token
const nonce = tx?.nonce

if (
Expand Down Expand Up @@ -680,7 +682,7 @@ export class Authing {
return
}
/**
*
*
* 使用内部维护的 refresh_token 刷新 access_token、id_token
*
*/
Expand Down

0 comments on commit f32bd22

Please sign in to comment.