提交 e7ec4ed8 编写于 作者: Anne_LXM's avatar Anne_LXM

兼容uni-app-x对客户端uniPlatform的调整(uni-app-x内uniPlatform区分app-android、app-ios)

上级 efce7305
...@@ -171,13 +171,6 @@ function getNonceStr (length = 16) { ...@@ -171,13 +171,6 @@ function getNonceStr (length = 16) {
return str.substring(0, length) return str.substring(0, length)
} }
try {
require('lodash.merge')
} catch (error) {
console.error('uni-id-co缺少依赖,请在uniCloud/cloudfunctions/uni-id-co目录执行 npm install 安装依赖')
throw error
}
function isMatchUserApp (userAppList, matchAppList) { function isMatchUserApp (userAppList, matchAppList) {
if (userAppList === undefined || userAppList === null) { if (userAppList === undefined || userAppList === null) {
return true return true
......
...@@ -111,6 +111,8 @@ module.exports = { ...@@ -111,6 +111,8 @@ module.exports = {
switch (clientPlatform) { switch (clientPlatform) {
case 'app': case 'app':
case 'app-plus': case 'app-plus':
case 'app-android':
case 'app-ios':
clientPlatform = 'app' clientPlatform = 'app'
break break
case 'web': case 'web':
......
const rsaPublicKeyPem = require('../rsa-public-key-pem') const rsaPublicKeyPem = require('../rsa-public-key-pem')
const {
jwtVerify
} = require('../../../npm/index')
let authKeysCache = null let authKeysCache = null
module.exports = class Auth { module.exports = class Auth {
...@@ -44,7 +47,7 @@ module.exports = class Auth { ...@@ -44,7 +47,7 @@ module.exports = class Auth {
* nonce_supported: true * nonce_supported: true
* } * }
*/ */
const payload = require('jsonwebtoken').verify( const payload = jwtVerify(
identityToken, identityToken,
rsaPublicKeyPem(usedKey.n, usedKey.e), rsaPublicKeyPem(usedKey.n, usedKey.e),
{ {
......
...@@ -18,7 +18,7 @@ const uniIdConfig = createConfig({ ...@@ -18,7 +18,7 @@ const uniIdConfig = createConfig({
}) })
class ConfigUtils { class ConfigUtils {
constructor ({ constructor({
context context
} = {}) { } = {}) {
this.context = context this.context = context
...@@ -31,6 +31,8 @@ class ConfigUtils { ...@@ -31,6 +31,8 @@ class ConfigUtils {
switch (uniPlatform) { switch (uniPlatform) {
case 'app': case 'app':
case 'app-plus': case 'app-plus':
case 'app-android':
case 'app-ios':
this.platform = 'app' this.platform = 'app'
break break
case 'web': case 'web':
...@@ -43,7 +45,7 @@ class ConfigUtils { ...@@ -43,7 +45,7 @@ class ConfigUtils {
} }
} }
getConfigArray () { getConfigArray() {
let configContent let configContent
try { try {
configContent = require('uni-config-center/uni-id/config.json') configContent = require('uni-config-center/uni-id/config.json')
...@@ -57,12 +59,12 @@ class ConfigUtils { ...@@ -57,12 +59,12 @@ class ConfigUtils {
return [configContent] return [configContent]
} }
getAppConfig () { getAppConfig() {
const configArray = this.getConfigArray() const configArray = this.getConfigArray()
return configArray.find(item => item.dcloudAppid === this.appId) || configArray.find(item => item.isDefaultConfig) return configArray.find(item => item.dcloudAppid === this.appId) || configArray.find(item => item.isDefaultConfig)
} }
getPlatformConfig () { getPlatformConfig() {
const appConfig = this.getAppConfig() const appConfig = this.getAppConfig()
if (!appConfig) { if (!appConfig) {
throw new Error( throw new Error(
...@@ -87,7 +89,7 @@ class ConfigUtils { ...@@ -87,7 +89,7 @@ class ConfigUtils {
return Object.assign(defaultConfig, appConfig, appConfig[platform]) return Object.assign(defaultConfig, appConfig, appConfig[platform])
} }
getOauthProvider ({ getOauthProvider({
provider provider
} = {}) { } = {}) {
const clientPlatform = this.platform const clientPlatform = this.platform
...@@ -101,7 +103,7 @@ class ConfigUtils { ...@@ -101,7 +103,7 @@ class ConfigUtils {
return oatuhProivder return oatuhProivder
} }
getOauthConfig ({ getOauthConfig({
provider provider
} = {}) { } = {}) {
const config = this.getPlatformConfig() const config = this.getPlatformConfig()
...@@ -122,7 +124,7 @@ class ConfigUtils { ...@@ -122,7 +124,7 @@ class ConfigUtils {
return oauthConfig return oauthConfig
} }
getHooks () { getHooks() {
if (uniIdConfig.hasFile('hooks/index.js')) { if (uniIdConfig.hasFile('hooks/index.js')) {
return require( return require(
uniIdConfig.resolve('hooks/index.js') uniIdConfig.resolve('hooks/index.js')
......
...@@ -10,6 +10,8 @@ function getQQPlatform () { ...@@ -10,6 +10,8 @@ function getQQPlatform () {
switch (platform) { switch (platform) {
case 'app': case 'app':
case 'app-plus': case 'app-plus':
case 'app-android':
case 'app-ios':
return 'app' return 'app'
case 'mp-qq': case 'mp-qq':
return 'mp' return 'mp'
......
...@@ -16,7 +16,9 @@ const { ...@@ -16,7 +16,9 @@ const {
logout logout
} = require('./logout') } = require('./logout')
const PasswordUtils = require('./password') const PasswordUtils = require('./password')
const merge = require('lodash.merge') const {
merge
} = require('../npm/index')
async function realPreRegister (params = {}) { async function realPreRegister (params = {}) {
const { const {
......
...@@ -14,7 +14,9 @@ const { ...@@ -14,7 +14,9 @@ const {
const { const {
batchFindObjctValue batchFindObjctValue
} = require('../../common/utils') } = require('../../common/utils')
const merge = require('lodash.merge') const {
merge
} = require('../npm/index')
/** /**
* *
......
...@@ -43,6 +43,8 @@ function getWeixinPlatform () { ...@@ -43,6 +43,8 @@ function getWeixinPlatform () {
switch (platform) { switch (platform) {
case 'app': case 'app':
case 'app-plus': case 'app-plus':
case 'app-android':
case 'app-ios':
return 'app' return 'app'
case 'mp-weixin': case 'mp-weixin':
return 'mp' return 'mp'
......
{ {
"name": "uni-id-co", "name": "uni-id-co",
"version": "1.1.19", "version": "1.1.20",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"keywords": [], "keywords": [],
"author": "DCloud", "author": "DCloud",
"dependencies": { "dependencies": {
"jsonwebtoken": "8.5.1",
"lodash.merge": "^4.6.2",
"uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha", "uni-captcha": "file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha",
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center", "uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center",
"uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common", "uni-id-common": "file:../../../../uni-id-common/uniCloud/cloudfunctions/common/uni-id-common",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册