Skip to content

Commit

Permalink
feat: update decryptData demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojingjing committed May 23, 2023
1 parent 23d736c commit 98fb04e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 49 additions & 1 deletion examples/miniapp-wx/miniapp/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ const authing = new Authing({

Page({
data: {},
onLoad() {
// 开启 shareTicket 用户分享获取群聊 id
wx.updateShareMenu({
withShareTicket: true,
})
},
onShareAppMessage() {
const promise = new Promise(resolve => {
setTimeout(() => {
resolve({
title: '自定义转发标题'
})
}, 2000)
})
return {
title: '自定义转发标题',
path: '/pages/index',
promise
}
},


/**
* 需要在真机上测试,微信开发者工具不会返回 code
Expand Down Expand Up @@ -257,11 +278,13 @@ Page({
},

async decryptData () {
const code = await authing.getLoginCode()

const res = await authing.decryptData({
extIdpConnidentifier: 'AUTHING_EXT_IDP_CONN_IDENTIFIER',
encryptedData: '',
iv: '',
code: ''
code
})

console.log('authing.decryptData res: ', res)
Expand All @@ -274,5 +297,30 @@ Page({
})

console.log('authing.getAccessToken res: ', res)
},

getShareInfo() {
const {shareTicket} = wx.getLaunchOptionsSync()

wx.getShareInfo({
shareTicket,
async success({encryptedData, iv}: any) {
// 公共方法获取 code
const code = await authing.getLoginCode()

// 解密数据
const res = await authing.decryptData({
extIdpConnidentifier: 'AUTHING_EXT_IDP_CONN_IDENTIFIER',
encryptedData,
iv,
code
})

console.log('authing.decryptData res: ', res)
},
fail(error: any) {
console.log("error: ", error);
}
})
}
})
2 changes: 2 additions & 0 deletions examples/miniapp-wx/miniapp/pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@

<button bindtap="getLoginState">getLoginState</button>
<button bindtap="clearLoginState">clearLoginState</button>

<button bindtap="getShareInfo">getShareInfo</button>

0 comments on commit 98fb04e

Please sign in to comment.