
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@ebscn/adapter
Advanced tools
1.0.0-beta.2 修复端外手机号登录问题
用户登录:
await getAuthParam(5, 1, requestFlag); requestFlag 0 读取缓存 token 1 网络请求 token
注:
1)requestFlag 通常默认传 0 , 如果接口返回验权失败错误号,再 requestFlag = 1 2)该支持包最终会提供 http 方法,无需调用方做 setheader
return type GetAuthParamJWTResult = { 'api-token'?: string; };
1)判断客户端版本号是否支持,如不支持调转到 app 下载页面 2)判断当前用户是否已登录,未登录则调用登录框自动登录并回调 token 3)支持 pc 调试,可模拟 app 返回数据
请参考 dist/docs 文档
字典值:jyg(金阳光) web(浏览器) wx(微信端)
type AppIdType = 'jyg' | 'web' | 'wx'
export const getAppId = ()=>AppIdType
/**
* 检查登录状态 - web交易登录上线后需要扩展
* @function checkLogin
* @param {number} account_type 登录类型 0 普通账户, 1 信用账号, 3 期权账号, 5 用户
* @param {string} appid 当前环境 非必传,默认取自getAppId方法返回值
* @returns {Promise<{code, msg, data}>}
*/
type AccountType = 0 | 1 | 3 | 5
export const checkLogin = async (account_type: AccountType, appid?: AppIdType)=>Promise<{
code: 0 | any, // code为0时成功,其他值错误
msg:string, // 报错/成功信息
data: string // 登录的对应类型账号值
}
需注意app端外暂不支持信用和期权账号
/**
* 检查登录状态并在未登录情况下调用登录功能 - web交易登录上线后需要扩展
* @function beginLogin
* @param {number} loginType 登录类型 0 普通账户, 1 信用账号, 3 期权账号, 5 用户
* @param {string} appid 当前环境 非必传,默认取自getAppId方法返回值
* @returns {Promise<any>}
*/
export const beginLogin = async (
account_type: AccountType = 0,
appid?: 'web' | 'wx' | 'jyg'
)=> Promise<{
code: 0 | any, // code为0时成功,其他值错误
msg:string, // 报错/成功信息
data: string // 登录的对应类型账号值
}>
/**
* 检查登录状态并在未登录情况下调用登录功能 - web交易登录上线后需要扩展
* @function getAuth
* @param {number} account_type 登录类型 0 普通账户, 1 信用账号, 3 期权账号, 5 用户
* @param {number} version 统一认证版本 0 老版本(缺省) 1 新版本
* @param {number} requestFlag 是否丛缓存读取 0 读取缓存 1 请求最新
* @param {string} appid 当前环境 非必传,默认取自getAppId方法返回值
* @param {number | string} staleTime 单位秒,端外登录的缓存失效时间,默认与统一认证保持一致,900秒
* @returns {Promise<any>}
*/
// 统一认证老版本票据
type GetAuthParamTicketResult = {
appid?: number | undefined;
authId?: string | undefined;
authType?: string | undefined;
ipAddress?: string | undefined;
terminalWay?: string | undefined;
macAddress?: string | undefined;
serviceTicketId?: string | undefined;
checkString?: string | undefined;
}
// 统一认证新版本token
type GetAuthParamJWTResult = {
appid?: string | undefined;
'api-token'?: string | undefined; // token
userId?: string | undefined; // 手机号登录的userId
accountValue?: string | undefined; // 登录账号值
}
export const getAuthParam = async (account_type: AccountType = 0,
version: VersionType = 1,
requestFlag: RequestFlagType = 0,
appid?: string,
staleTime?: string | number)
=>Promise<GetAuthParamTicketResult | GetAuthParamJWTResult | {
code,
msg
}>
interface HttpRequestParams extends AxiosRequestConfig {
version?: VersionType。 // 认证版本,同上
account_type?: AccountType // 账号类型,同上
errorHandler?: (errorMsg:string)=>void // 自定义错误请求函数,可拿到请求的错误msg信息
noAuth?: boolean //为true时不鉴权(判断优先级高于version和account_type) 不传时version和account_type必传
appid?: AppIdType
onAuthCb?: (
authParams: void | LoginResultParam | GetAuthParamTicketResult | GetAuthParamJWTResult
requestFlag: number
) => void // 获取认证参数之后的钩子函数
staleTime?: number | string // 端外登录的token主动过期时间 单位秒 同getAuthParam中的staleTime
}
export const http = async <T = object>(
params: HttpRequestParams
) => Promise<{ code: string | number; msg: string; data?: T }>
/**
*
* @param paramStr urlQuery拼接形式,支持参数见jssdk文档goWebview方法 如targetUrl=encodeURIComponent(${targetUrl})&navBarStyle=3
* @param appid 当前环境,不传默认从jssdk获取
* @param environment app环境,默认测试环境
* @param newVersionOnly 是否只运行在金阳光7020版本及以上,默认false
* @param withDownload 是否用通用下载页承载端外跳转功能 默认false
* @param msgPush 是否站内信推送超链接格式 默认false
* @returns scheme 返回生成的scheme
*/
type generateTransformPageParams = {
paramStr: string
environment?: 0 | 1 | 2 // 0 测试 1 仿真 2生产
appid?: 'jyg' | 'wx' | 'web' // 打开端
newVersionOnly?: boolean // 是否7000版本后
withDownload?: boolean // 是否通过下载页打开
msgPush?: boolean // 是否用于消息推送
}
export const generateTransformPage = async (params: generateTransformPageParams)=>string
FAQs
adapter beta
We found that @ebscn/adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.