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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@alipay/faas-biz-server-sdk

v1.1.5

Published

支付宝云开发业务 SDK(函数端)

Downloads

141

Readme

云函数SDK

@alipay/faas-biz-server-sdk 在服务端(云函数)中使用 Node.js 访问云开发用户身份服务。

安装

可以通过 npm 安装:

npm i @alipay/faas-biz-server-sdk

API

Websocket

Websocket API 请点击

getCurrentUser()

接口功能:获取用户信息 输入参数:无 返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID | | userPoolUid | string | 是 | 用户池ID | | idpUid | string | 是 | 身份提供商ID | | idpUserId | string | 是 | 用户ID,在此供应商范围内唯一 | | username | string | 是 | 用户名 | | mobile | string | 否 | 手机号 | | email | string | 否 | 邮箱地址 | | avatar | string | 否 | 头像 | | locked | boolean | 是 | 是否锁定,默认false |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const userInfo = await auth.getUserInfo();
  return userInfo;
};

getUser() TODO

createUser()

接口功能:创建用户 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | idpUid | string | 是 | 身份提供商ID | | idpUserId | string | 是 | 用户ID,在此供应商范围内唯一 | | username | string | 是 | 用户名 | | password | string | 是 | 密码 | | mobile | string | 否 | 手机号 | | email | string | 否 | 邮箱地址 | | avatar | string | 否 | 头像 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.createUser(event.userPoolUid, event.idpUid, event.idpUserId, event.userName, event.password, event.mobile, event.email, event.avatar);
  return result;
};

deleteUser()

接口功能:删除用户 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 删除是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.deleteUser(event.uid);
  return result;
};

modifyUserPassword()

接口功能:修改用户密码 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID | | curPassword | string | 是 | 当前密码 | | newPassword | string | 是 | 新密码 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.modifyUserPassword(event.uid, event.curPassword, event.newPassword);
  return result;
};

modifyUser()

接口功能:修改用户信息 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID | | username | string | 否 | 用户名 | | mobile | string | 否 | 手机号 | | email | string | 否 | 邮箱地址 | | avatar | string | 否 | 头像 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.modifyUserInfo(event.uid, event.userName, event.mobile, event.email, event.avatar);
  return result;
};

checkUserPassword()

接口功能:校验用户密码 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID | | password | string | 是 | 当前密码 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.checkUserPassword(event.uid, event.password);
  return result;
};

resetUserPassword()

接口功能:无需当前密码,直接重置用户密码 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID | | newPassword | string | 是 | 新密码 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.resetUserPassword(event.uid, event.newPassword);
  return result;
};

lockUser()

接口功能:锁定用户 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.lockUser(event.uid);
  return result;
};

unlockUser()

接口功能:解锁用户 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 用户UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.unlockUser(event.uid);
  return result;
};

queryUsers()

接口功能:查询用户 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | idpUid | string | 否 | 身份提供商ID | | idpUserId | string | 否 | 用户ID,在此供应商范围内唯一 | | username | string | 否 | 用户名 | | locked | string | 否 | 是否冻结 | | pageIndex | int | 否 | 起始页 | | pageSize | int | 否 | 页行数 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | total | int | 是 | 查询结果总数 | | pageIndex | int | 是 | 当前行 | | pageSize | int | 是 | 页行数 | | users | User[] | 是 | 查询结果集 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const userList = await auth.queryUsers(event.userPoolUid, event.idpUid, event.idpUserId, event.locked, event.pageIndex, event.pageSize);
  return userList;
};

createRole()

接口功能:创建角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | name | string | 是 | 角色编码 | | displayName | string | 是 | 角色名 | | description | string | 否 | 备注 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 角色UID |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.createRole(event.userPoolUid, event.name, event.displayName, event.description);
  return result;
};

deleteRole()

接口功能:删除角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 角色UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 删除是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.deleteRole(event.uid);
  return result;
};

getRole()

接口功能:获取角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 角色UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 角色UID | | userPoolUid | string | 是 | 用户池ID | | name | string | 是 | 角色编码 | | displayName | string | 是 | 角色名 | | description | string | 否 | 备注 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.getRoleInfo(event.uid);
  return result;
};

queryRoles()

接口功能:查询角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | name | string | 否 | 角色编码 | | pageIndex | int | 否 | 起始页索引 | | pageSize | int | 否 | 每页条数 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | total | int | 是 | 查询结果总数 | | pageIndex | int | 是 | 当前行 | | pageSize | int | 是 | 页行数 | | roles | Roles[] | 是 | 查询结果集 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.queryRoles(event.userPoolUid, event.name, event.pageIndex, event.pageSize);
  return result;
};

modifyRole()

接口功能:修改角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 角色UID | | name | string | 否 | 角色编码 | | displayName | string | 否 | 角色名称 | | description | string | 否 | 备注 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改角色是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.modifyRoleInfo(event.uid, event.name, event.displayName, event.description);
  return result;
};

createPermission()

接口功能:创建权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | name | string | 是 | 权限编码 | | displayName | string | 是 | 权限名称 | | description | string | 否 | 备注 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 权限UID |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.createPermission(event.userPoolUid, event.name, event.displayName, event.description);
  return result;
};

deletePermission()

接口功能:删除权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 权限UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 删除是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.deletePermission(event.uid);
  return result;
};

getPermission()

接口功能:获取权限信息 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 权限UID |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | uid | string | 是 | 权限UID | | name | string | 是 | 权限编码 | | displayName | string | 是 | 权限名称 | | description | string | 否 | 备注 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.getPermissionInfo(event.uid);
  return result;
};

queryPermissions()

接口功能:查询权限列表 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userPoolUid | string | 是 | 用户池ID | | name | string | 否 | 权限编码 | | pageIndex | int | 否 | 起始页索引 | | pageSize | int | 否 | 每页条数 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | total | int | 是 | 查询结果总数 | | pageIndex | int | 是 | 当前行 | | pageSize | int | 是 | 页行数 | | permisssions | Permission[] | 是 | 查询结果集 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.queryPermissions(event.userPoolUid, event.name, event.pageIndex, event.pageSize);
  return result;
};

modifyPermission()

接口功能:修改权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | uid | string | 是 | 权限UID | | name | string | 否 | 权限编码 | | displayName | string | 否 | 权限名称 | | description | string | 否 | 备注 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 修改是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.modifyPermissionInfo(event.uid, event.name, event.displayName, event.description);
  return result;
};

queryUserRoles()

接口功能:查询用户角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userUid | string | 是 | 用户UID | | pageIndex | int | 否 | 起始页索引 | | pageSize | int | 否 | 每页条数 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | total | int | 是 | 查询结果总数 | | pageIndex | int | 是 | 当前行 | | pageSize | int | 是 | 页行数 | | roles | Roles[] | 是 | 查询结果集 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.queryUserRoles(event.uid, event.pageIndex, event.pageSize);
  return result;
};

assignRoleToUser()

接口功能:为用户添加角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userUid | string | 是 | 用户UID | | roleName | string | 是 | 角色编码 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 添加角色是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.assignRoleForUser(event.uid, event.roleName);
  return result;
};

removeRoleFromUser()

接口功能:为用户移除角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userUid | string | 是 | 用户UID | | roleName | string | 是 | 角色编码 |

返回结果:

| 字段 | 类型 | 不为空 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 移除角色是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.removeRoleForUser(event.uid, event.roleName);
  return result;
};

checkRoleOfUser()

接口功能:检查用户是否拥有角色 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | userUid | string | 是 | 用户UID | | roleName | string | 是 | 角色编码 |

返回结果:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 用户是否拥有角色 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.checkRoleForUser(event.uid, event.roleName);
  return result;
};

queryRolePermissions()

接口功能:查询角色权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | roleUid | string | 是 | 角色UID |

返回结果:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | total | int | 是 | 查询结果总数 | | pageIndex | int | 是 | 当前行 | | pageSize | int | 是 | 页行数 | | permisssions | Permission[] | 是 | 查询结果集 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.queryRolePermissions(event.uid);
  return result;
};

assignPermissionToRole()

接口功能:为角色添加权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | roleUid | string | 是 | 权限UID | | permissionName | string | 是 | 权限编码 |

返回结果:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 添加权限是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.assignPermissionForRole(event.uid, event.permissionName);
  return result;
};

removePermissionFromRole()

接口功能:为角色移除权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | roleUid | string | 是 | 权限UID | | permissionName | string | 是 | 权限编码 |

返回结果:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 移除权限是否成功 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.removePermissionForRole(event.uid, event.permissionName);
  return result;
};

checkPermissionOfRole()

接口功能:检查角色是否拥有权限 输入参数:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | roleUid | string | 是 | 角色UID | | permissionName | string | 是 | 权限编码 |

返回结果:

| 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | result | boolean | 是 | 角色是否拥有权限 |

示例代码:

const { Auth } = require("@alipay/faas-biz-server-sdk");

exports.main = async (event, context) => {
  const auth = new Auth();
  const result = await auth.checkPermissionForRole(event.uid, event.permissionName);
  return result;
};