# edu-idaas-client-mp

> 用于小程序idaas密码协议的库 目前只支持wepy，其他框架包括官方npm未测试 见[idaas-client-mp](https://www.npmjs.com/package/idaas-client-mp)

Latest version **1.2.1** (published 2020-06-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install edu-idaas-client-mp
pnpm add edu-idaas-client-mp
yarn add edu-idaas-client-mp
bun add edu-idaas-client-mp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-06-15 |
| First published | 2020-06-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | okhowang |
| Maintainers | evansui |

## Links

- npm: https://www.npmjs.com/package/edu-idaas-client-mp
- npm.io page: https://npm.io/package/edu-idaas-client-mp

## Recent versions

- 1.2.1 (latest) — 2020-06-15
- 1.1.1 — 2020-06-10
- 1.0.1 — 2020-06-10

## README

# idaas-client-mp

用于小程序idaas密码协议的库
目前只支持wepy，其他框架包括官方npm未测试
见[idaas-client-mp](https://www.npmjs.com/package/idaas-client-mp)

## Usage
安装依赖
```shell
npm i idaas-client
```

创建client对象
```javascript
import {SimpleIDaaSClient} from "idaas-client";

const client = new SimpleIDaaSClient({
    appId: 1, //后台分配，帐号系统的appId
    basePath: "/subpath", //整体系统basepath，一般不用填
    domain: "some.domain.com", //后台域名非当前域名的情况下需要填写
});
```
### 密码登录
```javascript
try {
    const response = await client.passwordLogin({
        namespace: 1, //主帐号id，子帐号登录时需要填写
        captcha: { //验证码票据，业务自行处理验证码的时候需要填写
            ticket: "",
            randStr: "",
        },
        //用户名/邮箱/国家码手机号三选一
        username: "",
        email: "",
        nation: "",
        phone: ""
    }, password);
    if (response.code === 12050) {//需要重置密码后才能登录
        if (client.loginResetNeedOldPassword()) {//判断是否需要旧密码
            await client.loginResetPassword(oldPassword, newPassword)
            //重置成功
        } else {
            await client.loginSetPassword(newPassword)
            //设置新密码成功
        }
    } else if (response.code === 0) {
        //登录成功
    }
} catch (e) {
    if (e instanceof SimpleIDaaSClientException) {
        //其他错误
        alert(e.response.message)
    }
}
```

---
_Source: https://npm.io/package/edu-idaas-client-mp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
