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

@cloudbase/extension-sms

v0.0.2

Published

腾讯云云开发短信登录扩展

Downloads

65

Readme

验证码登录(扩展)

安装

方法1: 使用npm:

npm install --save @cloudbase/extension-sms

方法2: 使用CDN

<script src="//unpkg.com/@cloudbase/extension-sms/built/index.umd.js"></script>

Usage

const extSms = require('@cloudbase/extension-sms')

tcb.init({
    env:'xxx',
});

tcb.registerExtension(extSms)

const res = await tcb.invokeExtension('CloudInfinite',opts)

opts 包含以下属性

|名称 |类型 | 是否必须 | 说明 | |--| -- | -- | -- | | action | String | 是 | 操作类型,支持 Send, Login, Verify | | phone | String | 是 | 电话号码 | | app | Tcb | 是 | tcb实例 | | smsCode | String | 否 | 短信验证码,action 为 LoginVerify 时需要传入 | | customDomain | String | 否 | HTTP触发的自定义域名 |

action目前包含以下类型

  • Send: 发送短信验证码
  • Verify: 校验短信验证码
  • Login: 短信验证码登录

功能说明

发送短信验证码

const app = tcb.init({
    env: '您的环境ID'
});

const opts = {
    action: 'Send',
    app,
    phone: '' // 用户输入的手机号
};

try {
    await tcb.invokeExtension(extSms.name, opts); // 发送短信验证码
    console.log('短信验证码发送成功')
} catch (error) {
    console.log('短信验证码发送失败:', error.message)
}

注意:前往短信服务(SMS),调整短信发送频率配置

校验短信验证码

const app = tcb.init({
    env: '您的环境ID'
});

const opts = {
    action: 'Verify',
    app,
    phone: '', // 用户手机号
    smsCode: '', // 需要校验的验证码
};

try {
    await tcb.invokeExtension(extSms.name, opts); // 校验短信验证码
    console.log('短信验证码校验成功')
} catch (error) {
    console.log('短信验证码校验失败', error.message)
}

短信验证码登录

const app = tcb.init({
    env: '您的环境ID'
});

const opts = {
    action: 'Login',
    app,
    phone: '', // 用户手机号
    smsCode: '', // 接收到的短信验证码
}

try {
    await tcb.invokeExtension(extSms.name, opts); // 正式登录
    console.log('短信验证码登录成功')
} catch (error) {
    console.log('登录失败:', error.message)
}

注意:登录成功后,验证码自动失效。