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.5 to 1.0.6

dist/index.js.map

70

dist/index.d.ts

@@ -0,9 +1,71 @@

// Generated by dts-bundle-generator v5.9.0
import { AxiosInstance } from 'axios';
export interface IContext {
headers: Record<string, string>;
request?: IContext;
}
export declare type nullable = string | null;
export interface CurrentResponse {
_id: string;
username: string;
nickname?: string;
openid?: string;
anonymousOpenid?: string;
unionid?: string;
platform?: string;
avatar: nullable;
passhash?: nullable;
secret?: nullable;
email: nullable;
phoneNumber: nullable;
intro: nullable;
lastIp: nullable;
lastLogin: number | null;
loginCount: number;
agent: nullable;
status: boolean;
firstProvider: string;
createAt: number;
createdAt: number;
updatedAt: number;
[k: string]: any;
}
export interface RegisterResponse {
isLogin: boolean;
sessionKey: string;
userInfo: CurrentResponse;
}
export interface SendSMSOptions {
region?: string;
}
export interface SendSMSResponse {
createdAt: number;
account: string;
messageId: string;
success: boolean;
}
declare class User {
readonly serviceId: string;
readonly axios: AxiosInstance;
constructor(serviceId: string, axiosInstance: AxiosInstance);
current: (ctx: any) => Promise<any>;
private readonly serviceId;
private readonly axios;
constructor(serviceId: string, axiosInstance: AxiosInstance);
private request;
private bind;
current: (ctx: IContext) => Promise<CurrentResponse>;
logout: (ctx: IContext) => Promise<{
success: boolean;
}>;
login: (ctx: IContext, account: string, password: string) => Promise<any>;
loginByPhone: (ctx: IContext, account: string, code: string) => Promise<any>;
register: (ctx: IContext, account: string, password: string) => Promise<RegisterResponse>;
updateOne: (ctx: IContext, user: Partial<CurrentResponse>) => Promise<CurrentResponse>;
sendSMS: (ctx: IContext, account: string, opt?: SendSMSOptions | undefined) => Promise<SendSMSResponse>;
changePassword: (ctx: IContext, newPassword: string, originPassword?: string | undefined) => Promise<{
success: boolean;
}>;
}
export declare function createUserSDK(serviceId: string, axiosInstance: AxiosInstance): User;
export default User;
export {};

9

dist/index.js

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

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

@@ -8,25 +8,11 @@ "main": "dist/index.js",

"files": [
"dist",
"src"
"dist"
],
"engines": {
"node": ">=10"
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
"dev": "tsm dev",
"build": "tsm build",
"lint": "tsm lint",
"dts": "dts-bundle-generator -o dist/index.d.ts --no-check --silent src/index.ts",
"prepare": "tsm build"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"publishConfig": {
"access": "public"
},
"prettier": {

@@ -39,25 +25,9 @@ "printWidth": 80,

"author": "郭秀峰",
"module": "dist/user.esm.js",
"size-limit": [
{
"path": "dist/user.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/user.esm.js",
"limit": "10 KB"
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^5.0.1",
"@types/jest": "^26.0.23",
"axios": "^0.21.1",
"babel-plugin-module-resolver": "^4.1.0",
"husky": "^6.0.0",
"size-limit": "4.10.2",
"tsdx": "^0.14.1",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
},
"gitHead": "4e09ed344b26cce4873a6503fbe54d21e3c99e4e"
"publishConfig": {
"access": "public"
},
"gitHead": "bfde2cd1c51f17c59371308a350a2a1168252380"
}
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