zmp-sdk 2.31.1 → 2.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/common/apis/general/getSetting.js +1 -1
- package/apis/common/token.js +1 -1
- package/apis/package.json.js +1 -1
- package/browser.min.js +2 -2
- package/index.es.js +2 -2
- package/index.js +2 -2
- package/index.umd.js +2 -2
- package/package.json +1 -1
- package/zmp-sdk-v2.31.1.tgz +0 -0
- package/zmp-sdk-v2.30.3.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import e from'./../../../external/@swc/helpers/src/_object_spread.mjs.js';import{RESPONSE_CODE as r,MESSAGES as n,APIS as s}from"../../../constants.js";import o from"../../token.js";import{AppError as i}from"../../../utils/errorHandler.js";import{__generator as a}from'./../../../external/tslib/tslib.es6.js';var u,c=(u=t((function(t){var r;return a(this,(function(n){switch(n.label){case 0:return r={headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(t)}},[4,fetch(s.GET_AUTH_SETTING,e({method:"GET"},r))];case 1:return[4,n.sent().json()];case 2:return[2,n.sent()]}}))})),function(t){return u.apply(this,arguments)}),m=t((function(){return a(this,(function(e){return[2,new Promise((s=t((function(t,e){var s,u,m,l;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,
|
|
1
|
+
import t from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import e from'./../../../external/@swc/helpers/src/_object_spread.mjs.js';import{RESPONSE_CODE as r,MESSAGES as n,APIS as s}from"../../../constants.js";import o from"../../token.js";import{AppError as i}from"../../../utils/errorHandler.js";import{__generator as a}from'./../../../external/tslib/tslib.es6.js';var u,c=(u=t((function(t){var r;return a(this,(function(n){switch(n.label){case 0:return r={headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(t)}},[4,fetch(s.GET_AUTH_SETTING,e({method:"GET"},r))];case 1:return[4,n.sent().json()];case 2:return[2,n.sent()]}}))})),function(t){return u.apply(this,arguments)}),m=t((function(){return a(this,(function(e){return[2,new Promise((s=t((function(t,e){var s,u,m,l;return a(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,o.getMiniProgramConfig()];case 1:return(u=null===(s=a.sent())||void 0===s?void 0:s.jwt)||e(new i(r.UNAUTHORIZED,n.LOGIN_REQUIRED,"getSetting")),[4,c(u)];case 2:return(m=a.sent())&&0===m.err?t({authSetting:m.data}):e(new i(m.err,m.msg,"getSetting")),[3,4];case 3:return l=a.sent(),e(l),[3,4];case 4:return[2]}}))})),function(t,e){return s.apply(this,arguments)}))];var s}))}));export{m as default,c as getAuthenSettings};
|
package/apis/common/token.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from'./../external/@swc/helpers/src/_class_call_check.mjs.js';import t from'./../external/@swc/helpers/src/_create_class.mjs.js';import s from'./../external/@swc/helpers/src/_object_spread.mjs.js';import r from"../utils/lodash.js";import{COOKIE_NAME as o,APIS as i,APP_ID as c,ZAPP_ID as a,ApiCallStage as u,MINI_APP_INTERNAL_LINK as l}from"../constants.js";import{logger as m}from"./logger.js";import f from"./call/zaloNative.js";import{apiResponse as p}from"../utils/response.js";import{sendLogData as h}from"./utils.js";import{getDynamicAPIByAction as d}from"../utils/common.js";import{__generator as g}from'./../external/tslib/tslib.es6.js';import{JumpStatus as _}from"../types/enum.js";import{authorize as T}from"../apis/authorize.js";import{getSetting as v}from"../apis/getSetting.js";var k=function(){function k(){n(this,k),this._jumpStatus=void 0,this.WAITING_QUEUE=[],this.getAccessTokenCount=0,this._accessToken="",this._jsAccessToken="",this.refreshToken="",this._cookies=[],this.accessTokenExpiresIn=0,this.prevGetAccessTokenTimestamp=(new Date).getTime(),this.manualSetAccessToken=!1,this._miniProgramConfig={}}var
|
|
1
|
+
import e from'./../external/@swc/helpers/src/_async_to_generator.mjs.js';import n from'./../external/@swc/helpers/src/_class_call_check.mjs.js';import t from'./../external/@swc/helpers/src/_create_class.mjs.js';import s from'./../external/@swc/helpers/src/_object_spread.mjs.js';import r from"../utils/lodash.js";import{COOKIE_NAME as o,APIS as i,APP_ID as c,ZAPP_ID as a,ApiCallStage as u,MINI_APP_INTERNAL_LINK as l}from"../constants.js";import{logger as m}from"./logger.js";import f from"./call/zaloNative.js";import{apiResponse as p}from"../utils/response.js";import{sendLogData as h}from"./utils.js";import{getDynamicAPIByAction as d}from"../utils/common.js";import{__generator as g}from'./../external/tslib/tslib.es6.js';import{JumpStatus as _}from"../types/enum.js";import{authorize as T}from"../apis/authorize.js";import{getSetting as v}from"../apis/getSetting.js";var k=function(){function k(){n(this,k),this._jumpStatus=void 0,this.WAITING_QUEUE=[],this.getAccessTokenCount=0,this._accessToken="",this._jsAccessToken="",this.refreshToken="",this._cookies=[],this.accessTokenExpiresIn=0,this.prevGetAccessTokenTimestamp=(new Date).getTime(),this.manualSetAccessToken=!1,this._miniProgramConfig={}}var w=k.prototype;return w.jump=function(){var n=this;return e((function(){return g(this,(function(e){return[2,new Promise((function(e,t){n._jumpStatus?n._jumpStatus===_.DONE?e(_.DONE):e(_.DOING):(n._jumpStatus=_.DOING,m({stage:u.REQUEST,type:"log",name:"jump"}),f("JUMP_LOGIN",{},{success:function(t){var s=t.data;n._miniProgramConfig=(null==s?void 0:s.miniProgramConfig)||{};var r=(null==s?void 0:s.cookiesOAuthLogins)||[],i=r.find((function(e){return e.name===o.JS_TOKEN}));i&&(n._jsAccessToken=i.value,window.ZJSBridge.setJSToken&&window.ZJSBridge.setJSToken(i.value)),n._cookies=r;var c=n._cookies.find((function(e){return e.name===o.ZOAUTH}));(null==c?void 0:c.value)||h([{action:"action.jump.login",error:-102,message:"no zoauth",data:{}}]),e(_.DONE)},fail:function(e){h([{action:"action.jump.login",error:-101,message:e.message||"jump error",data:{}}]),t(e)}},{skipJump:!0}))}))]}))}))()},w.loginZaloV3=function(n,t,s){var r=this;return e((function(){var o;return g(this,(function(c){switch(c.label){case 0:return o="".concat(i.GET_ACCESS_TOKEN_V3,"?app_id=").concat(t,"&redirect_uri=").concat(l,"/").concat(n,"/&code=").concat(s,"&isSDK=true"),[4,fetch(o).then((a=e((function(e){var n,t,s;return g(this,(function(o){switch(o.label){case 0:return[4,e.json()];case 1:return n=o.sent(),t=null==n?void 0:n.access_token,r._accessToken=t,s=1e3*parseInt(n.expires_in),r.accessTokenExpiresIn=s,r.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(r._accessToken||""),[2,t]}}))})),function(e){return a.apply(this,arguments)}))];case 1:return[2,c.sent()]}var a}))}))()},w.loginZaloV4=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",c=this;return e((function(){var a,u;return g(this,(function(l){switch(l.label){case 0:return(a=new URLSearchParams).append("app_id",n),a.append("code",t),a.append("code_verifier",o),r.isNull(c.refreshToken)||0===c.refreshToken.length?a.append("grant_type","authorization_code"):(a.append("grant_type","refresh_token"),a.append("refresh_token",c.refreshToken||"")),u={headers:{"Content-Type":"application/x-www-form-urlencoded"}},[4,fetch(i.GET_ACCESS_TOKEN,s({method:"POST",body:a},u)).then((m=e((function(e){var n,t,s,r;return g(this,(function(o){switch(o.label){case 0:return[4,e.json()];case 1:return n=o.sent(),t=(null==n?void 0:n.access_token)||"",s=(null==n?void 0:n.refresh_token)||"",c.refreshToken=s,c._accessToken=t,r=1e3*parseInt(null==n?void 0:n.expires_in),c.accessTokenExpiresIn=r,c.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(t),[2,t]}}))})),function(e){return m.apply(this,arguments)}))];case 1:return[2,l.sent()]}var m}))}))()},w.getAccessToken=function(){var n=this;return e((function(){var t,s,r,i,u,l,m;function f(){return d.apply(this,arguments)}function d(){return(d=e((function(){return g(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){var n=setInterval((function(){(s.getAccessTokenCount<=1||s._accessToken)&&(e("done"),clearInterval(n))}),200)}))];case 1:return[2,e.sent()]}}))}))).apply(this,arguments)}return g(this,(function(e){switch(e.label){case 0:return t=(new Date).getTime()-n.prevGetAccessTokenTimestamp,(s=n).getAccessTokenCount++,n.getAccessTokenCount>1?[4,f()]:[3,2];case 1:e.sent(),e.label=2;case 2:return n.manualSetAccessToken||n._accessToken.length>0&&t<n.accessTokenExpiresIn?(s.getAccessTokenCount--,[2,Promise.resolve(n._accessToken)]):(n.accessToken="",[4,n.get(o.ZOAUTH)]);case 3:return r=e.sent(),[4,n.get(o.ZOAUTH_VRF)];case 4:return i=e.sent(),u="zmp.getaccesstoken.fail",[4,n.verifyUserAuthorized()];case 5:if(!e.sent())throw s.getAccessTokenCount--,h([{action:u,error:-104,message:"no user auth",data:{}}]),p.error.loginFailed("User Authentication Required");if(!r)return[3,13];e.label=6;case 6:return e.trys.push([6,11,,12]),i?[4,n.loginZaloV4(c,r,i)]:[3,8];case 7:return l=e.sent(),[3,10];case 8:return[4,n.loginZaloV3(c,a,r)];case 9:l=e.sent(),e.label=10;case 10:return[3,12];case 11:return m=e.sent(),l="",console.log("Can not get access token",m),h([{action:u,error:-103,message:String(m)||"Can not get access token",data:{}}]),[3,12];case 12:return s.getAccessTokenCount--,l||h([{action:u,error:-101,message:"no accessToken",data:{}}]),[2,Promise.resolve(n._accessToken)];case 13:throw s.getAccessTokenCount--,h([{action:u,error:-102,message:"no oauth",data:{}}]),p.error.loginFailed("Zalo app has not been activated")}}))}))()},w.verifyUserAuthorized=function(){var n=this;return e((function(){var e,t,s,r,o,i;return g(this,(function(c){switch(c.label){case 0:if(t=!0,!1!==(null===(e=n.getMiniProgramConfig())||void 0===e?void 0:e.userAuthorized))return[3,6];c.label=1;case 1:return c.trys.push([1,5,,6]),(s=d("action.mp.user.authorize"))&&s.isSupported?[4,v()]:[3,4];case 2:return!1!==(null==(o=c.sent())||null===(r=o.authSetting)||void 0===r?void 0:r["scope.userInfo"])?[3,4]:[4,T()];case 3:i=c.sent(),t=(null==i?void 0:i["scope.userInfo"])||!1,c.label=4;case 4:return[3,6];case 5:return c.sent(),t=!1,[3,6];case 6:return[2,t]}}))}))()},w.setAccessToken=function(e){this.manualSetAccessToken=!0,this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)},w.getJSAccessToken=function(){var n=this;return e((function(){var e;return g(this,(function(t){switch(t.label){case 0:return n._jsAccessToken.length>0?[2,Promise.resolve(n._jsAccessToken)]:[4,n.get(o.JS_TOKEN)];case 1:return e=t.sent(),[2,Promise.resolve(e)]}}))}))()},w.getSync=function(e){var n;return null===(n=this._cookies.find((function(n){return n.name===e})))||void 0===n?void 0:n.value},w.get=function(n){var t,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this;return new Promise((t=e((function(e){var t,o,i,c;return g(this,(function(a){switch(a.label){case 0:return!s&&r._cookies.length>0?(t=r._cookies.find((function(e){return e.name===n})),[2,e(null==t?void 0:t.value)]):(s&&r._jumpStatus===_.DONE&&(r._jumpStatus=void 0),o={name:n,cb:function(n){return e(n)}},[4,r.jump()]);case 1:return(i=a.sent())===_.DONE?(r._jumpStatus=i,r.WAITING_QUEUE.length&&(r.WAITING_QUEUE.forEach((function(e){var n=r._cookies.find((function(n){return n.name===e.name}));e.cb(null==n?void 0:n.value)})),r.WAITING_QUEUE=[]),c=r._cookies.find((function(e){return e.name===o.name})),o.cb(null==c?void 0:c.value)):r.WAITING_QUEUE.push(o),[2]}}))})),function(e){return t.apply(this,arguments)}))},w.getMiniProgramConfig=function(){var n=this;return e((function(){return g(this,(function(e){switch(e.label){case 0:return[4,n.get("")];case 1:return e.sent(),[2,n._miniProgramConfig]}}))}))()},k.getInstance=function(){return k.instance||(k.instance=new k),k.instance},t(k,[{key:"jumpStatus",get:function(){return this._jumpStatus}},{key:"accessToken",set:function(e){this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)}}]),k}(),w=k.getInstance();export{w as default};
|
package/apis/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r="2.31.
|
|
1
|
+
var r="2.31.2";export{r as version};
|