Socket
Socket
Sign inDemoInstall

@byteinspire/user

Package Overview
Dependencies
0
Maintainers
7
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.9 to 1.0.10

2

dist/index.js

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

(()=>{"use strict";var h={};(()=>{h.d=(i,s)=>{for(var t in s)h.o(s,t)&&!h.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:s[t]})}})(),(()=>{h.o=(i,s)=>Object.prototype.hasOwnProperty.call(i,s)})(),(()=>{h.r=i=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})}})();var v={};h.r(v),h.d(v,{createUserSDK:()=>oe,default:()=>le});var x=function(i){var s=typeof i;return i!=null&&(s==="object"||s==="function")};const S=x;var w=["`phone_code`","`email`","`username`"],b="x-tt-session-v2",E="x-larkcloud-user-v1";function y(i){return i&&i.headers&&i.headers[b]}y.ContextError=new Error("context missing params");const _=y;function k(i){return i&&i._id&&(typeof i._id=="string"||typeof i.toHexString=="function")}const I=k;function O(i){var s,t;if((t=(s=i.response)===null||s===void 0?void 0:s.data)===null||t===void 0?void 0:t.message)throw new Error(i.response.data.message)}const q=O;function d(i){return i}var T=d(function(i){return function(){return i.request("current",{url:"/api/v1/services/"+i.serviceId+"/users/current",method:"GET",headers:i.headers})}});const B=T;var C=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},M=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},j=d(function(i){return function(){return C(void 0,void 0,void 0,function(){return M(this,function(s){switch(s.label){case 0:return[4,i.request("logout",{url:"/api/v1/services/"+i.serviceId+"/users/logout",headers:i.headers,method:"POST"})];case 1:return s.sent(),[2,{success:!0}]}})})}});const F=j;var G=function(i){return!0},D=function(i){return/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(i)},U=function(i){if(!w.includes("`"+i+"`")){var s="\u672A\u652F\u6301\u7684 provider: `"+i+"`. "+("\u76EE\u524D\u4EC5\u652F\u6301: "+w.join(",")+".");throw new Error(s)}},g=function(i,s){var t=!1;switch(U(s),s){case"phone_code":t=G(i);break;case"email":t=D(i);break;case"username":t=!0;break;default:throw new Error("\u4E0D\u652F\u6301\u7684\u6CE8\u518C\u65B9\u5F0F: `"+s+"`. \u8BF7\u68C0\u67E5!")}if(!t)throw new Error("\u8F93\u5165\u7684\u8D26\u53F7\u4E0D\u5408\u6CD5: `"+i+"`. \u8BF7\u68C0\u67E5!")},P=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},K=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},R=d(function(i){return function(s,t){return P(void 0,void 0,void 0,function(){var a,r;return K(this,function(e){switch(e.label){case 0:if(!t)throw new Error("\u5BC6\u7801\u53C2\u6570\u7F3A\u5931");return a="username",g(s,a),[4,i.request("login",{url:"/api/v1/services/"+i.serviceId+"/users/login",method:"post",headers:i.headers,data:{provider:a,account:s,password:t}})];case 1:return r=e.sent().userInfo,[2,r]}})})}});const V=R;var A=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},N=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},Y=d(function(i){return function(s,t){return A(void 0,void 0,void 0,function(){var a;return N(this,function(r){switch(r.label){case 0:return[4,i.request("loginByPhone",{url:"/api/v1/services/"+i.serviceId+"/users/loginByPhone",method:"post",headers:i.headers,data:{account:s,code:t}})];case 1:return a=r.sent().userInfo,[2,a]}})})}});const z=Y;var H=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},L=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},$=d(function(i){return function(s,t){return H(void 0,void 0,void 0,function(){return L(this,function(a){if(!t)throw new Error("\u5BC6\u7801\u53C2\u6570\u7F3A\u5931");return[2,i.request("register",{url:"/api/v1/services/"+i.serviceId+"/users/register",method:"post",headers:i.headers,data:{account:s,password:t,provider:"username"}})]})})}});const J=$;var Q=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},W=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},X=d(function(i){return function(s){return Q(void 0,void 0,void 0,function(){return W(this,function(t){return[2,i.request("updateOne",{url:"/api/v1/services/"+i.serviceId+"/users",method:"put",headers:i.headers,data:{user:s}})]})})}});const Z=X;var p=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},ee=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},ne=d(function(i){return function(s,t){return t===void 0&&(t={}),p(void 0,void 0,void 0,function(){var a;return ee(this,function(r){return a="phone_code",g(s,a),[2,i.request("sendSMS",{url:"/api/v1/services/"+i.serviceId+"/msg/sms",method:"post",data:{account:s,region:t.region}})]})})}});const te=ne;var re=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},ie=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},ue=d(function(i){return function(s,t){return re(void 0,void 0,void 0,function(){var a;return ie(this,function(r){switch(r.label){case 0:return a="username",[4,i.request("changePassword",{url:"/api/v1/services/"+i.serviceId+"/users/password/modify",headers:i.headers,method:"put",data:{oldPassword:t,newPassword:s,provider:a}})];case 1:return r.sent(),[2,{success:!0}]}})})}});const ae=ue;var ce=function(i,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function o(u){try{n(a.next(u))}catch(f){c(f)}}function l(u){try{n(a.throw(u))}catch(f){c(f)}}function n(u){u.done?e(u.value):r(u.value).then(o,l)}n((a=a.apply(i,s||[])).next())})},se=function(i,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function o(n){return function(u){return l([n,u])}}function l(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(i,t)}catch(u){n=[6,u],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},m=function(){function i(s,t){var a=this;if(this.request=function(r,e){return ce(a,void 0,void 0,function(){var c,o;return se(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),e.headers=Object.assign(e.headers||{},{"x-lang":"lang_zh"}),[4,this.axios.request(e)];case 1:return c=l.sent(),[2,c.data.data];case 2:throw o=l.sent(),q(o),new Error(r+" error: "+o);case 3:return[2]}})})},this.bind=function(r){return function(e){for(var c=[],o=1;o<arguments.length;o++)c[o-1]=arguments[o];if(I(e))return e;var l=S(e.request)?e.request:e;if(!_(l))throw _.ContextError;var n={};return n[b]=l.headers[b]||l.headers[E],r({serviceId:a.serviceId,request:a.request,ctx:l,headers:n}).apply(void 0,c)}},this.current=this.bind(B),this.logout=this.bind(F),this.login=this.bind(V),this.loginByPhone=this.bind(z),this.register=this.bind(J),this.updateOne=this.bind(Z),this.sendSMS=this.bind(te),this.changePassword=this.bind(ae),this.serviceId=s,this.axios=t,!this.serviceId||!this.axios)throw new Error("@byteinspire/user: Missing arguments.")}return i}();function oe(i,s){return new m(i,s)}const le=m;module.exports=v})();
(()=>{"use strict";var h={};(()=>{h.d=(u,s)=>{for(var t in s)h.o(s,t)&&!h.o(u,t)&&Object.defineProperty(u,t,{enumerable:!0,get:s[t]})}})(),(()=>{h.o=(u,s)=>Object.prototype.hasOwnProperty.call(u,s)})(),(()=>{h.r=u=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})}})();var v={};h.r(v),h.d(v,{createUserSDK:()=>oe,default:()=>de});var x=function(u){var s=typeof u;return u!=null&&(s==="object"||s==="function")};const S=x;var w=["`phone_code`","`email`","`username`"],b="x-tt-session-v2",k="x-larkcloud-user-v1";function y(u){return u&&u.headers&&u.headers[b]}y.ContextError=new Error("context missing params");const _=y;function E(u){return u&&u._id&&(typeof u._id=="string"||typeof u.toHexString=="function")}const I=E;function O(u){var s,t;if((t=(s=u.response)===null||s===void 0?void 0:s.data)===null||t===void 0?void 0:t.message)throw new Error(u.response.data.message)}const q=O;function d(u){return u}var T=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},B=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},C=d(function(u){return function(){return T(void 0,void 0,void 0,function(){var s;return B(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.request("current",{url:"/api/v1/services/"+u.serviceId+"/users/current",method:"GET",headers:u.headers})];case 1:return[2,t.sent()];case 2:return s=t.sent(),[2,void 0];case 3:return[2]}})})}});const G=C;var M=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},j=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},F=d(function(u){return function(){return M(void 0,void 0,void 0,function(){return j(this,function(s){switch(s.label){case 0:return[4,u.request("logout",{url:"/api/v1/services/"+u.serviceId+"/users/logout",headers:u.headers,method:"POST"})];case 1:return s.sent(),[2,{success:!0}]}})})}});const D=F;var U=function(u){return!0},P=function(u){return/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(u)},K=function(u){if(!w.includes("`"+u+"`")){var s="\u672A\u652F\u6301\u7684 provider: `"+u+"`. "+("\u76EE\u524D\u4EC5\u652F\u6301: "+w.join(",")+".");throw new Error(s)}},g=function(u,s){var t=!1;switch(K(s),s){case"phone_code":t=U(u);break;case"email":t=P(u);break;case"username":t=!0;break;default:throw new Error("\u4E0D\u652F\u6301\u7684\u6CE8\u518C\u65B9\u5F0F: `"+s+"`. \u8BF7\u68C0\u67E5!")}if(!t)throw new Error("\u8F93\u5165\u7684\u8D26\u53F7\u4E0D\u5408\u6CD5: `"+u+"`. \u8BF7\u68C0\u67E5!")},R=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},V=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},A=d(function(u){return function(s,t){return R(void 0,void 0,void 0,function(){var a,r;return V(this,function(e){switch(e.label){case 0:if(!t)throw new Error("\u5BC6\u7801\u53C2\u6570\u7F3A\u5931");return a="username",g(s,a),[4,u.request("login",{url:"/api/v1/services/"+u.serviceId+"/users/login",method:"post",headers:u.headers,data:{provider:a,account:s,password:t}})];case 1:return r=e.sent().userInfo,[2,r]}})})}});const N=A;var Y=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},z=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},H=d(function(u){return function(s,t){return Y(void 0,void 0,void 0,function(){var a;return z(this,function(r){switch(r.label){case 0:return[4,u.request("loginByPhone",{url:"/api/v1/services/"+u.serviceId+"/users/loginByPhone",method:"post",headers:u.headers,data:{account:s,code:t}})];case 1:return a=r.sent().userInfo,[2,a]}})})}});const L=H;var $=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},J=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},Q=d(function(u){return function(s,t){return $(void 0,void 0,void 0,function(){return J(this,function(a){if(!t)throw new Error("\u5BC6\u7801\u53C2\u6570\u7F3A\u5931");return[2,u.request("register",{url:"/api/v1/services/"+u.serviceId+"/users/register",method:"post",headers:u.headers,data:{account:s,password:t,provider:"username"}})]})})}});const W=Q;var X=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},Z=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},p=d(function(u){return function(s){return X(void 0,void 0,void 0,function(){return Z(this,function(t){return[2,u.request("updateOne",{url:"/api/v1/services/"+u.serviceId+"/users",method:"put",headers:u.headers,data:{user:s}})]})})}});const ee=p;var ne=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},te=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},re=d(function(u){return function(s,t){return t===void 0&&(t={}),ne(void 0,void 0,void 0,function(){var a;return te(this,function(r){return a="phone_code",g(s,a),[2,u.request("sendSMS",{url:"/api/v1/services/"+u.serviceId+"/msg/sms",method:"post",data:{account:s,region:t.region}})]})})}});const ie=re;var ue=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},ae=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},ce=d(function(u){return function(s,t){return ue(void 0,void 0,void 0,function(){var a;return ae(this,function(r){switch(r.label){case 0:return a="username",[4,u.request("changePassword",{url:"/api/v1/services/"+u.serviceId+"/users/password/modify",headers:u.headers,method:"put",data:{oldPassword:t,newPassword:s,provider:a}})];case 1:return r.sent(),[2,{success:!0}]}})})}});const se=ce;var le=function(u,s,t,a){function r(e){return e instanceof t?e:new t(function(c){c(e)})}return new(t||(t=Promise))(function(e,c){function l(i){try{n(a.next(i))}catch(o){c(o)}}function f(i){try{n(a.throw(i))}catch(o){c(o)}}function n(i){i.done?e(i.value):r(i.value).then(l,f)}n((a=a.apply(u,s||[])).next())})},fe=function(u,s){var t={label:0,sent:function(){if(e[0]&1)throw e[1];return e[1]},trys:[],ops:[]},a,r,e,c;return c={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function l(n){return function(i){return f([n,i])}}function f(n){if(a)throw new TypeError("Generator is already executing.");for(;t;)try{if(a=1,r&&(e=n[0]&2?r.return:n[0]?r.throw||((e=r.return)&&e.call(r),0):r.next)&&!(e=e.call(r,n[1])).done)return e;switch(r=0,e&&(n=[n[0]&2,e.value]),n[0]){case 0:case 1:e=n;break;case 4:return t.label++,{value:n[1],done:!1};case 5:t.label++,r=n[1],n=[0];continue;case 7:n=t.ops.pop(),t.trys.pop();continue;default:if(e=t.trys,!(e=e.length>0&&e[e.length-1])&&(n[0]===6||n[0]===2)){t=0;continue}if(n[0]===3&&(!e||n[1]>e[0]&&n[1]<e[3])){t.label=n[1];break}if(n[0]===6&&t.label<e[1]){t.label=e[1],e=n;break}if(e&&t.label<e[2]){t.label=e[2],t.ops.push(n);break}e[2]&&t.ops.pop(),t.trys.pop();continue}n=s.call(u,t)}catch(i){n=[6,i],r=0}finally{a=e=0}if(n[0]&5)throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},m=function(){function u(s,t){var a=this;if(this.request=function(r,e){return le(a,void 0,void 0,function(){var c,l;return fe(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),e.headers=Object.assign(e.headers||{},{"x-lang":"lang_zh"}),[4,this.axios.request(e)];case 1:return c=f.sent(),[2,c.data.data];case 2:throw l=f.sent(),q(l),new Error(r+" error: "+l);case 3:return[2]}})})},this.bind=function(r){return function(e){for(var c=[],l=1;l<arguments.length;l++)c[l-1]=arguments[l];if(I(e))return e;var f=S(e.request)?e.request:e;if(!_(f))throw _.ContextError;var n={};return n[b]=f.headers[b]||f.headers[k],r({serviceId:a.serviceId,request:a.request,ctx:f,headers:n}).apply(void 0,c)}},this.current=this.bind(G),this.logout=this.bind(D),this.login=this.bind(N),this.loginByPhone=this.bind(L),this.register=this.bind(W),this.updateOne=this.bind(ee),this.sendSMS=this.bind(ie),this.changePassword=this.bind(se),this.serviceId=s,this.axios=t,!this.serviceId||!this.axios)throw new Error("@byteinspire/user: Missing arguments.")}return u}();function oe(u,s){return new m(u,s)}const de=m;module.exports=v})();
//# sourceMappingURL=index.js.map
{
"name": "@byteinspire/user",
"version": "1.0.9",
"version": "1.0.10",
"license": "MIT",

@@ -29,3 +29,3 @@ "main": "dist/index.js",

},
"gitHead": "87fcf08ebaa4703dee0b20f5ae6c982b8f66ae69"
"gitHead": "5a0f4514ad4ad0e8fdad9c8c0918b5bf5127eddb"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc