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

@alipay/faas-biz-mini-sdk

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/faas-biz-mini-sdk

支付宝云开发业务 SDK(小程序端)

  • 1.1.4-alpha.2
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-83.64%
Maintainers
0
Weekly downloads
 
Created
Source

小程序SDK

@alipay/faas-biz-mini-sdk 可以在小程序端使用 Javascript 访问云开发用户身份服务。

安装

可以通过 npm 安装:

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

前置配置

参数:

字段类型必填说明
envIdstring云开发的 envId
userPoolUidstring云开发 UserPool 的 UID
environmentstring环境,当前仅支持生产(hz)环境,默认为 hz
useHttpsboolean是否使用 HTTPS,默认为 true

UserPool 是在云开发创建出来的,会分配一个 Uid,一般一个应用使用一个 UserPool 即可,云开发也支持创建多个。 示例代码:

import { Auth } from "@alipay/faas-biz-mini-sdk";

const auth = new Auth({
  envId: "your-env-id",
  userPoolUid: "your-userpool-uid"
});

API

getAlipayAuthProvider().login()

接口功能:支付宝登录 输入参数:无 返回结果:

字段类型不为空说明
userUser用户信息
loginTypestring登录方式
isAlipayAuthboolean支付宝三方登录

示例代码:

import { Auth } from '@alipay/faas-biz-mini-sdk';

const userPoolConfig = {
	envId: 'your-env-id',
	userPoolUid: 'your-userPool-uid',
};
const auth = new Auth(userPoolConfig);
const alipayAuthProvider = auth.getAlipayAuthProvider();
alipayAuthProvider.login().then(res => {
	//登录成功
});
getAuthHeader()

接口功能:获取 HTTP 鉴权头部 输入参数:无 返回结果:

字段类型不为空说明
x-faas-context-authorizationstring鉴权头部信息

示例代码:

import { Auth } from '@alipay/faas-biz-mini-sdk';

const userPoolConfig = {
	envId: 'your-env-id',
	userPoolUid: 'your-userPool-uid',
};
const auth = new Auth(userPoolConfig);
await auth.getAuthHeader();
getCurrentUser()

接口功能:获取当前登录用户对象 输入参数:无 返回结果:

字段类型不为空说明
userUser用户对象

示例代码:

import { Auth } from '@alipay/faas-biz-mini-sdk';

const userPoolConfig = {
	envId: 'your-env-id',
	userPoolUid: 'your-userPool-uid',
};
const auth = new Auth(userPoolConfig);
await auth.getCurrentUser();
logout()

接口功能:退出登录 输入参数:无 返回结果:无 示例代码:

import { Auth } from "@alipay/faas-biz-mini-sdk";

const userPoolConfig = {
	envId: 'your-env-id',
	userPoolUid: 'your-userPool-uid',
};
const auth = new Auth(userPoolConfig);
auth.logout();

FAQs

Package last updated on 27 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