Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/miniapp gid #222

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"npmClient": "npm",
"packages": ["packages/*"],
"useWorkspaces": true,
"version": "5.1.6"
"version": "5.1.7-alpha.0"
}
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/miniapp-jsencrypt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp-jsencrypt",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "JavaScript encrypt module for miniapp",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/miniapp-sm2encrypt/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/miniapp-sm2encrypt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp-sm2encrypt",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "JavaScript sm2 encrypt module for miniapp",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/miniapp-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp-taro",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Authing miniapp JS SDK for Taro",
"main": "dist/bundle-taro.js",
"types": "dist/typings/src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/miniapp-uniapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp-uniapp",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Authing miniapp JS SDK for uniapp",
"main": "dist/bundle-uniapp.js",
"types": "dist/typings/src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/miniapp-wx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp-wx",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Authing miniapp JS SDK for WX",
"main": "dist/bundle-wx.js",
"types": "dist/typings/src/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/miniapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/miniapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/miniapp",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Authing miniapp sdk source code",
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
17 changes: 1 addition & 16 deletions packages/miniapp/src/Authing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,28 +905,12 @@ export class Authing {
}

async decryptData(data: DecryptDataOptions) {
const [error, loginState] = await this.getLoginState()

if (error) {
return returnError({
message: 'Token has expired, please login again'
})
}

const { access_token, expires_at } = loginState as LoginState

if (expires_at < Date.now()) {
return returnError({
message: 'Token has expired, please login again'
})
}

const [decryptError, res] = await request({
method: 'POST',
url: `${this.options.host}/api/v3/decrypt-wechat-miniprogram-data`,
data,
header: {
Authorization: access_token,
'x-authing-userpool-id': this.options.userPoolId
}
})
Expand Down Expand Up @@ -972,4 +956,5 @@ export class Authing {
return returnSuccess(res)
}


}
4 changes: 2 additions & 2 deletions packages/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/web",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Official SDK of Authing for Browser",
"main": "dist/global/index.global.js",
"module": "dist/esm/index.esm.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/weixin-official-account/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/weixin-official-account/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authing/weixin-official-account",
"version": "5.1.6",
"version": "5.1.7-alpha.0",
"description": "Authing SDK for Weixin official account",
"module": "dist/esm/weixin-official-account.min.js",
"types": "dist/typings/index.d.ts",
Expand Down