zmp-sdk 2.25.3 → 2.25.5
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/requestCameraPermission.js +1 -1
- package/apis/common/token.js +1 -1
- package/apis/package.json.js +1 -1
- package/browser.min.js +1 -1
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/index.umd.js +2 -2
- package/package.json +1 -1
- package/zmp-sdk-v2.25.3.tgz +0 -0
- package/zmp-sdk-v2.25.4.tgz +0 -0
- package/zmp-sdk-v2.25.0-alpha.8.tgz +0 -0
- package/zmp-sdk-v2.25.0-rc.12.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'./../../../external/@swc/helpers/src/_async_to_generator.mjs.js';import e from"../../call/index.js";import{__generator as r}from'./../../../external/tslib/tslib.es6.js';import s from"../../../appEnv/getEnv.js";var n=o((function(){return r(this,(function(o){return[2,new Promise((function(o,r){e("REQUEST_PERMISSION_CAMERA",{},{success:function(e){o({userAllow:(null==e?void 0:e.error_code)>=0,message:null==e?void 0:e.error_message})},fail:function(e){var n,l;(null===(n=s())||void 0===n||null===(l=n.platform)||void 0===l?void 0:l.isAndroid)&&"number"==typeof(null==e?void 0:e.code)?o({userAllow:(null==e?void 0:e.code)>=0,message:null==e?void 0:e.message}):r(e)}},{})}))]}))}));export{n as default};
|
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 o from"../utils/lodash.js";import{COOKIE_NAME as r,APIS as c,APP_ID as i,ZAPP_ID as a,ApiCallStage as u,MINI_APP_INTERNAL_LINK as l}from"../constants.js";import{logger as p}from"./logger.js";import h from"./call/zaloNative.js";import{apiResponse as f}from"../utils/response.js";import{__generator as
|
|
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 o from"../utils/lodash.js";import{COOKIE_NAME as r,APIS as c,APP_ID as i,ZAPP_ID as a,ApiCallStage as u,MINI_APP_INTERNAL_LINK as l}from"../constants.js";import{logger as p}from"./logger.js";import h from"./call/zaloNative.js";import{apiResponse as f}from"../utils/response.js";import{__generator as m}from'./../external/tslib/tslib.es6.js';import{JumpStatus as d}from"../types/enum.js";var _=function(){function _(){n(this,_),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}var T=_.prototype;return T.jump=function(){var n=this;return e((function(){return m(this,(function(e){return[2,new Promise((function(e,t){n._jumpStatus?n._jumpStatus===d.DONE?e(d.DONE):e(d.DOING):(n._jumpStatus=d.DOING,p({stage:u.REQUEST,type:"log",name:"jump"}),h("JUMP_LOGIN",{},{success:function(t){var s=t.data,o=(null==s?void 0:s.cookiesOAuthLogins)||[],c=o.find((function(e){return e.name===r.JS_TOKEN}));c&&(n._jsAccessToken=c.value,window.ZJSBridge.setJSToken&&window.ZJSBridge.setJSToken(c.value)),n._cookies=o,e(d.DONE)},fail:function(e){t(e)}},{skipJump:!0}))}))]}))}))()},T.loginZaloV3=function(n,t,s){var o=this;return e((function(){var r;return m(this,(function(i){switch(i.label){case 0:return r="".concat(c.GET_ACCESS_TOKEN_V3,"?app_id=").concat(t,"&redirect_uri=").concat(l,"/").concat(n,"/&code=").concat(s,"&isSDK=true"),[4,fetch(r).then((a=e((function(e){var n,t,s;return m(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),t=null==n?void 0:n.access_token,o._accessToken=t,s=1e3*parseInt(n.expires_in),o.accessTokenExpiresIn=s,o.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(o._accessToken||""),[2,t]}}))})),function(e){return a.apply(this,arguments)}))];case 1:return[2,i.sent()]}var a}))}))()},T.loginZaloV4=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=this;return e((function(){var a,u;return m(this,(function(l){switch(l.label){case 0:return(a=new URLSearchParams).append("app_id",n),a.append("code",t),a.append("code_verifier",r),o.isNull(i.refreshToken)||0===i.refreshToken.length?a.append("grant_type","authorization_code"):(a.append("grant_type","refresh_token"),a.append("refresh_token",i.refreshToken||"")),u={headers:{"Content-Type":"application/x-www-form-urlencoded"}},[4,fetch(c.GET_ACCESS_TOKEN,s({method:"POST",body:a},u)).then((p=e((function(e){var n,t,s,o;return m(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),t=(null==n?void 0:n.access_token)||"",s=(null==n?void 0:n.refresh_token)||"",i.refreshToken=s,i._accessToken=t,o=1e3*parseInt(null==n?void 0:n.expires_in),i.accessTokenExpiresIn=o,i.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(t),[2,t]}}))})),function(e){return p.apply(this,arguments)}))];case 1:return[2,l.sent()]}var p}))}))()},T.getAccessToken=function(){var n=this;return e((function(){var t,s,o,c,u;function l(){return p.apply(this,arguments)}function p(){return(p=e((function(){return m(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 m(this,(function(e){switch(e.label){case 0:return t=(new Date).getTime()-n.prevGetAccessTokenTimestamp,(s=n).getAccessTokenCount++,n.getAccessTokenCount>1?[4,l()]:[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(r.ZOAUTH)]);case 3:return o=e.sent(),[4,n.get(r.ZOAUTH_VRF)];case 4:return c=e.sent(),o?c?[4,n.loginZaloV4(i,o,c)]:[3,6]:[3,9];case 5:return u=e.sent(),[3,8];case 6:return[4,n.loginZaloV3(i,a,o)];case 7:u=e.sent(),e.label=8;case 8:if(s.getAccessTokenCount--,!u)throw f.error.loginFailed("Invalid authorization code");return[2,Promise.resolve(n._accessToken)];case 9:throw s.getAccessTokenCount--,f.error.loginFailed("Zalo app has not been activated")}}))}))()},T.setAccessToken=function(e){this.manualSetAccessToken=!0,this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)},T.getJSAccessToken=function(){var n=this;return e((function(){var e;return m(this,(function(t){switch(t.label){case 0:return n._jsAccessToken.length>0?[2,Promise.resolve(n._jsAccessToken)]:[4,n.get(r.JS_TOKEN)];case 1:return e=t.sent(),[2,Promise.resolve(e)]}}))}))()},T.getSync=function(e){var n;return null===(n=this._cookies.find((function(n){return n.name===e})))||void 0===n?void 0:n.value},T.get=function(n){var t,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=this;return new Promise((t=e((function(e){var t,r,c,i;return m(this,(function(a){switch(a.label){case 0:return!s&&o._cookies.length>0?(t=o._cookies.find((function(e){return e.name===n})),[2,e(null==t?void 0:t.value)]):(s&&o._jumpStatus===d.DONE&&(o._jumpStatus=void 0),r={name:n,cb:function(n){return e(n)}},[4,o.jump()]);case 1:return(c=a.sent())===d.DONE?(o._jumpStatus=c,o.WAITING_QUEUE.length&&(o.WAITING_QUEUE.forEach((function(e){var n=o._cookies.find((function(n){return n.name===e.name}));e.cb(null==n?void 0:n.value)})),o.WAITING_QUEUE=[]),i=o._cookies.find((function(e){return e.name===r.name})),r.cb(null==i?void 0:i.value)):o.WAITING_QUEUE.push(r),[2]}}))})),function(e){return t.apply(this,arguments)}))},_.getInstance=function(){return _.instance||(_.instance=new _),_.instance},t(_,[{key:"jumpStatus",get:function(){return this._jumpStatus}},{key:"accessToken",set:function(e){this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)}}]),_}(),T=_.getInstance();export{T as default};
|
package/apis/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r="2.25.
|
|
1
|
+
var r="2.25.5";export{r as version};
|