diff --git a/uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue b/uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue index dd8b8c4ed0879ac47e8db9ab7aa352940cda0e3d..3d3334344d02fdfdfb6ee470b514014632681159 100644 --- a/uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue +++ b/uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue @@ -47,6 +47,13 @@ } } }, + data() { + return { + focusCaptchaInput: false, + captchaBase64: "", + loging: false + }; + }, watch: { scene: { handler(scene) { @@ -113,16 +120,6 @@ background-color: #FEFAE7; } - .captcha { - height: 44px; - line-height: 44px; - } - - .captcha-img-box { - position: relative; - background-color: #FEFAE7; - } - .captcha { background-color: #F8F8F8; font-size: 14px; @@ -167,4 +164,4 @@ transform: rotate(360deg) } } - + \ No newline at end of file diff --git a/uni_modules/uni-captcha/readme.md b/uni_modules/uni-captcha/readme.md index 9cbc5573d611f0737947cd1aa67134137cc61168..d929f633b9698b2170088fa85b572884eea7d77d 100644 --- a/uni_modules/uni-captcha/readme.md +++ b/uni_modules/uni-captcha/readme.md @@ -1,3 +1,3 @@

文档已移至 uni-captcha文档 -

+ \ No newline at end of file diff --git a/uni_modules/uni-config-center/changelog.md b/uni_modules/uni-config-center/changelog.md index 4d2eb92f668fd9c35d56f525fde7244b7b38972d..57dbcb568d07a5758d1234b1061558b48595afc0 100644 --- a/uni_modules/uni-config-center/changelog.md +++ b/uni_modules/uni-config-center/changelog.md @@ -1,3 +1,5 @@ +## 0.0.3(2022-11-11) +- 修复 config 方法获取根节点为数组格式配置时错误的转化为了对象的Bug ## 0.0.2(2021-04-16) - 修改插件package信息 ## 0.0.1(2021-03-15) diff --git a/uni_modules/uni-config-center/package.json b/uni_modules/uni-config-center/package.json index d97bd27a6329c76d1cafe7e15b7afaf2a25f9343..0798109cdd8e42ed8bb4383f0104947414f07cdc 100644 --- a/uni_modules/uni-config-center/package.json +++ b/uni_modules/uni-config-center/package.json @@ -1,7 +1,7 @@ { "id": "uni-config-center", "displayName": "uni-config-center", - "version": "0.0.2", + "version": "0.0.3", "description": "uniCloud 配置中心", "keywords": [ "配置", @@ -11,11 +11,7 @@ "engines": { "HBuilderX": "^3.1.0" }, - "dcloudext": { - "category": [ - "uniCloud", - "云函数模板" - ], +"dcloudext": { "sale": { "regular": { "price": "0.00" @@ -32,7 +28,8 @@ "data": "无", "permissions": "无" }, - "npmurl": "" + "npmurl": "", + "type": "unicloud-template-function" }, "directories": { "example": "../../../scripts/dist" @@ -73,8 +70,12 @@ "快应用": { "华为": "u", "联盟": "u" + }, + "Vue": { + "vue2": "y", + "vue3": "u" } } } } -} +} diff --git a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js index e14fb3b0a213443d5c51cb3fcb763d322c21c97f..00ba62fd2b17655234fb4fa6818245cfdca62bce 100644 --- a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js +++ b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/index.js @@ -1 +1 @@ -"use strict";var t=require("fs"),r=require("path");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t),o=e(r),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var u=function(t){var r={exports:{}};return t(r,r.exports),r.exports}((function(t,r){var e="__lodash_hash_undefined__",n=9007199254740991,o="[object Arguments]",u="[object Function]",c="[object Object]",a=/^\[object .+?Constructor\]$/,f=/^(?:0|[1-9]\d*)$/,s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s[o]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s[u]=s["[object Map]"]=s["[object Number]"]=s[c]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1;var l="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=l||h||Function("return this")(),_=r&&!r.nodeType&&r,v=_&&t&&!t.nodeType&&t,d=v&&v.exports===_,y=d&&l.process,g=function(){try{var t=v&&v.require&&v.require("util").types;return t||y&&y.binding&&y.binding("util")}catch(t){}}(),b=g&&g.isTypedArray;function j(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}var w,O,m,A=Array.prototype,z=Function.prototype,M=Object.prototype,x=p["__core-js_shared__"],C=z.toString,F=M.hasOwnProperty,U=(w=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+w:"",S=M.toString,I=C.call(Object),P=RegExp("^"+C.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=d?p.Buffer:void 0,q=p.Symbol,E=p.Uint8Array,$=T?T.allocUnsafe:void 0,D=(O=Object.getPrototypeOf,m=Object,function(t){return O(m(t))}),k=Object.create,B=M.propertyIsEnumerable,N=A.splice,L=q?q.toStringTag:void 0,R=function(){try{var t=_t(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),G=T?T.isBuffer:void 0,V=Math.max,W=Date.now,H=_t(p,"Map"),J=_t(Object,"create"),K=function(){function t(){}return function(r){if(!Mt(r))return{};if(k)return k(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}}();function Q(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r-1},X.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this},Y.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(H||X),string:new Q}},Y.prototype.delete=function(t){var r=pt(this,t).delete(t);return this.size-=r?1:0,r},Y.prototype.get=function(t){return pt(this,t).get(t)},Y.prototype.has=function(t){return pt(this,t).has(t)},Y.prototype.set=function(t,r){var e=pt(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this},Z.prototype.clear=function(){this.__data__=new X,this.size=0},Z.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Z.prototype.get=function(t){return this.__data__.get(t)},Z.prototype.has=function(t){return this.__data__.has(t)},Z.prototype.set=function(t,r){var e=this.__data__;if(e instanceof X){var n=e.__data__;if(!H||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new Y(n)}return e.set(t,r),this.size=e.size,this};var it,ut=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var c=i[it?u:++n];if(!1===r(o[c],c,o))break}return t};function ct(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":L&&L in Object(t)?function(t){var r=F.call(t,L),e=t[L];try{t[L]=void 0;var n=!0}catch(t){}var o=S.call(t);n&&(r?t[L]=e:delete t[L]);return o}(t):function(t){return S.call(t)}(t)}function at(t){return xt(t)&&ct(t)==o}function ft(t){return!(!Mt(t)||function(t){return!!U&&U in t}(t))&&(At(t)?P:a).test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function st(t){if(!Mt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=dt(t),e=[];for(var n in t)("constructor"!=n||!r&&F.call(t,n))&&e.push(n);return e}function lt(t,r,e,n,o){t!==r&&ut(r,(function(i,u){if(o||(o=new Z),Mt(i))!function(t,r,e,n,o,i,u){var a=yt(t,e),f=yt(r,e),s=u.get(f);if(s)return void rt(t,e,s);var l=i?i(a,f,e+"",t,r,u):void 0,h=void 0===l;if(h){var p=wt(f),_=!p&&mt(f),v=!p&&!_&&Ct(f);l=f,p||_||v?wt(a)?l=a:xt(j=a)&&Ot(j)?l=function(t,r){var e=-1,n=t.length;r||(r=Array(n));for(;++e-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(R?function(t,r){return R(t,"toString",{configurable:!0,enumerable:!1,value:(e=r,function(){return e}),writable:!0});var e}:It);function bt(t,r){return t===r||t!=t&&r!=r}var jt=at(function(){return arguments}())?at:function(t){return xt(t)&&F.call(t,"callee")&&!B.call(t,"callee")},wt=Array.isArray;function Ot(t){return null!=t&&zt(t.length)&&!At(t)}var mt=G||function(){return!1};function At(t){if(!Mt(t))return!1;var r=ct(t);return r==u||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}function zt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}function Mt(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function xt(t){return null!=t&&"object"==typeof t}var Ct=b?function(t){return function(r){return t(r)}}(b):function(t){return xt(t)&&zt(t.length)&&!!s[ct(t)]};function Ft(t){return Ot(t)?tt(t,!0):st(t)}var Ut,St=(Ut=function(t,r,e){lt(t,r,e)},ht((function(t,r){var e=-1,n=r.length,o=n>1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=Ut.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!Mt(e))return!1;var n=typeof r;return!!("number"==n?Ot(e)&&vt(r,e.length):"string"==n&&r in e)&&bt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++ec.call(t,r);class f{constructor({pluginId:t,defaultConfig:r={},customMerge:e,root:n}){this.pluginId=t,this.defaultConfig=r,this.pluginConfigPath=o.default.resolve(n||__dirname,t),this.customMerge=e,this._config=void 0}resolve(t){return o.default.resolve(this.pluginConfigPath,t)}hasFile(t){return n.default.existsSync(this.resolve(t))}requireFile(t){try{return require(this.resolve(t))}catch(t){if("MODULE_NOT_FOUND"===t.code)return;throw t}}_getUserConfig(){return this.requireFile("config.json")}config(t,r){this._config||(this._config=(this.customMerge||u)(this.defaultConfig,this._getUserConfig()));let e=this._config;return t?function(t,r,e){if("number"==typeof r)return t[r];if("symbol"==typeof r)return a(t,r)?t[r]:e;const n="string"!=typeof(o=r)?o:o.split(".").reduce(((t,r)=>(r.split(/\[([^}]+)\]/g).forEach((r=>r&&t.push(r))),t)),[]);var o;let i=t;for(let t=0;t-1},X.prototype.set=function(t,r){var e=this.__data__,n=nt(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this},Y.prototype.clear=function(){this.size=0,this.__data__={hash:new Q,map:new(H||X),string:new Q}},Y.prototype.delete=function(t){var r=_t(this,t).delete(t);return this.size-=r?1:0,r},Y.prototype.get=function(t){return _t(this,t).get(t)},Y.prototype.has=function(t){return _t(this,t).has(t)},Y.prototype.set=function(t,r){var e=_t(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this},Z.prototype.clear=function(){this.__data__=new X,this.size=0},Z.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Z.prototype.get=function(t){return this.__data__.get(t)},Z.prototype.has=function(t){return this.__data__.has(t)},Z.prototype.set=function(t,r){var e=this.__data__;if(e instanceof X){var n=e.__data__;if(!H||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new Y(n)}return e.set(t,r),this.size=e.size,this};var it,ut=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var c=i[it?u:++n];if(!1===r(o[c],c,o))break}return t};function ct(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":L&&L in Object(t)?function(t){var r=F.call(t,L),e=t[L];try{t[L]=void 0;var n=!0}catch(t){}var o=S.call(t);n&&(r?t[L]=e:delete t[L]);return o}(t):function(t){return S.call(t)}(t)}function at(t){return Ct(t)&&ct(t)==o}function ft(t){return!(!xt(t)||function(t){return!!U&&U in t}(t))&&(zt(t)?P:a).test(function(t){if(null!=t){try{return C.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function st(t){if(!xt(t))return function(t){var r=[];if(null!=t)for(var e in Object(t))r.push(e);return r}(t);var r=yt(t),e=[];for(var n in t)("constructor"!=n||!r&&F.call(t,n))&&e.push(n);return e}function lt(t,r,e,n,o){t!==r&&ut(r,(function(i,u){if(o||(o=new Z),xt(i))!function(t,r,e,n,o,i,u){var a=gt(t,e),f=gt(r,e),s=u.get(f);if(s)return void rt(t,e,s);var l=i?i(a,f,e+"",t,r,u):void 0,h=void 0===l;if(h){var p=Ot(f),_=!p&&At(f),v=!p&&!_&&Ft(f);l=f,p||_||v?Ot(a)?l=a:Ct(j=a)&&mt(j)?l=function(t,r){var e=-1,n=t.length;r||(r=Array(n));for(;++e-1&&t%1==0&&t0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(pt);function jt(t,r){return t===r||t!=t&&r!=r}var wt=at(function(){return arguments}())?at:function(t){return Ct(t)&&F.call(t,"callee")&&!B.call(t,"callee")},Ot=Array.isArray;function mt(t){return null!=t&&Mt(t.length)&&!zt(t)}var At=G||function(){return!1};function zt(t){if(!xt(t))return!1;var r=ct(t);return r==u||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}function Mt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}function xt(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function Ct(t){return null!=t&&"object"==typeof t}var Ft=b?function(t){return function(r){return t(r)}}(b):function(t){return Ct(t)&&Mt(t.length)&&!!s[ct(t)]};function Ut(t){return mt(t)?tt(t,!0):st(t)}var St,It=(St=function(t,r,e){lt(t,r,e)},ht((function(t,r){var e=-1,n=r.length,o=n>1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=St.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,r,e){if(!xt(e))return!1;var n=typeof r;return!!("number"==n?mt(e)&&dt(r,e.length):"string"==n&&r in e)&&jt(e[r],t)}(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++ec.call(t,r);class f{constructor({pluginId:t,defaultConfig:r={},customMerge:e,root:n}){this.pluginId=t,this.defaultConfig=r,this.pluginConfigPath=o.default.resolve(n||__dirname,t),this.customMerge=e,this._config=void 0}resolve(t){return o.default.resolve(this.pluginConfigPath,t)}hasFile(t){return n.default.existsSync(this.resolve(t))}requireFile(t){try{return require(this.resolve(t))}catch(t){if("MODULE_NOT_FOUND"===t.code)return;throw t}}_getUserConfig(){return this.requireFile("config.json")}config(t,r){if(!this._config){const t=this._getUserConfig();this._config=Array.isArray(t)?t:(this.customMerge||u)(this.defaultConfig,t)}let e=this._config;return t?function(t,r,e){if("number"==typeof r)return t[r];if("symbol"==typeof r)return a(t,r)?t[r]:e;const n="string"!=typeof(o=r)?o:o.split(".").reduce(((t,r)=>(r.split(/\[([^}]+)\]/g).forEach((r=>r&&t.push(r))),t)),[]);var o;let i=t;for(let t=0;t - + - - - + + + @@ -36,570 +72,567 @@ - - +} + diff --git a/uni_modules/uni-easyinput/package.json b/uni_modules/uni-easyinput/package.json index 4ca4200a1dd125a837ed9b17d68a0c49557525d0..af8cf5cb4d21e9d2a352c5a6cce67181970072f6 100644 --- a/uni_modules/uni-easyinput/package.json +++ b/uni_modules/uni-easyinput/package.json @@ -1,7 +1,7 @@ { "id": "uni-easyinput", "displayName": "uni-easyinput 增强输入框", - "version": "1.1.3", + "version": "1.1.4", "description": "Easyinput 组件是对原生input组件的增强", "keywords": [ "uni-ui", diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md index e0567b4068512c198e1c78443675758b928183c6..83419e1015666cf8d9de7590a09d380834a946e5 100644 --- a/uni_modules/uni-id-pages/changelog.md +++ b/uni_modules/uni-id-pages/changelog.md @@ -1,5 +1,15 @@ -## 1.0.26(2022-10-18) -- 修复 uni-id-pages 导入时异常的Bug +## 1.0.30(2022-11-11) +- uni-id-co 修复 用户只有openid时绑定微信/QQ报错 +## 1.0.29(2022-11-10) +- uni-id-co 支持URL化方式请求 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#adapter-http) +## 1.0.28(2022-11-09) +- uni-id-co 升级密码加密算法,支持hmac-sha256加密 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#password-safe) +- uni-id-co 新增 开发者可以自定义密码加密规则 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#custom-password-encrypt) +- uni-id-co 新增 支持将其他系统用户迁移至uni-id [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary.html#move-users-to-uni-id) +## 1.0.27(2022-10-26) +- uni-id-co 新增 secureNetworkHandshakeByWeixin 接口,用于建立和微信小程序的安全网络连接 +## 1.0.26(2022-10-18) +- 修复 uni-id-pages 导入时异常的Bug ## 1.0.25(2022-10-14) - uni-id-co 增加 微信授权手机号登录方式 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#login-by-weixin-mobile) - uni-id-co 增加 解绑第三方平台账号 [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-third-account) diff --git a/uni_modules/uni-id-pages/init.js b/uni_modules/uni-id-pages/init.js index 3b9665e6b58a3af3148c94c9507c616fa5c7663d..b1b3d1f03c9155697d0fe4f7d7336373658d525b 100644 --- a/uni_modules/uni-id-pages/init.js +++ b/uni_modules/uni-id-pages/init.js @@ -34,7 +34,7 @@ export default async function() { google: 'google', alipay: 'alipay', apple: "apple" - } + } //遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示 let list = loginTypes.filter(type => !supportedLoginType.includes(data[type])) if (list.length) { @@ -55,8 +55,7 @@ export default async function() { }) } // #endif - -/* 注释此代码块原因:与uni-starter中的appinit逻辑一致 + //3. 绑定clientDB错误事件 // clientDB对象 const db = uniCloud.database() @@ -73,9 +72,9 @@ export default async function() { } // 解绑clientDB错误事件 //db.off('error', onDBError) -*/ - //4. 同步客户端push_clientid至uni-id-device表 + + //4. 同步客户端push_clientid至device表 if (uniCloud.onRefreshToken) { uniCloud.onRefreshToken(() => { console.log('onRefreshToken'); @@ -91,10 +90,10 @@ export default async function() { console.log('getPushClientId', res); }, fail(e) { - console.error(e,'更多详情:https://uniapp.dcloud.net.cn/uniCloud/uni-starter.html#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9') + console.log(e) } }) } }) - } + } } diff --git a/uni_modules/uni-id-pages/package.json b/uni_modules/uni-id-pages/package.json index 4f0138305e51b0aa78477554d54f547e45c7751e..ca0aef16ff7013ba07da8877087e1ec7c88db519 100644 --- a/uni_modules/uni-id-pages/package.json +++ b/uni_modules/uni-id-pages/package.json @@ -1,7 +1,7 @@ { "id": "uni-id-pages", "displayName": "uni-id-pages", - "version": "1.0.26", + "version": "1.0.30", "description": "云端一体简单、统一、可扩展的用户中心页面模版", "keywords": [ "用户管理", diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js index 1e44b98c98e5fe73d71445aac587e3a1bd29935b..c282adabf716c707a564595e4626bef627efda34 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/constants.js @@ -6,6 +6,8 @@ const verifyCollectionName = 'opendb-verify-codes' const verifyCollection = db.collection(verifyCollectionName) const deviceCollectionName = 'uni-id-device' const deviceCollection = db.collection(deviceCollectionName) +const openDataCollectionName = 'opendb-open-data' +const openDataCollection = db.collection(openDataCollectionName) const USER_IDENTIFIER = { username: 'username', @@ -78,6 +80,7 @@ module.exports = { userCollection, verifyCollection, deviceCollection, + openDataCollection, USER_IDENTIFIER, USER_STATUS, CAPTCHA_SCENE, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js index ca08116e4abffdb74fd04a21f25b77686771b743..09fdd3b886c6de64c682526367e5420b6f3bf77c 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/error.js @@ -35,7 +35,8 @@ const ERROR = { UNBIND_NOT_SUPPORTED: 'uni-id-unbind-not-supported', UNBIND_UNIQUE_LOGIN: 'uni-id-unbind-unique-login', UNBIND_PASSWORD_NOT_EXISTS: 'uni-id-unbind-password-not-exists', - UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists' + UNBIND_MOBILE_NOT_EXISTS: 'uni-id-unbind-mobile-not-exists', + UNSUPPORTED_REQUEST: 'uni-id-unsupported-request' } function isUniIdError (errCode) { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js new file mode 100644 index 0000000000000000000000000000000000000000..4bf46a0b31d1588b62de43104d03cf63d5fdfffe --- /dev/null +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/common/universal.js @@ -0,0 +1,47 @@ +const { ERROR } = require('./error') + +function getHttpClientInfo () { + const requestId = this.getUniCloudRequestId() + const { clientIP, userAgent, source, secretType = 'none' } = this.getClientInfo() + const { clientInfo = {} } = JSON.parse(this.getHttpInfo().body) + + return { + ...clientInfo, + clientIP, + userAgent, + source, + secretType, + requestId + } +} + +function getHttpUniIdToken () { + const { uniIdToken = '' } = JSON.parse(this.getHttpInfo().body) + + return uniIdToken +} + +function verifyHttpMethod () { + const { headers, httpMethod } = this.getHttpInfo() + + if (!/^application\/json/.test(headers['content-type']) || httpMethod.toUpperCase() !== 'POST') { + throw { + errCode: ERROR.UNSUPPORTED_REQUEST, + errMsg: 'unsupported request' + } + } +} + +function universal () { + if (this.getClientInfo().source === 'http') { + verifyHttpMethod.call(this) + this.getParams()[0] = JSON.parse(this.getHttpInfo().body).params + this.getUniversalClientInfo = getHttpClientInfo.bind(this) + this.getUniversalUniIdToken = getHttpUniIdToken.bind(this) + } else { + this.getUniversalClientInfo = this.getClientInfo + this.getUniversalUniIdToken = this.getUniIdToken + } +} + +module.exports = universal diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js index 24cbbc7b4d78dbf5ffcbe1cc3a92ef8e01da4e75..d0e5d557a2fb78ab03eb8deec75470d8df1c5ede 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/index.obj.js @@ -12,6 +12,7 @@ const { isUniIdError } = require('./common/error') const middleware = require('./middleware/index') +const universal = require('./common/universal') const { registerAdmin, @@ -63,7 +64,8 @@ const { } = require('./module/verify/index') const { refreshToken, - setPushCid + setPushCid, + secureNetworkHandshakeByWeixin } = require('./module/utils/index') const { getInvitedUser, @@ -80,7 +82,10 @@ const { module.exports = { async _before () { - const clientInfo = this.getClientInfo() + // 支持 callFunction 与 URL化 + universal.call(this) + + const clientInfo = this.getUniversalClientInfo() /** * 检查clientInfo,无appId和uniPlatform时本云对象无法正常运行 * 此外需要保证用到的clientInfo字段均经过类型检查 @@ -576,5 +581,9 @@ module.exports = { * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#unbind-apple * @returns */ - unbindApple + unbindApple, + /** + * 安全网络握手,目前仅处理微信小程序安全网络握手 + */ + secureNetworkHandshakeByWeixin } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js index 99c445d4ce17620a8f7c4cfbbe8da60cb7eda986..9470af20fcac3f3849feaf6399ab74934b978c26 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/en.js @@ -40,7 +40,8 @@ const sentence = { 'uni-id-unbind-failed': 'Please bind first and then unbind', 'uni-id-unbind-not-supported': 'Unbinding is not supported', 'uni-id-unbind-mobile-not-exists': 'This is the only way to login at the moment, please bind your phone number and then try to unbind', - 'uni-id-unbind-password-not-exists': 'Please set a password first' + 'uni-id-unbind-password-not-exists': 'Please set a password first', + 'uni-id-unsupported-request': 'Unsupported request' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js index 923d2af8f40c1360780789fb6a83a3b4221a5231..40b3b6a20c826158c49edc848bf3951b13966080 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lang/zh-hans.js @@ -40,7 +40,8 @@ const sentence = { 'uni-id-unbind-failed': '请先绑定后再解绑', 'uni-id-unbind-not-supported': '不支持解绑', 'uni-id-unbind-mobile-not-exists': '这是当前唯一登录方式,请绑定手机号后再尝试解绑', - 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑' + 'uni-id-unbind-password-not-exists': '请先设置密码在尝试解绑', + 'uni-id-unsupported-request': '不支持的请求方式' } module.exports = { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js index 726f40608c3ede4c53ecfccf6fd962b8eac56c6a..07c1f349dc37ea5c8b56d46f9f0789501495a6f9 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/captcha.js @@ -39,7 +39,7 @@ async function getNeedCaptcha ({ const { data: recentRecord } = await uniIdLogCollection.where({ - ip: this.getClientInfo().clientIP, + ip: this.getUniversalClientInfo().clientIP, ...userIdentifier, type, create_date: dbCmd.gt(now - limitDuration) @@ -61,7 +61,7 @@ async function verifyCaptcha (params = {}) { } } const payload = await this.uniCaptcha.verify({ - deviceId: this.getClientInfo().deviceId, + deviceId: this.getUniversalClientInfo().deviceId, captcha, scene }) diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js index 07bd0442178145fe9406c22b5bfe0d806d35bbf2..21375bf565d0ffff9a84178eaa257eec2062ba18 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/login.js @@ -17,7 +17,7 @@ async function realPreLogin (params = {}) { const { user } = params - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const userMatched = await findUser({ userQuery: user, authorizedApp: appId @@ -66,7 +66,7 @@ async function preLoginWithPassword (params = {}) { } = this.config const { clientIP - } = this.getClientInfo() + } = this.getUniversalClientInfo() // 根据ip地址,密码错误次数过多,锁定登录 let loginIPLimit = userRecord.login_ip_limit || [] // 清理无用记录 @@ -78,6 +78,8 @@ async function preLoginWithPassword (params = {}) { } } const passwordUtils = new PasswordUtils({ + userRecord, + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) @@ -85,9 +87,7 @@ async function preLoginWithPassword (params = {}) { success: checkPasswordSuccess, refreshPasswordInfo } = passwordUtils.checkUserPassword({ - password, - passwordHash: userRecord.password, - passwordSecretVersion: userRecord.password_secret_version + password }) if (!checkPasswordSuccess) { // 更新用户ip对应的密码错误记录 @@ -179,7 +179,7 @@ async function postLogin (params = {}) { const { clientIP, uniIdToken - } = this.getClientInfo() + } = this.getUniversalClientInfo() const uid = user._id const updateData = { last_login_date: Date.now(), diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js index 5cd9c617057b34d877709130e362fb6b7a495152..e91559110fa3cf3677e41da01a8a9f723b0485da 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/logout.js @@ -5,11 +5,11 @@ const { userCollection } = require('../../common/constants') -async function logout() { +async function logout () { const { uniIdToken, deviceId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const { uid } = await this.uniIdCommon.checkToken( @@ -44,4 +44,4 @@ async function logout() { module.exports = { logout -} \ No newline at end of file +} diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js index b1da3842c3dbe114f6f555d95bb564721733240c..92294df35f077258a1b1b0eee78a82f202940694 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/password.js @@ -2,37 +2,160 @@ const { getType } = require('../../common/utils') const crypto = require('crypto') +const createConfig = require('uni-config-center') +const shareConfig = createConfig({ + pluginId: 'uni-id' +}) +let customPassword = {} +if (shareConfig.hasFile('custom-password.js')) { + customPassword = shareConfig.requireFile('custom-password.js') || {} +} + +const passwordAlgorithmMap = { + UNI_ID_HMAC_SHA1: 'hmac-sha1', + UNI_ID_HMAC_SHA256: 'hmac-sha256', + UNI_ID_CUSTOM: 'custom' +} + +const passwordAlgorithmKeyMap = Object.keys(passwordAlgorithmMap).reduce((res, item) => { + res[passwordAlgorithmMap[item]] = item + return res +}, {}) + +const passwordExtMethod = { + [passwordAlgorithmMap.UNI_ID_HMAC_SHA1]: { + verify ({ password }) { + const { password_secret_version: passwordSecretVersion } = this.userRecord + + const passwordSecret = this._getSecretByVersion({ + version: passwordSecretVersion + }) + + const { passwordHash } = this.encrypt({ + password, + passwordSecret + }) + + return passwordHash === this.userRecord.password + }, + encrypt ({ password, passwordSecret }) { + const { value: secret, version } = passwordSecret + const hmac = crypto.createHmac('sha1', secret.toString('ascii')) + + hmac.update(password) + + return { + passwordHash: hmac.digest('hex'), + version + } + } + }, + [passwordAlgorithmMap.UNI_ID_HMAC_SHA256]: { + verify ({ password }) { + const parse = this._parsePassword() + const passwordHash = crypto.createHmac(parse.algorithm, parse.salt).update(password).digest('hex') + + return passwordHash === parse.hash + }, + encrypt ({ password, passwordSecret }) { + const { version } = passwordSecret + + // 默认使用 sha256 加密算法 + const salt = crypto.randomBytes(10).toString('hex') + const sha256Hash = crypto.createHmac(passwordAlgorithmMap.UNI_ID_HMAC_SHA256.substring(5), salt).update(password).digest('hex') + const algorithm = passwordAlgorithmKeyMap[passwordAlgorithmMap.UNI_ID_HMAC_SHA256] + // B 为固定值,对应 PasswordMethodMaps 中的 sha256算法 + // hash 格式 $[PasswordMethodFlagMapsKey]$[salt size]$[salt][Hash] + const passwordHash = `$${algorithm}$${salt.length}$${salt}${sha256Hash}` + + return { + passwordHash, + version + } + } + }, + [passwordAlgorithmMap.UNI_ID_CUSTOM]: { + verify ({ password, passwordSecret }) { + if (!customPassword.verifyPassword) throw new Error('verifyPassword method not found in custom password file') + + // return true or false + return customPassword.verifyPassword({ + password, + passwordSecret, + userRecord: this.userRecord, + clientInfo: this.clientInfo + }) + }, + encrypt ({ password, passwordSecret }) { + if (!customPassword.encryptPassword) throw new Error('encryptPassword method not found in custom password file') -const PasswordHashMethod = { - 'hmac-sha1': function (content, secret) { - const hmac = crypto.createHmac('sha1', secret.toString('ascii')) - hmac.update(content) - return hmac.digest('hex') + // return object<{passwordHash: string, version: number}> + return customPassword.encryptPassword({ + password, + passwordSecret, + clientInfo: this.clientInfo + }) + } } } class PasswordUtils { constructor ({ + userRecord = {}, + clientInfo, passwordSecret } = {}) { - const passwordSecretType = getType(passwordSecret) - if (passwordSecretType === 'array') { - this.passwordSecret = passwordSecret.sort((a, b) => { - return a.version - b.version + if (!clientInfo) throw new Error('Invalid clientInfo') + if (!passwordSecret) throw new Error('Invalid password secret') + + this.clientInfo = clientInfo + this.userRecord = userRecord + this.passwordSecret = this.prePasswordSecret(passwordSecret) + } + + /** + * passwordSecret 预处理 + * @param passwordSecret + * @return {*[]} + */ + prePasswordSecret (passwordSecret) { + const newPasswordSecret = [] + if (getType(passwordSecret) === 'string') { + newPasswordSecret.push({ + value: passwordSecret, + type: passwordAlgorithmMap.UNI_ID_HMAC_SHA1 }) - } else if (passwordSecretType === 'string') { - this.passwordSecret = [{ value: passwordSecret }] + } else if (getType(passwordSecret) === 'array') { + for (const secret of passwordSecret.sort((a, b) => a.version - b.version)) { + newPasswordSecret.push({ + ...secret, + // 没有 type 设置默认 type hmac-sha1 + type: secret.type || passwordAlgorithmMap.UNI_ID_HMAC_SHA1 + }) + } } else { throw new Error('Invalid password secret') } + + return newPasswordSecret } - getSecretByVersion (params = {}) { - const { - version - } = params + /** + * 获取最新加密密钥 + * @return {*} + * @private + */ + _getLastestSecret () { + return this.passwordSecret[this.passwordSecret.length - 1] + } + + _getOldestSecret () { + return this.passwordSecret[0] + } + + _getSecretByVersion ({ version } = {}) { if (!version && version !== 0) { - return this.getOldestSecret() + return this._getOldestSecret() } if (this.passwordSecret.length === 1) { return this.passwordSecret[0] @@ -40,77 +163,99 @@ class PasswordUtils { return this.passwordSecret.find(item => item.version === version) } - getLastestSecret () { - return this.passwordSecret[this.passwordSecret.length - 1] + /** + * 获取密码的验证/加密方法 + * @param passwordSecret + * @return {*[]} + * @private + */ + _getPasswordExt (passwordSecret) { + const ext = passwordExtMethod[passwordSecret.type] + if (!ext) { + throw new Error(`暂不支持 ${passwordSecret.type} 类型的加密算法`) + } + + const passwordExt = Object.create(null) + + for (const key in ext) { + passwordExt[key] = ext[key].bind(Object.assign(this, Object.keys(ext).reduce((res, item) => { + if (item !== key) { + res[item] = ext[item].bind(this) + } + return res + }, {}))) + } + + return passwordExt } - getOldestSecret () { - return this.passwordSecret[0] + _parsePassword () { + const [algorithmKey = '', cost = 0, hashStr = ''] = this.userRecord.password.split('$').filter(key => key) + const algorithm = passwordAlgorithmMap[algorithmKey] ? passwordAlgorithmMap[algorithmKey].substring(5) : null + const salt = hashStr.substring(0, Number(cost)) + const hash = hashStr.substring(Number(cost)) + + return { + algorithm, + salt, + hash + } } - checkUserPassword (params = {}) { - const { + /** + * 生成加密后的密码 + * @param {String} password 密码 + */ + generatePasswordHash ({ password }) { + if (!password) throw new Error('Invalid password') + + const passwordSecret = this._getLastestSecret() + const ext = this._getPasswordExt(passwordSecret) + + const { passwordHash, version } = ext.encrypt({ password, - passwordHash: passwordHashToCheck, - passwordSecretVersion, - autoRefresh = true - } = params - const currentPasswordSecret = this.getSecretByVersion({ - version: passwordSecretVersion + passwordSecret }) - if (!currentPasswordSecret) { - throw new Error('Invalid password version') + + return { + passwordHash, + version } - const { - value: passwordSecret - } = currentPasswordSecret - const { - passwordHash - } = this.generatePasswordHash({ - password, - passwordSecret, - passwordSecretVersion + } + + /** + * 密码校验 + * @param {String} password + * @param {Boolean} autoRefresh + * @return {{refreshPasswordInfo: {version: *, passwordHash: *}, success: boolean}|{success: boolean}} + */ + checkUserPassword ({ password, autoRefresh = true }) { + if (!password) throw new Error('Invalid password') + + const { password_secret_version: passwordSecretVersion } = this.userRecord + const passwordSecret = this._getSecretByVersion({ + version: passwordSecretVersion }) - if (passwordHashToCheck !== passwordHash) { + const ext = this._getPasswordExt(passwordSecret) + + const success = ext.verify({ password, passwordSecret }) + + if (!success) { return { success: false } } + let refreshPasswordInfo - if (autoRefresh && passwordSecretVersion !== this.getLastestSecret().version) { - refreshPasswordInfo = this.generatePasswordHash({ - password - }) + if (autoRefresh && passwordSecretVersion !== this._getLastestSecret().version) { + refreshPasswordInfo = this.generatePasswordHash({ password }) } + return { success: true, refreshPasswordInfo } } - - generatePasswordHash (params = {}) { - let { - password, - passwordSecret, - passwordSecretVersion - } = params - if (getType(password) !== 'string') { - throw new Error('Invalid password') - } - password = password && password.trim() - if (!password) { - throw new Error('Invalid password') - } - if (!passwordSecret) { - const lastestSecret = this.getLastestSecret() - passwordSecret = lastestSecret.value - passwordSecretVersion = lastestSecret.version - } - return { - passwordHash: PasswordHashMethod['hmac-sha1'](password, passwordSecret), - version: passwordSecretVersion - } - } } module.exports = PasswordUtils diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js index 08da035674560158d984e3e5799ed0c34c57c8aa..18f5b559574e1e8d24ee41c66e443c80e4fbb890 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/qq.js @@ -5,7 +5,7 @@ const { ERROR } = require('../../common/error') -function getQQPlatform() { +function getQQPlatform () { const platform = this.clientPlatform switch (platform) { case 'app': @@ -18,7 +18,7 @@ function getQQPlatform() { } } -async function saveQQUserKey({ +async function saveQQUserKey ({ openid, sessionKey, // QQ小程序用户sessionKey accessToken, // App端QQ用户accessToken @@ -26,7 +26,7 @@ async function saveQQUserKey({ } = {}) { // 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqPlatform = getQQPlatform.call(this) const keyObj = { dcloudAppid: appId, @@ -45,9 +45,9 @@ async function saveQQUserKey({ await this.uniOpenBridge.setUserAccessToken(keyObj, { access_token: accessToken, access_token_expired: accessTokenExpired - }, accessTokenExpired ? - Math.floor((accessTokenExpired - Date.now()) / 1000) : - 30 * 24 * 60 * 60 + }, accessTokenExpired + ? Math.floor((accessTokenExpired - Date.now()) / 1000) + : 30 * 24 * 60 * 60 ) break default: @@ -55,7 +55,7 @@ async function saveQQUserKey({ } } -function generateQQCache({ +function generateQQCache ({ sessionKey, // QQ小程序用户sessionKey accessToken, // App端QQ用户accessToken accessTokenExpired // App端QQ用户accessToken过期时间 @@ -84,11 +84,11 @@ function generateQQCache({ } } -function getQQOpenid({ +function getQQOpenid ({ userRecord } = {}) { const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqOpenidObj = userRecord.qq_openid if (!qqOpenidObj) { return @@ -96,7 +96,7 @@ function getQQOpenid({ return qqOpenidObj[`${qqPlatform}_${appId}`] || qqOpenidObj[qqPlatform] } -async function getQQCacheFallback({ +async function getQQCacheFallback ({ userRecord, key } = {}) { @@ -109,13 +109,13 @@ async function getQQCacheFallback({ return qqCache && qqCache[key] } -async function getQQCache({ +async function getQQCache ({ uid, userRecord, key } = {}) { const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!userRecord) { const getUserRes = await userCollection.doc(uid).get() diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js index 274713c62a335cf6ed807432bb65565702e12f48..254cf743e2316c45ebe93077f7e6db91ec6ebeed 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/register.js @@ -18,13 +18,13 @@ const { const PasswordUtils = require('./password') const merge = require('lodash.merge') -async function realPreRegister(params = {}) { +async function realPreRegister (params = {}) { const { user } = params const userMatched = await findUser({ userQuery: user, - authorizedApp: this.getClientInfo().appId + authorizedApp: this.getUniversalClientInfo().appId }) if (userMatched.length > 0) { throw { @@ -33,7 +33,7 @@ async function realPreRegister(params = {}) { } } -async function preRegister(params = {}) { +async function preRegister (params = {}) { try { await realPreRegister.call(this, params) } catch (error) { @@ -45,7 +45,7 @@ async function preRegister(params = {}) { } } -async function preRegisterWithPassword(params = {}) { +async function preRegisterWithPassword (params = {}) { const { user, password @@ -54,6 +54,7 @@ async function preRegisterWithPassword(params = {}) { user }) const passwordUtils = new PasswordUtils({ + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { @@ -72,7 +73,7 @@ async function preRegisterWithPassword(params = {}) { } } -async function thirdPartyRegister({ +async function thirdPartyRegister ({ user = {} } = {}) { return { @@ -81,7 +82,7 @@ async function thirdPartyRegister({ } } -async function postRegister(params = {}) { +async function postRegister (params = {}) { const { user, extraData = {}, @@ -98,7 +99,7 @@ async function postRegister(params = {}) { clientIP, osName, uniIdToken - } = this.getClientInfo() + } = this.getUniversalClientInfo() merge(user, extraData) @@ -162,7 +163,7 @@ async function postRegister(params = {}) { if (beforeRegister) { userRecord = await beforeRegister({ userRecord, - clientInfo: this.getClientInfo() + clientInfo: this.getUniversalClientInfo() }) } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js index e095780ac60591c416defcc8298e43e7d8decbcf..4fec25b23521519c0b6ffe7816451af76957dc95 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/relate.js @@ -29,7 +29,7 @@ async function preBind ({ } = {}) { const userMatched = await findUser({ userQuery: bindAccount, - authorizedApp: this.getClientInfo().appId + authorizedApp: this.getUniversalClientInfo().appId }) if (userMatched.length > 0) { await this.middleware.uniIdLog({ diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js index 3665fe9f4742b412ae038fbbc09aecda9092be9b..b3aa7aa0c8545e6a578e5c23b6882336aebb74f2 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/unified-login.js @@ -17,7 +17,7 @@ async function realPreUnifiedLogin (params = {}) { user, type } = params - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const userMatched = await findUser({ userQuery: user, authorizedApp: appId diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js index 2ba70baa58e9c37a2173950e2f2ead8cdca4747b..8b45b620d722d9f1fc11a8d92186b5577d9bb003 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/univerify.js @@ -13,7 +13,7 @@ async function getPhoneNumber ({ } return uniCloud.getPhoneNumber({ provider: 'univerify', - appid: this.getClientInfo().appId, + appid: this.getUniversalClientInfo().appId, apiKey: univerifyConfig.apiKey, apiSecret: univerifyConfig.apiSecret, // eslint-disable-next-line camelcase diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..7d3e0f3668115023247947f26e46a89a65fba31a --- /dev/null +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/utils.js @@ -0,0 +1,18 @@ +let redisEnable = null +function getRedisEnable() { + // 未用到的时候不调用redis接口,节省一些连接数 + if (redisEnable !== null) { + return redisEnable + } + try { + uniCloud.redis() + redisEnable = true + } catch (error) { + redisEnable = false + } + return redisEnable +} + +module.exports = { + getRedisEnable +} \ No newline at end of file diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js index cc80004c9f10a2f3b79a21175ee5241739bd80e9..31ba23614cc927b57edcdd633784515e36542394 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/verify-code.js @@ -23,7 +23,7 @@ async function setVerifyCode ({ scene, code: code || getVerifyCode(), state: 0, - ip: this.getClientInfo().clientIP, + ip: this.getUniversalClientInfo().clientIP, created_date: now, expired_date: now + expiresIn * 1000 } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js index 3bfbdfe3116cf66ea589aa1f5977579c8f05381b..37a0cb853288bb00bf12939e477226b89064c715 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/lib/utils/weixin.js @@ -5,6 +5,12 @@ const { const { ERROR } = require('../../common/error') +const { + getRedisEnable +} = require('./utils') +const { + openDataCollection +} = require('../../common/constants') function decryptWeixinData ({ encryptedData, @@ -33,7 +39,7 @@ function decryptWeixinData ({ function getWeixinPlatform () { const platform = this.clientPlatform - const userAgent = this.getClientInfo().userAgent + const userAgent = this.getUniversalClientInfo().userAgent switch (platform) { case 'app': case 'app-plus': @@ -58,7 +64,7 @@ async function saveWeixinUserKey ({ // 微信公众平台、开放平台refreshToken有效期均为30天(微信没有在网络请求里面返回30天这个值,务必注意未来可能出现调整,需及时更新此处逻辑)。 // 此前QQ开放平台有调整过accessToken的过期时间:[access_token有效期由90天缩短至30天](https://wiki.connect.qq.com/%E3%80%90qq%E4%BA%92%E8%81%94%E3%80%91access_token%E6%9C%89%E6%95%88%E6%9C%9F%E8%B0%83%E6%95%B4) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const weixinPlatform = getWeixinPlatform.call(this) const keyObj = { dcloudAppid: appId, @@ -85,6 +91,35 @@ async function saveWeixinUserKey ({ } } +async function saveSecureNetworkCache ({ + code, + openid, + unionid, + sessionKey +}) { + const { + appId + } = this.getUniversalClientInfo() + const key = `uni-id:${appId}:weixin-mp:code:${code}:secure-network-cache` + const value = JSON.stringify({ + openid, + unionid, + session_key: sessionKey + }) + // 此处存储的是code的缓存,有效期两天即可 + const expiredSeconds = 2 * 24 * 60 * 60 + + await openDataCollection.doc(key).set({ + value, + expired: Date.now() + expiredSeconds * 1000 + }) + const isRedisEnable = getRedisEnable() + if (isRedisEnable) { + const redis = uniCloud.redis() + await redis.set(key, value, 'EX', expiredSeconds) + } +} + function generateWeixinCache ({ sessionKey, // 微信小程序用户sessionKey accessToken, // App端微信用户accessToken @@ -122,7 +157,7 @@ function getWeixinOpenid ({ userRecord } = {}) { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const wxOpenidObj = userRecord.wx_openid if (!wxOpenidObj) { return @@ -149,7 +184,7 @@ async function getWeixinCache ({ key } = {}) { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!userRecord) { const getUserRes = await userCollection.doc(uid).get() userRecord = getUserRes.data[0] @@ -179,7 +214,7 @@ async function getWeixinCache ({ async function getWeixinAccessToken () { const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const cache = await this.uniOpenBridge.getAccessToken({ dcloudAppid: appId, @@ -194,5 +229,6 @@ module.exports = { generateWeixinCache, getWeixinCache, saveWeixinUserKey, - getWeixinAccessToken + getWeixinAccessToken, + saveSecureNetworkCache } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js index 945e6a1aa81ee6b643b543e27ee88a6d51424d40..a111ee3b2e091564cd0d522c1ea7bf8930217e99 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/auth.js @@ -2,7 +2,7 @@ module.exports = async function () { if (this.authInfo) { // 多次执行auth时如果第一次成功后续不再执行 return } - const token = this.getUniIdToken() + const token = this.getUniversalUniIdToken() const payload = await this.uniIdCommon.checkToken(token) if (payload.errCode) { throw payload diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js index 8202d587e5682169a1915d349c012e92108356eb..013f7ae6b0723422c0e66663b910ccbafbc0474b 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/middleware/uni-id-log.js @@ -19,7 +19,7 @@ module.exports = async function ({ clientIP, deviceId, userAgent - } = this.getClientInfo() + } = this.getUniversalClientInfo() const logData = { appid: appId, device_id: deviceId, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js index 63611b3d7b2010685b79d5a676a622be15b1969b..bd5dc0fd62912aa07726bb4af63fd540419bf6be 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-email.js @@ -79,7 +79,7 @@ module.exports = async function (params = {}) { userQuery: { email }, - authorizedApp: [this.getClientInfo().appId] + authorizedApp: [this.getUniversalClientInfo().appId] }) if (userMatched.length === 0) { throw { @@ -95,6 +95,7 @@ module.exports = async function (params = {}) { passwordHash, version } = new PasswordUtils({ + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }).generatePasswordHash({ password diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js index 646834f321004dcd5bfa40d61db364bee7503c1a..05e68bf795c6907306534a796e78e66d80c2f22b 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/reset-pwd-by-sms.js @@ -79,7 +79,7 @@ module.exports = async function (params = {}) { userQuery: { mobile }, - authorizedApp: [this.getClientInfo().appId] + authorizedApp: [this.getUniversalClientInfo().appId] }) if (userMatched.length === 0) { throw { @@ -95,6 +95,7 @@ module.exports = async function (params = {}) { passwordHash, version } = new PasswordUtils({ + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }).generatePasswordHash({ password diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js index 7329b736445393accaf754f20aef82e11b24c298..8a0271847158635ca16205731b795c8d2d71e1ad 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/account/update-pwd.js @@ -32,16 +32,18 @@ module.exports = async function (params = {}) { newPassword } = params const passwordUtils = new PasswordUtils({ + userRecord, + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) + const { success: checkPasswordSuccess } = passwordUtils.checkUserPassword({ password: oldPassword, - passwordHash: userRecord.password, - passwordSecretVersion: userRecord.password_secret_version, autoRefresh: false }) + if (!checkPasswordSuccess) { throw { errCode: ERROR.PASSWORD_ERROR diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js index 5b494e2d1e5956682b299339e7a9d9739405eee8..f7081ddd6aafb41ebd8d2e17e3ace77be15e9817 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/add-user.js @@ -83,6 +83,7 @@ module.exports = async function (params = {}) { } } const passwordUtils = new PasswordUtils({ + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js index 5dc1b294fdd172071d2132b642f364f2d411c7df..a224a1c4d291295fda470e73a0a509f22929461f 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/admin/update-user.js @@ -107,6 +107,7 @@ module.exports = async function (params = {}) { if (password) { const passwordUtils = new PasswordUtils({ + clientInfo: this.getUniversalClientInfo(), passwordSecret: this.config.passwordSecret }) const { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js index 9f7b0cea1aa889ebc6b093f71b134e59b301e16e..445c5cdadd9b6a0774a8d64fb3674decceb7ca87 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-qq.js @@ -56,7 +56,7 @@ module.exports = async function (params = {}) { } = params const { appId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const qqApi = initQQ.call(this) const qqPlatform = getQQPlatform.call(this) let apiName diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js index f26b2b030d7213bdf294200a0152bcd698acfca9..1b6e5150dede949621d27742d24b9d8ac609385c 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin-mobile.js @@ -2,10 +2,7 @@ const { initWeixin } = require('../../lib/third-party/index') const { - getWeixinPlatform, - getWeixinAccessToken, - generateWeixinCache, - saveWeixinUserKey + getWeixinAccessToken } = require('../../lib/utils/weixin') const { ERROR diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js index d2a4bcf57c686fb25bc6c8dde21d1a917f31be31..0d624c929bd2230c418ce997cfac39942cdf662c 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/login/login-by-weixin.js @@ -11,7 +11,8 @@ const { const { generateWeixinCache, getWeixinPlatform, - saveWeixinUserKey + saveWeixinUserKey, + saveSecureNetworkCache } = require('../../lib/utils/weixin') const { LOG_TYPE @@ -37,11 +38,13 @@ module.exports = async function (params = {}) { this.middleware.validate(params, schema) const { code, - inviteCode + inviteCode, + // 内部参数,暂不暴露 + secureNetworkCache = false } = params const { appId - } = this.getClientInfo() + } = this.getUniversalClientInfo() const weixinApi = initWeixin.call(this) const weixinPlatform = getWeixinPlatform.call(this) let apiName @@ -81,6 +84,18 @@ module.exports = async function (params = {}) { expired: accessTokenExpired // App端微信用户accessToken过期时间 } = getWeixinAccountResult + if (secureNetworkCache) { + if (weixinPlatform !== 'mp') { + throw new Error('Unsupported weixin platform, expect mp-weixin') + } + await saveSecureNetworkCache({ + code, + openid, + unionid, + sessionKey + }) + } + const { type, user diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js index 21ca0913cfb679e1bab59d40d8d06f58fa5e1828..564ec147a8fc896aaa63b34f5dca4c09733f4f62 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/register/register-admin.js @@ -38,7 +38,7 @@ module.exports = async function (params = {}) { }).limit(1).get() if (getAdminRes.data.length > 0) { const [admin] = getAdminRes.data - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId if (!admin.dcloud_appid || (admin.dcloud_appid && admin.dcloud_appid.includes(appId))) { return { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js index 370eefb97dffa677e108a33e6fa29e94f1b450a3..2ae771ddf7ed89522348cf66746efe5e28f59148 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-qq.js @@ -49,7 +49,7 @@ module.exports = async function (params = {}) { accessTokenExpired } = params const qqPlatform = getQQPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const qqApi = initQQ.call(this) const clientPlatform = this.clientPlatform const apiName = clientPlatform === 'mp-qq' ? 'code2Session' : 'getOpenidByToken' @@ -78,7 +78,7 @@ module.exports = async function (params = {}) { const bindAccount = { qq_openid: { - [clientPlatform]: openid + [qqPlatform]: openid }, qq_unionid: unionid } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js index f94f6dcdbd686334cf3ac8e30390887a4303a980..def541a8725335558228020127471029b5150b41 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/bind-weixin.js @@ -34,7 +34,7 @@ module.exports = async function (params = {}) { code } = params const weixinPlatform = getWeixinPlatform.call(this) - const appId = this.getClientInfo().appId + const appId = this.getUniversalClientInfo().appId const weixinApi = initWeixin.call(this) const clientPlatform = this.clientPlatform @@ -64,7 +64,7 @@ module.exports = async function (params = {}) { const bindAccount = { wx_openid: { - [clientPlatform]: openid + [weixinPlatform]: openid }, wx_unionid: unionid } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js index 372a4f071a1af2e575a38ce2283b191491e0ef2f..c4aec7235a311525bef29b7b02490ea02c6221b1 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/relate/unbind-qq.js @@ -16,7 +16,7 @@ const { */ module.exports = async function () { const { uid } = this.authInfo - const { appId } = this.getClientInfo() + const { appId } = this.getUniversalClientInfo() const qqPlatform = getQQPlatform.call(this) await preUnBind.call(this, { diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js index de12366f9e8c77cedc49a30502e5a32a9d0ca93d..314d458415a1f7a3938d5621583de10c5f399b12 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/index.js @@ -1,4 +1,5 @@ module.exports = { refreshToken: require('./refresh-token'), - setPushCid: require('./set-push-cid') + setPushCid: require('./set-push-cid'), + secureNetworkHandshakeByWeixin: require('./secure-network-handshake-by-weixin') } diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js index 3d50dbdec98260cc986739528adbcbc682b4bfdc..316a9ca51ea7465dc8480643c14bb8f43cfebfd9 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/refresh-token.js @@ -7,7 +7,7 @@ module.exports = async function () { token, tokenExpired } = await this.uniIdCommon.refreshToken({ - token: this.getUniIdToken() + token: this.getUniversalUniIdToken() }) return { errCode: 0, diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/secure-network-handshake-by-weixin.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/secure-network-handshake-by-weixin.js new file mode 100644 index 0000000000000000000000000000000000000000..82ea0b3762cd6459309ad794b87058feb16b2b71 --- /dev/null +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/secure-network-handshake-by-weixin.js @@ -0,0 +1,73 @@ +const { + ERROR +} = require('../../common/error') +const { + initWeixin +} = require('../../lib/third-party/index') +const { + saveWeixinUserKey, + saveSecureNetworkCache +} = require('../../lib/utils/weixin') +const loginByWeixin = require('../login/login-by-weixin') +/** + * 微信安全网络握手 + * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#set-push-cid + * @param {object} params + * @param {string} params.code 微信登录返回的code + * @param {boolean} params.callLoginByWeixin 是否同时调用一次微信登录 + * @returns + */ +module.exports = async function (params = {}) { + const schema = { + code: 'string', + callLoginByWeixin: { + type: 'boolean', + required: false + } + } + this.middleware.validate(params, schema) + let platform = this.clientPlatform + if (platform !== 'mp-weixin') { + throw new Error(`[secureNetworkHandshake] platform ${platform} is not supported`) + } + const { + code, + callLoginByWeixin = false + } = params + if (callLoginByWeixin) { + return loginByWeixin.call(this, { + code, + secureNetworkCache: true + }) + } + + const weixinApi = initWeixin.call(this) + let getWeixinAccountResult + try { + getWeixinAccountResult = await weixinApi.code2Session(code) + } catch (error) { + console.error(error) + throw { + errCode: ERROR.GET_THIRD_PARTY_ACCOUNT_FAILED + } + } + const { + openid, + unionid, + sessionKey // 微信小程序用户sessionKey + } = getWeixinAccountResult + await saveSecureNetworkCache.call(this, { + code, + openid, + unionid, + sessionKey + }) + await saveWeixinUserKey.call(this, { + openid, + sessionKey + }) + + return { + errCode: 0 + } +} diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js index fbf424b2ece7d752a1a84db1e40ed91ed35e689f..70ff66f5a80f59b20ab371d0611bdd07b965f276 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/utils/set-push-cid.js @@ -25,7 +25,7 @@ async function setOpendbDevice ({ screenHeight, romName, romVersion - } = this.getClientInfo() + } = this.getUniversalClientInfo() const platform = this.clientPlatform const now = Date.now() @@ -80,7 +80,7 @@ module.exports = async function (params = {}) { deviceId, appId, osName - } = this.getClientInfo() + } = this.getUniversalClientInfo() let platform = this.clientPlatform if (platform === 'app') { platform += osName diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js index 81b60649e0e9a607f8bf72fbca378f14b853890c..a8f338afede3fd1c3f6df203f4d168f3f9b3e5d2 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/create-captcha.js @@ -18,7 +18,7 @@ module.exports = async function (params = {}) { } this.middleware.validate(params, schema) - const deviceId = this.getClientInfo().deviceId + const deviceId = this.getUniversalClientInfo().deviceId const { scene } = params diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js index 6cbbbddea3c40871a53b9784ba68e9e29ec72402..0d7df4be673541a799394515f6778f9af29eb957 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/module/verify/refresh-captcha.js @@ -18,7 +18,7 @@ module.exports = async function (params = {}) { } this.middleware.validate(params, schema) - const deviceId = this.getClientInfo().deviceId + const deviceId = this.getUniversalClientInfo().deviceId const { scene } = params diff --git a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json index 1c6e40a599bdc77f8abded9c1caf2e492869ee89..740b12f03d1d2572788a1d8599cac842188af899 100644 --- a/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json +++ b/uni_modules/uni-id-pages/uniCloud/cloudfunctions/uni-id-co/package.json @@ -1,6 +1,6 @@ { "name": "uni-id-co", - "version": "1.0.26", + "version": "1.0.30", "description": "", "main": "index.js", "keywords": [], @@ -14,6 +14,10 @@ "uni-open-bridge-common": "file:../../../../uni-open-bridge-common/uniCloud/cloudfunctions/common/uni-open-bridge-common" }, "extensions": { - "uni-cloud-sms": {} + "uni-cloud-sms": {}, + "uni-cloud-redis": {} + }, + "cloudfunction-config": { + "keepRunningAfterReturn": false } } diff --git a/uni_modules/uni-list/changelog.md b/uni_modules/uni-list/changelog.md index 6aa6e4e0028e0a51f0b0ca9c29912fa70a8a1315..af43bfd5d68ee4850aeaf3bc36049973bfed0cc6 100644 --- a/uni_modules/uni-list/changelog.md +++ b/uni_modules/uni-list/changelog.md @@ -1,3 +1,7 @@ +## 1.2.2(2022-11-11) +- uni-list 新增属性 render-reverse 详情参考:[https://uniapp.dcloud.net.cn/component/list.html](https://uniapp.dcloud.net.cn/component/list.html) +- uni-list-chat note属性 支持:“草稿”字样 加红显示 详情参考uni-im:[https://ext.dcloud.net.cn/plugin?name=uni-im](https://ext.dcloud.net.cn/plugin?name=uni-im) +- uni-list-item 新增属性 customStyle 支持设置padding、backgroundColor ## 1.2.1(2022-03-30) - 删除无用文件 ## 1.2.0(2021-11-23) diff --git a/uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue b/uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue index 04e56b82f9902b0a23740e69d93e46133cc5ea7a..f3221291f8667fe2d8c2449ee878006c5f7f00ec 100644 --- a/uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue +++ b/uni_modules/uni-list/components/uni-list-chat/uni-list-chat.vue @@ -23,8 +23,11 @@ - {{ title }} - {{ note }} + {{ title }} + + [草稿] + {{isDraft?note.slice(14,-1):note}} + @@ -120,7 +123,10 @@ } }, // inject: ['list'], - computed: { + computed: { + isDraft(){ + return this.note.slice(0,14) == '[uni-im-draft]' + }, isSingle() { if (this.badgeText === 'dot') { return 'uni-badge--dot'; @@ -445,12 +451,19 @@ overflow: hidden; } - .uni-list-chat__content-note { + .draft ,.uni-list-chat__content-note { margin-top: 3px; color: $note-color; font-size: $note-size; font-weight: $title-weight; overflow: hidden; + } + .draft{ + color: #eb3a41; + /* #ifndef APP-NVUE */ + flex-shrink: 0; + /* #endif */ + padding-right: 3px; } .uni-list-chat__content-extra { diff --git a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue index 2c7d9ea7cec731113cce0f3e76301e6f5e37b181..fe310dfdcad4eefcc7ecc4c216146b0a93159bcf 100644 --- a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue +++ b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue @@ -1,14 +1,14 @@ - + .uni-list--border-bottom { + position: absolute; + bottom: 0; + right: 0; + left: 0; + height: 1px; + -webkit-transform: scaleY(0.5); + transform: scaleY(0.5); + background-color: $uni-border-color; + } + + /* #endif */ + diff --git a/uni_modules/uni-list/package.json b/uni_modules/uni-list/package.json index 66e8bef0c687903d3d0ca857ac97450f34a07565..1af05901d84d2d4ce9c43f514b18207f1223ed8e 100644 --- a/uni_modules/uni-list/package.json +++ b/uni_modules/uni-list/package.json @@ -1,7 +1,7 @@ { "id": "uni-list", "displayName": "uni-list 列表", - "version": "1.2.1", + "version": "1.2.2", "description": "List 组件 ,帮助使用者快速构建列表。", "keywords": [ "", @@ -18,11 +18,7 @@ "directories": { "example": "../../temps/example_temps" }, - "dcloudext": { - "category": [ - "前端组件", - "通用组件" - ], +"dcloudext": { "sale": { "regular": { "price": "0.00" @@ -39,7 +35,8 @@ "data": "无", "permissions": "无" }, - "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" }, "uni_modules": { "dependencies": [