npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yeefox/auth-sdk

v1.7.1

Published

Authorization Sdk for yeefox

Downloads

39

Readme

@yeefox/auth-sdk

以狐钱包授权SDK (1.6.0)

安装

通过npm 安装

npm install @yeefox/auth-sdk

如何引入

打包后的版本在 lib 文件夹

import {YEEFOX_AUTH, YeefoxAuthSdk} from "@yeefox/auth-sdk/lib";

如果您使用打包工具, 可也以这样

import {YEEFOX_AUTH, YeefoxAuthSdk} from "@yeefox/auth-sdk";

或者在浏览器直接引入

<script type="text/javascript" src="node_modules/@yeefox/auth-sdk/lib/index.umd.js"></script>
<script type="text/javascript">
    const appId="xxx";
	const yeefoxAuth = window.YEEFOX.YeefoxAuthSdk.instance(appId);
</script>

使用申请授权接口前, 初始化必须传入 appId, 使用DApp授权接口则不需要

调用方法

  • 初始化SDK, 使用单例模式, 用instance方法获得实例

    const appId="xxx";
    const yeefoxAuth = YeefoxAuthSdk.instance(appId);

申请授权接口 (需要appId)

调用方式

直接调用实例的对应方法, 第一个参数为业务参数, 必填, 各个接口第一个参数见下面接口列表. 第二个参数为验签相关, 如果不希望用户收到未签名的警告, 请传入第二个参数. 第二个参数的内容为

| 参数字段 | 名称 | 类型 | | --------- | ------ | ------ | | sign | 签名 | 字符串 | | timestamp | 时间戳 | 数字 |

其中sign的生成方式和Gate平台请求一致. 第一个参数的内容作为业务参数, 让后端对

{
	appId: <APP ID>
	bizContent: <业务参数>
	timeStamp: <时间戳>
}

进行签名, 将得到sign和timestamp返回至前端并传递给第二个参数

如果没有传递第二个签名参数, 该请求可能会被用户或者以狐直接拒绝掉.

返回值为异步返回(Promise), 内容是授权序列号, 将序列号交于后端以实际执行授权.

接口及参数列表

  1. 申请授权用户信息接口(grantUserInfo)

    | 字段名 | 类型 | 必选 | 说明 | | ---------- | ---------- | -------------------------- | ------------------------------------------------------------ | | fields | 字符串数组 | 是 | 需要获取用户信息列表选项及含义见附录2 | | chain | 字符串 | 在fields中包含wallet时必填 | 以狐钱包链代码选项及含义见附录1 | | walletType | 字符串 | 否 | chain参数为 wenchang-tianzhou 时有效0x是EVM链地址格式, iaa是原生链地址格式 |

  2. 申请授权用户资产列表查看接口(grantAssetView)

    | 字段名 | 类型 | 必选 | 说明 | | ------ | ---------- | ---- | ------------------------------------------------------------ | | chains | 字符串数组 | 否 | 授权链列表. 当设置时, 用户只能在选择的链中授权链地址选项及含义见附录1 |

  3. 申请授权用户资产托管接口(grantAssetHosting)

    | 字段名 | 类型 | 必选 | 说明 | | -------- | ------ | ---- | ---------------------------------------------------------- | | chain | 字符串 | 是 | 以狐钱包链代码选项及含义见附录1 | | class_id | 字符串 | 是 | 资产的分类ID | | token_id | 字符串 | 是 | 资产的TokenID | | type | 数字 | 是 | 资产类型选项及含义见附录3 | | amount | 数字 | 是 | 在 type 是 137和721时固定为1是1155时为需要托管的数量 |

  4. 申请授权用户资产转移接口(grantAssetTransfer)

    | 字段名 | 类型 | 必选 | 说明 | | --------- | ------ | ---- | ---------------------------------------------------------- | | chain | 字符串 | 是 | 以狐钱包链代码选项及含义见附录1 | | class_id | 字符串 | 是 | 资产的分类ID | | token_id | 字符串 | 是 | 资产的TokenID | | type | 数字 | 是 | 资产类型选项及含义见附录3 | | amount | 数字 | 是 | 在 type 是 137和721时固定为1是1155时为需要托管的数量 | | recipient | 字符串 | 是 | 接收者地址 |

调用示例

try{
    const params = {
        fields: [YEEFOX_AUTH.UserInfoField.CODE, YEEFOX_AUTH.UserInfoField.WALLET, YEEFOX_AUTH.UserInfoField.PHONE],
        chain: "wenchang-tianzhou"
    }
    const signInfo = await requestSign(params);
    
    const serial = await yeefoxAuth.grantUserInfo(params, signInfo);
    console.log("授权成功, 凭证序列号",serial)
}
catch(e){
    console.error("授权失败", e);
}

如果授权发生错误(用户拒绝, 参数错误等) 会抛出错误.

DApp授权接口 (不需要appId)

调用方式

直接调用实例的对应方法, 第一个参数为业务参数, 必填, 各个接口第一个参数见下面接口列表.

返回值为异步返回(Promise), 内容是各个接口的实际返回内容, 返回内容见下面接口列表.

在调用DApp接口前应该先检测DApp环境是否有效

if(YeefoxAuthSdk.dappAvailable()){
    ...
}
else{
    console.error("未检测到DApp环境")
}

接口及参数列表

  1. DApp授权用户信息(getUserInfo)

    | 字段名 | 类型 | 必选 | 说明 | | ------ | ---------- | -------------------------- | ------------------------------------------------------------ | | fields | 字符串数组 | 是 | 需要获取用户信息列表选项及含义见附录2, 只能取codewallet两个值 | | chain | 字符串 | 在fields中包含wallet时必填 | 以狐钱包链代码选项及含义见附录1 |

    返回值为对象

    {
    	"code": "用户码",
    	"wallet":"链地址"
    }

调用示例

if(YeefoxAuthSdk.dappAvailable()){
    try {
        const result = await yeefoxAuth.getUserInfo({
            fields: [
                YEEFOX_AUTH.UserInfoField.CODE,
                YEEFOX_AUTH.UserInfoField.WALLET,
            ],
            chain: 'wenchang-tianzhou',
        });

        console.log("授权成功, 用户信息",result)
    }
    catch (e){
        console.error("授权失败", e);
    }
}
else{
    console.error("未检测到DApp环境")
}

附录

1. 以狐钱包链代码(2023-09-26)

| 链代码 | 链名称 | | ----------------- | ------ | | wenchang-tianhe | 天和链 | | wenchang-tianzhou | 天舟链 | | conflux | 树图链 |

2. 用户信息字段含义

| UserInfoField 代码 | 值(字符串) | 意义 | | ------------------ | ---------- | ------ | | CODE | code | 用户码 | | WALLET | wallet | 链地址 | | PHONE | phone | 手机号 | | NICK_NAME | nickName | 昵称 |

3. 资产类型

| 值(数字) | 意义 | | -------- | ----------------------- | | 137 | Web3域名 | | 721 | NFT(Non-Fungible Token) | | 1155 | MT(Multi-Token) |