Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alipay/faas-biz-server-sdk

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/faas-biz-server-sdk

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

  • 1.1.1-alpha.1
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
3
Weekly downloads
 
Created
Source

云函数SDK

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

安装

可以通过 npm 安装:

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

API

getCurrentUser()

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

字段类型不为空说明
uidstring用户UID
userPoolUidstring用户池ID
idpUidstring身份提供商ID
idpUserIdstring用户ID,在此供应商范围内唯一
usernamestring用户名
mobilestring手机号
emailstring邮箱地址
avatarstring头像
lockedboolean是否锁定,默认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()

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

字段类型必填说明
userPoolUidstring用户池ID
idpUidstring身份提供商ID
idpUserIdstring用户ID,在此供应商范围内唯一
usernamestring用户名
passwordstring密码
mobilestring手机号
emailstring邮箱地址
avatarstring头像

返回结果:

字段类型不为空说明
uidstring用户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()

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

字段类型必填说明
uidstring用户UID

返回结果:

字段类型不为空说明
resultboolean删除是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID
curPasswordstring当前密码
newPasswordstring新密码

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID
usernamestring用户名
mobilestring手机号
emailstring邮箱地址
avatarstring头像

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID
passwordstring当前密码

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID
newPasswordstring新密码

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
uidstring用户UID

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
userPoolUidstring用户池ID
idpUidstring身份提供商ID
idpUserIdstring用户ID,在此供应商范围内唯一
usernamestring用户名
lockedstring是否冻结
pageIndexint起始页
pageSizeint页行数

返回结果:

字段类型不为空说明
totalint查询结果总数
pageIndexint当前行
pageSizeint页行数
usersUser[]查询结果集

示例代码:

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()

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

字段类型必填说明
userPoolUidstring用户池ID
namestring角色编码
displayNamestring角色名
descriptionstring备注

返回结果:

字段类型不为空说明
uidstring角色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()

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

字段类型必填说明
uidstring角色UID

返回结果:

字段类型不为空说明
resultboolean删除是否成功

示例代码:

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()

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

字段类型必填说明
uidstring角色UID

返回结果:

字段类型不为空说明
uidstring角色UID
userPoolUidstring用户池ID
namestring角色编码
displayNamestring角色名
descriptionstring备注

示例代码:

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()

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

字段类型必填说明
userPoolUidstring用户池ID
namestring角色编码
pageIndexint起始页索引
pageSizeint每页条数

返回结果:

字段类型不为空说明
totalint查询结果总数
pageIndexint当前行
pageSizeint页行数
rolesRoles[]查询结果集

示例代码:

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()

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

字段类型必填说明
uidstring角色UID
namestring角色编码
displayNamestring角色名称
descriptionstring备注

返回结果:

字段类型不为空说明
resultboolean修改角色是否成功

示例代码:

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()

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

字段类型必填说明
userPoolUidstring用户池ID
namestring权限编码
displayNamestring权限名称
descriptionstring备注

返回结果:

字段类型不为空说明
uidstring权限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()

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

字段类型必填说明
uidstring权限UID

返回结果:

字段类型不为空说明
resultboolean删除是否成功

示例代码:

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()

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

字段类型必填说明
uidstring权限UID

返回结果:

字段类型不为空说明
userPoolUidstring用户池ID
uidstring权限UID
namestring权限编码
displayNamestring权限名称
descriptionstring备注

示例代码:

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()

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

字段类型必填说明
userPoolUidstring用户池ID
namestring权限编码
pageIndexint起始页索引
pageSizeint每页条数

返回结果:

字段类型不为空说明
totalint查询结果总数
pageIndexint当前行
pageSizeint页行数
permisssionsPermission[]查询结果集

示例代码:

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()

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

字段类型必填说明
uidstring权限UID
namestring权限编码
displayNamestring权限名称
descriptionstring备注

返回结果:

字段类型不为空说明
resultboolean修改是否成功

示例代码:

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()

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

字段类型必填说明
userUidstring用户UID
pageIndexint起始页索引
pageSizeint每页条数

返回结果:

字段类型不为空说明
totalint查询结果总数
pageIndexint当前行
pageSizeint页行数
rolesRoles[]查询结果集

示例代码:

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()

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

字段类型必填说明
userUidstring用户UID
roleNamestring角色编码

返回结果:

字段类型不为空说明
resultboolean添加角色是否成功

示例代码:

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()

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

字段类型必填说明
userUidstring用户UID
roleNamestring角色编码

返回结果:

字段类型不为空说明
resultboolean移除角色是否成功

示例代码:

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()

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

字段类型必填说明
userUidstring用户UID
roleNamestring角色编码

返回结果:

字段类型必填说明
resultboolean用户是否拥有角色

示例代码:

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()

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

字段类型必填说明
roleUidstring角色UID

返回结果:

字段类型必填说明
totalint查询结果总数
pageIndexint当前行
pageSizeint页行数
permisssionsPermission[]查询结果集

示例代码:

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()

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

字段类型必填说明
roleUidstring权限UID
permissionNamestring权限编码

返回结果:

字段类型必填说明
resultboolean添加权限是否成功

示例代码:

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()

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

字段类型必填说明
roleUidstring权限UID
permissionNamestring权限编码

返回结果:

字段类型必填说明
resultboolean移除权限是否成功

示例代码:

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()

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

字段类型必填说明
roleUidstring角色UID
permissionNamestring权限编码

返回结果:

字段类型必填说明
resultboolean角色是否拥有权限

示例代码:

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;
};

FAQs

Package last updated on 03 Jun 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc