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

@ourea/doraemon-kit

Package Overview
Dependencies
Maintainers
2
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.20 to 1.0.24

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/ssoToken"],i=e.getters["doraemon/oauth/tokenInfo"]||{},s=i.access_token,f=i.token_type,p=i.tenant_id,d=e.getters["doraemon/oauth/clientInfo"],l=d.client_id,m=d.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(l,":").concat(m))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var h=c.tenantId;(h||p)&&(a["Tenant-Id"]=h||p)}else if(s&&f)a.auth="".concat(f," ").concat(s);else{if(!u)throw new Error("缺少鉴权信息");a.auth="bearer ".concat(u)}return{url:r,opt:o(o({},n),{},{headers:a})}}))},u={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function i(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 s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){i(a,n,o,c,u,"next",e)}function u(e){i(a,n,o,c,u,"throw",e)}c(void 0)}))}}function f(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 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 d(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){l(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 l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(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 h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){m(a,n,o,c,u,"next",e)}function u(e){m(a,n,o,c,u,"throw",e)}c(void 0)}))}}var v={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null,ssoToken:null},g=function(e){var t=function(e){return{login:(o=s(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,u);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=s(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,u);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=s(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,u);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=s(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/getByUserName",r,u);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 h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,g,y,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=d(d({},r),{},{scope:u.scope}),n.next=5,t.login(i);case 5:if(!(s=n.sent).code||"200"!=="".concat(s.code)){n.next=16;break}return delete(p=d({},s)).success,delete p.code,l=p.access_token,m=p.token_type,v=p.refresh_token,g=p.expires_in,y=p.tenant_id,b=f(p,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:m,refresh_token:v,expires_in:g,tenant_id:y,last:(new Date).getTime()}),O={userName:b.user_name},n.next=15,c("getUserInfo",O);case 15:setTimeout(h(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)}))),g/3*2*1e3);case 16:return n.abrupt("return",s);case 17:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,g;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:if(!(c=n.sent).code||"200"!=="".concat(c.code)){n.next=14;break}return delete(u=d({},c)).success,delete u.code,i=u.access_token,s=u.token_type,p=u.refresh_token,l=u.expires_in,m=u.tenant_id,v=f(u,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:s,refresh_token:p,expires_in:l,tenant_id:m,last:(new Date).getTime()}),g={userName:v.user_name},n.next=13,a("getUserInfo",g);case 13:setTimeout(h(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:p});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3);case 14:return n.abrupt("return",c);case 15:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return h(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_SSO_TOKEN:function(e,t){e.ssoToken=t},UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t},UPDATE_LAST_REFRESH_TIME:function(e,t){e.lastRefreshTime=t}},b={ssoToken:function(e){return e.ssoToken},tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo},lastRefreshTime:function(e){return e.lastRefreshTime}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:d(d(d({},v),t),r),actions:g(e),mutations:y,getters:b}},_=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"],O(t,e.state.doraemon.oauth||{},r)))};function w(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 k(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){w(a,n,o,c,u,"next",e)}function u(e){w(a,n,o,c,u,"throw",e)}c(void 0)}))}}function x(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 P=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},u);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){x(a,n,o,c,u,"next",e)}function u(e){x(a,n,o,c,u,"throw",e)}c(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function j(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){T(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(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 D={dictMap:{}},I=function(e){var t=P(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",T({},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){E(a,r,o,c,u,"next",e)}function u(e){E(a,r,o,c,u,"throw",e)}c(void 0)}))})();var n}}},S={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},M={},U=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:R(R({},D),t),actions:I(e),mutations:S,getters:M}}(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}),_(t,r,n),c(t,r),e.prototype.do_refresh_token=function(){var e=k(regeneratorRuntime.mark((function e(r){var n,o,a,c,u,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=t.getters["doraemon/oauth/tokenInfo"])||!n.refresh_token){e.next=14;break}if(o=n.expires_in,a=n.refresh_token,c=n.last,u=1e3*o,!((i=Date.now()-c)>u)){e.next=13;break}if(!r){e.next=10;break}r(),e.next=11;break;case 10:throw new Error("超过token刷新时间请跳转到登录页。");case 11:e.next=14;break;case 13:setTimeout(k(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.dispatch("doraemon/oauth/refresh",{refresh_token:a});case 2:case"end":return e.stop()}}),e)}))),u-i);case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.prototype.do_sso_by_token=function(){var e=k(regeneratorRuntime.mark((function e(r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.commit("doraemon/oauth/UPDATE_SSO_TOKEN",r),e.t0=n,!e.t0){e.next=5;break}return e.next=5,t.dispatch("doraemon/oauth/getUserInfo",{userName:n});case 5:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},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}),U(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 u=function(e,t){t.injectBefore((function(t){var r=t.url,n=t.opt,a=n.headers,u=n.params,c=e.getters["doraemon/oauth/ssoToken"],i=e.getters["doraemon/oauth/tokenInfo"]||{},s=i.access_token,f=i.token_type,p=i.tenant_id,d=e.getters["doraemon/oauth/clientInfo"],l=d.client_id,m=d.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(l,":").concat(m))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var h=u.tenantId;(h||p)&&(a["Tenant-Id"]=h||p)}else if(s&&f)a.auth="".concat(f," ").concat(s);else{if(!c){var g=new Error;throw g.message="缺少鉴权信息",g.code=401,g}a.auth="bearer ".concat(c)}return{url:r,opt:o(o({},n),{},{headers:a})}}))},c={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function i(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function u(e){i(a,n,o,u,c,"next",e)}function c(e){i(a,n,o,u,c,"throw",e)}u(void 0)}))}}function f(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 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 d(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){l(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 l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function u(e){m(a,n,o,u,c,"next",e)}function c(e){m(a,n,o,u,c,"throw",e)}u(void 0)}))}}var g={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null,ssoToken:null,currentOrg:""},v=function(e){var t=function(e){return{login:(o=s(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,c);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=s(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,c);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=s(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,c);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=s(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/getByUserName",r,c);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 h(regeneratorRuntime.mark((function n(){var o,a,u,c,i,s,p,l,m,g,v,y,b,O;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,a=e.state,u=e.dispatch,c=a.clientInfo,i=d(d({},r),{},{scope:c.scope}),n.next=5,t.login(i);case 5:if(!(s=n.sent).code||"200"!=="".concat(s.code)){n.next=16;break}return delete(p=d({},s)).success,delete p.code,l=p.access_token,m=p.token_type,g=p.refresh_token,v=p.expires_in,y=p.tenant_id,b=f(p,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:m,refresh_token:g,expires_in:v,tenant_id:y,last:(new Date).getTime()}),O={userName:b.user_name},n.next=15,u("getUserInfo",O);case 15:setTimeout(h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u("refresh",{refresh_token:g});case 2:case"end":return e.stop()}}),e)}))),v/3*2*1e3);case 16:return n.abrupt("return",s);case 17:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,u,c,i,s,p,l,m,g,v;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:if(!(u=n.sent).code||"200"!=="".concat(u.code)){n.next=14;break}return delete(c=d({},u)).success,delete c.code,i=c.access_token,s=c.token_type,p=c.refresh_token,l=c.expires_in,m=c.tenant_id,g=f(c,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:s,refresh_token:p,expires_in:l,tenant_id:m,last:(new Date).getTime()}),v={userName:g.user_name},n.next=13,a("getUserInfo",v);case 13:setTimeout(h(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:p});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3);case 14:return n.abrupt("return",u);case 15:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return h(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_SSO_TOKEN:function(e,t){e.ssoToken=t},UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t;var r=t.currentOrg,n=t.organizationId;e.currentOrg=r||n},UPDATE_LAST_REFRESH_TIME:function(e,t){e.lastRefreshTime=t}},b={ssoToken:function(e){return e.ssoToken},tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo},lastRefreshTime:function(e){return e.lastRefreshTime},currentOrgId:function(e){return e.currentOrg},userOrgId:function(e){return e.userInfo?e.userInfo.organizationId:""}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:d(d(d({},g),t),r),actions:v(e),mutations:y,getters:b}},_=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"],O(t,e.state.doraemon.oauth||{},r)))};function w(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}function k(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function u(e){w(a,n,o,u,c,"next",e)}function c(e){w(a,n,o,u,c,"throw",e)}u(void 0)}))}}function x(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}var P=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},c);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 u(e){x(a,n,o,u,c,"next",e)}function c(e){x(a,n,o,u,c,"throw",e)}u(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function j(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){T(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}var I={dictMap:{}},D=function(e){var t=P(e);return{getDictionary:function(e,r){return(n=regeneratorRuntime.mark((function n(){var o,a,u,c,i,s,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=e.commit,a=e.state,u=a.dictMap,c=r.code,i=r.cache,s=void 0===i||i,!u.hasOwnProperty(c)||!s){n.next=10;break}return n.next=7,Promise.resolve(u[c]);case 7:return n.abrupt("return",n.sent);case 10:return n.next=12,t.dict(c);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",T({},c,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 u(e){E(a,r,o,u,c,"next",e)}function c(e){E(a,r,o,u,c,"throw",e)}u(void 0)}))})();var n}}},S={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},M={},U=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:R(R({},I),t),actions:D(e),mutations:S,getters:M}}(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]:{};arguments.length>4&&void 0!==arguments[4]&&arguments[4];t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),_(t,r,n),u(t,r),e.prototype.do_refresh_token=function(){var e=k(regeneratorRuntime.mark((function e(r){var n,o,a,u,c,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=t.getters["doraemon/oauth/tokenInfo"])||!n.refresh_token){e.next=14;break}if(o=n.expires_in,a=n.refresh_token,u=n.last,c=1e3*o,!((i=Date.now()-u)>c)){e.next=13;break}if(!r){e.next=10;break}r(),e.next=11;break;case 10:throw new Error("超过token刷新时间请跳转到登录页。");case 11:e.next=14;break;case 13:setTimeout(k(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.dispatch("doraemon/oauth/refresh",{refresh_token:a});case 2:case"end":return e.stop()}}),e)}))),c-i);case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.prototype.do_sso_by_token=function(){var e=k(regeneratorRuntime.mark((function e(r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.commit("doraemon/oauth/UPDATE_SSO_TOKEN",r),e.t0=n,!e.t0){e.next=5;break}return e.next=5,t.dispatch("doraemon/oauth/getUserInfo",{userName:n});case 5:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},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}),U(t,r)}}}])}));
{
"name": "@ourea/doraemon-kit",
"version": "1.0.20",
"version": "1.0.24",
"description": "",

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

# Doraemon-kit
> 注意 对vuex 的版本需要在 @3.4.0
## Oauth

@@ -4,0 +6,0 @@

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

// eslint-disable-next-line no-unused-vars
export default (Vue, store, http, state = {}) => {
export default (Vue, store, http, state = {}, sync = false)=> {
if (!store.hasModule('doraemon')) {

@@ -8,0 +8,0 @@ store.registerModule('doraemon', { namespaced: true, state: store.state['doraemon'] })

@@ -31,3 +31,6 @@

} else {
throw new Error('缺少鉴权信息')
const error = new Error()
error.message = '缺少鉴权信息'
error.code = 401
throw error
}

@@ -34,0 +37,0 @@ }

@@ -21,2 +21,3 @@ /* eslint-disable no-empty-pattern */

ssoToken: null, // 单点登录的token
currentOrg: '', // 当前的一个组织机构信息
}

@@ -88,2 +89,4 @@

state.userInfo = info
const { currentOrg, organizationId } = info
state.currentOrg = currentOrg || organizationId
},

@@ -110,2 +113,8 @@ UPDATE_LAST_REFRESH_TIME(state, time) {

return state.lastRefreshTime
},
currentOrgId(state) {
return state.currentOrg
},
userOrgId(state) {
return state.userInfo ? state.userInfo.organizationId : ''
}

@@ -112,0 +121,0 @@ }

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