Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ourea/doraemon-kit

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ourea/doraemon-kit - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

2

dist/index.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("doraemon-kit",[],t):"object"==typeof exports?exports["doraemon-kit"]=t():e["doraemon-kit"]=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var c=function(e,t){t.injectBefore((function(t){var r=t.url,n=t.opt,a=n.headers,c=n.params,u=e.getters["doraemon/oauth/tokenInfo"]||{},i=u.access_token,s=u.token_type,f=u.tenant_id,p=e.getters["doraemon/oauth/clientInfo"],d=p.client_id,l=p.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(d,":").concat(l))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var m=c.tenantId;a["Tenant-Id"]=m||f}else{if(!s||!i)throw new Error("缺少鉴权信息");a.auth="".concat(s," ").concat(i)}return{url:r,opt:o(o({},n),{},{headers:a})}}))};function u(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){u(a,n,o,c,i,"next",e)}function i(e){u(a,n,o,c,i,"throw",e)}c(void 0)}))}}function s(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){l(a,n,o,c,u,"next",e)}function u(e){l(a,n,o,c,u,"throw",e)}c(void 0)}))}}var h={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null},v=function(e){var t=function(e){return{login:(o=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="password",t.next=3,e.post("/doraemon-oauth/oauth/token",r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e){return o.apply(this,arguments)}),refresh:(n=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="refresh_token",r.scope="all",t.next=4,e.post("/doraemon-oauth/oauth/token",r);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)}))),function(e){return n.apply(this,arguments)}),ssoLogin:(r=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-oauth/oauth/token",r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)}),getUserInfo:(t=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.get("/doraemon-user/user/getVoByUserName",r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})};var t,r,n,o}(e);return{login:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a,c,u,i,f,d,l,h,v,y,b,g,O;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,a=e.state,c=e.dispatch,u=a.clientInfo,i=p(p({},r),{},{scope:u.scope}),n.next=5,t.login(i);case 5:return(f=n.sent).code&&"200"==="".concat(f.code)&&(delete(d=p({},f)).success,delete d.code,l=d.access_token,h=d.token_type,v=d.refresh_token,y=d.expires_in,b=d.tenant_id,g=s(d,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:h,refresh_token:v,expires_in:y,tenant_id:b,last:(new Date).getTime()}),O={userName:g.user_name},c("getUserInfo",O),setTimeout(m(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c("refresh",{refresh_token:v});case 2:case"end":return e.stop()}}),e)}))),y/3*2*1e3)),n.abrupt("return",f);case 8:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a,c,u,i,f,d,l,h,v,y;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,e.rootGetters,a=e.dispatch,e.state,n.next=3,t.refresh(r);case 3:return(c=n.sent).code&&"200"==="".concat(c.code)&&(delete(u=p({},c)).success,delete u.code,i=u.access_token,f=u.token_type,d=u.refresh_token,l=u.expires_in,h=u.tenant_id,v=s(u,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:f,refresh_token:d,expires_in:l,tenant_id:h,last:(new Date).getTime()}),y={userName:v.user_name},a("getUserInfo",y),setTimeout(m(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a("refresh",{refresh_token:d});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3)),n.abrupt("return",c);case 6:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,n.next=3,t.getUserInfo(r);case 3:(a=n.sent).code&&"200"==="".concat(a.code)&&o("SET_USER_INFO",a.data);case 5:case"end":return n.stop()}}),n)})))()}}},y={UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t}},b={tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo}},g=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:p(p(p({},h),t),r),actions:v(e),mutations:y,getters:b}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e.hasModule("doraemon/oauth")||e.registerModule(["doraemon","oauth"],g(t,e.state.doraemon.oauth||{},r),{preserveState:!0})};function _(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function w(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){_(a,n,o,c,u,"next",e)}function u(e){_(a,n,o,c,u,"throw",e)}c(void 0)}))}}function k(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var x=function(e){return{dict:(t=regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-propertydict/propertyDict/listByPrefix",{prefix:r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})),r=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(e){k(a,n,o,c,u,"next",e)}function u(e){k(a,n,o,c,u,"throw",e)}c(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var E={dictMap:{}},I=function(e){var t=x(e);return{getDictionary:function(e,r){return(n=regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=e.commit,a=e.state,c=a.dictMap,u=r.code,i=r.cache,s=void 0===i||i,!c.hasOwnProperty(u)||!s){n.next=10;break}return n.next=7,Promise.resolve(c[u]);case 7:return n.abrupt("return",n.sent);case 10:return n.next=12,t.dict(u);case 12:(f=n.sent).code&&"200"==="".concat(f.code)&&(p=f.data.map((function(e){return{name:e.displayName,value:e.id,_data:e}})),o("UPDATE_DICT_CACHE",R({},u,p)));case 14:case"end":return n.stop()}}),n)})),function(){var e=this,t=arguments;return new Promise((function(r,o){var a=n.apply(e,t);function c(e){D(a,r,o,c,u,"next",e)}function u(e){D(a,r,o,c,u,"throw",e)}c(void 0)}))})();var n}}},T={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},S={},M=function(e,t){e.hasModule("doraemon/dictionary")||e.registerModule(["doraemon","dictionary"],function(e,t){return{namespaced:!0,state:j(j({},E),t),actions:I(e),mutations:T,getters:S}}(t,e.state.doraemon.dictionary||{}),{preserveState:!0})};window&&(window.__POWER_BY_DORAEMON_KIT__=!0);t.default={Oauth:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0}),O(t,r,n),c(t,r),e.prototype.do_refresh_token=w(regeneratorRuntime.mark((function e(){var r,n,o,a,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.getters["doraemon/oauth/tokenInfo"])||!r.refresh_token){e.next=9;break}if(n=r.expires_in,o=r.refresh_token,a=r.last,c=1e3*n,!(Date.now()-a>c)){e.next=8;break}throw new Error("超过token刷新时间请跳转到登录页。");case 8:t.dispatch("doraemon/oauth/refresh",{refresh_token:o});case 9:case"end":return e.stop()}}),e)})))},Dictionary:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3];t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0}),M(t,r)}}}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("doraemon-kit",[],t):"object"==typeof exports?exports["doraemon-kit"]=t():e["doraemon-kit"]=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var c=function(e,t){t.injectBefore((function(t){var r=t.url,n=t.opt,a=n.headers,c=n.params,u=e.getters["doraemon/oauth/tokenInfo"]||{},i=u.access_token,s=u.token_type,f=u.tenant_id,p=e.getters["doraemon/oauth/clientInfo"],d=p.client_id,l=p.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(d,":").concat(l))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var m=c.tenantId;a["Tenant-Id"]=m||f}else{if(!s||!i)throw new Error("缺少鉴权信息");a.auth="".concat(s," ").concat(i)}return{url:r,opt:o(o({},n),{},{headers:a})}}))};function u(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){u(a,n,o,c,i,"next",e)}function i(e){u(a,n,o,c,i,"throw",e)}c(void 0)}))}}function s(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){l(a,n,o,c,u,"next",e)}function u(e){l(a,n,o,c,u,"throw",e)}c(void 0)}))}}var h={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null},v=function(e){var t=function(e){return{login:(o=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="password",t.next=3,e.post("/doraemon-oauth/oauth/token",r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e){return o.apply(this,arguments)}),refresh:(n=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="refresh_token",r.scope="all",t.next=4,e.post("/doraemon-oauth/oauth/token",r);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)}))),function(e){return n.apply(this,arguments)}),ssoLogin:(r=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-oauth/oauth/token",r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)}),getUserInfo:(t=i(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.get("/doraemon-user/user/getVoByUserName",r);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})};var t,r,n,o}(e);return{login:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a,c,u,i,f,d,l,h,v,y,g,b,O;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,a=e.state,c=e.dispatch,u=a.clientInfo,i=p(p({},r),{},{scope:u.scope}),n.next=5,t.login(i);case 5:return(f=n.sent).code&&"200"==="".concat(f.code)&&(delete(d=p({},f)).success,delete d.code,l=d.access_token,h=d.token_type,v=d.refresh_token,y=d.expires_in,g=d.tenant_id,b=s(d,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:h,refresh_token:v,expires_in:y,tenant_id:g,last:(new Date).getTime()}),O={userName:b.user_name},c("getUserInfo",O),setTimeout(m(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c("refresh",{refresh_token:v});case 2:case"end":return e.stop()}}),e)}))),y/3*2*1e3)),n.abrupt("return",f);case 8:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a,c,u,i,f,d,l,h,v,y;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,e.rootGetters,a=e.dispatch,e.state,n.next=3,t.refresh(r);case 3:return(c=n.sent).code&&"200"==="".concat(c.code)&&(delete(u=p({},c)).success,delete u.code,i=u.access_token,f=u.token_type,d=u.refresh_token,l=u.expires_in,h=u.tenant_id,v=s(u,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:f,refresh_token:d,expires_in:l,tenant_id:h,last:(new Date).getTime()}),y={userName:v.user_name},a("getUserInfo",y),setTimeout(m(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a("refresh",{refresh_token:d});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3)),n.abrupt("return",c);case 6:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return m(regeneratorRuntime.mark((function n(){var o,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,n.next=3,t.getUserInfo(r);case 3:(a=n.sent).code&&"200"==="".concat(a.code)&&o("SET_USER_INFO",a.data);case 5:case"end":return n.stop()}}),n)})))()}}},y={UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t}},g={tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo}},b=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:p(p(p({},h),t),r),actions:v(e),mutations:y,getters:g}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};console.log("registerModule","->","doraemon/oauth: start"),e.hasModule("doraemon/oauth")||(console.log("registerModule","->","doraemon/oauth"),e.registerModule(["doraemon","oauth"],b(t,e.state.doraemon.oauth||{},r)))};function _(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function w(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){_(a,n,o,c,u,"next",e)}function u(e){_(a,n,o,c,u,"throw",e)}c(void 0)}))}}function k(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var x=function(e){return{dict:(t=regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-propertydict/propertyDict/listByPrefix",{prefix:r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})),r=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(e){k(a,n,o,c,u,"next",e)}function u(e){k(a,n,o,c,u,"throw",e)}c(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var E={dictMap:{}},I=function(e){var t=x(e);return{getDictionary:function(e,r){return(n=regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=e.commit,a=e.state,c=a.dictMap,u=r.code,i=r.cache,s=void 0===i||i,!c.hasOwnProperty(u)||!s){n.next=10;break}return n.next=7,Promise.resolve(c[u]);case 7:return n.abrupt("return",n.sent);case 10:return n.next=12,t.dict(u);case 12:(f=n.sent).code&&"200"==="".concat(f.code)&&(p=f.data.map((function(e){return{name:e.displayName,value:e.id,_data:e}})),o("UPDATE_DICT_CACHE",R({},u,p)));case 14:case"end":return n.stop()}}),n)})),function(){var e=this,t=arguments;return new Promise((function(r,o){var a=n.apply(e,t);function c(e){D(a,r,o,c,u,"next",e)}function u(e){D(a,r,o,c,u,"throw",e)}c(void 0)}))})();var n}}},M={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},T={},S=function(e,t){console.log("registerModule","->","doraemon/dictionary: start"),e.hasModule("doraemon/dictionary")||(console.log("registerModule","->","doraemon/dictionary"),e.registerModule(["doraemon","dictionary"],function(e,t){return{namespaced:!0,state:j(j({},E),t),actions:I(e),mutations:M,getters:T}}(t,e.state.doraemon.dictionary||{})))};window&&(window.__POWER_BY_DORAEMON_KIT__=!0);t.default={Oauth:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),O(t,r,n),c(t,r),e.prototype.do_refresh_token=w(regeneratorRuntime.mark((function e(){var r,n,o,a,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.getters["doraemon/oauth/tokenInfo"])||!r.refresh_token){e.next=9;break}if(n=r.expires_in,o=r.refresh_token,a=r.last,c=1e3*n,!(Date.now()-a>c)){e.next=8;break}throw new Error("超过token刷新时间请跳转到登录页。");case 8:t.dispatch("doraemon/oauth/refresh",{refresh_token:o});case 9:case"end":return e.stop()}}),e)})))},Dictionary:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3];t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),S(t,r)}}}])}));
{
"name": "@ourea/doraemon-kit",
"version": "1.0.12",
"version": "1.0.13",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -5,5 +5,4 @@ import storeInitFunc from './init/store-init'

export default (Vue, store, http, state = {}) => {
if (!store.hasModule('doraemon')) {
store.registerModule('doraemon', { namespaced: true })
store.registerModule('doraemon', { namespaced: true, state: store.state['doraemon'] })
}

@@ -10,0 +9,0 @@ // 初始化 doraemon 状态库

import modulesStores from '../store/dictionary'
export default (store, http) => {
console.log('registerModule','->', 'doraemon/dictionary: start')
if (!store.hasModule('doraemon/dictionary')) {
console.log('registerModule','->', 'doraemon/dictionary')
store.registerModule(
['doraemon', 'dictionary'],
modulesStores(http, store.state.doraemon['dictionary'] || {}),
{ preserveState: true }
modulesStores(http, store.state.doraemon['dictionary'] || {})
)
}
}

@@ -6,7 +6,5 @@ import httpInitFunc from './init/http-init'

export default (Vue, store, http, state = {}) => {
if (!store.hasModule('doraemon')) {
store.registerModule('doraemon', { namespaced: true })
store.registerModule('doraemon', { namespaced: true, state: store.state['doraemon'] })
}
// 初始化 doraemon 状态库

@@ -13,0 +11,0 @@ storeInitFunc(store, http, state)

import modulesStores from '../store/oauth'
export default (store, http, clientInfo = {}) => {
console.log('registerModule','->', 'doraemon/oauth: start')
if (!store.hasModule('doraemon/oauth')) {
console.log('registerModule','->', 'doraemon/oauth')
store.registerModule(
['doraemon', 'oauth'],
modulesStores(http, store.state.doraemon['oauth'] || {}, clientInfo),
{ preserveState: true }
modulesStores(http, store.state.doraemon['oauth'] || {}, clientInfo)
)
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc