Giter Club home page Giter Club logo

wechaty-authing's Introduction

wechaty-authing

npm npm Maintainability Test Coverage

简体中文

Usage

POC Example: https://github.com/Authing/wechaty-authing-poc

Constructor

Params: WechatyAuthingConfig | ManagementClientOptions

Ref docs: https://docs.authing.cn/v2/reference/sdk-for-node/

Example:

import { WechatyAuthing, type WechatyAuthingConfig } from 'wechaty-authing';

const config: WechatyAuthingConfig = {
  userPoolId: 'xxxxxxxxxx',
  secret: 'xxxxxxxxxxx'
};

const authing = WechatyAuthing(config);

protected client

Returns: ManagementClient

Which is an Authing SDK client

protected createAuthingUser(contact: Contact): Promise<User | null>;

Create a Authing user

Params: Contact

Returns: User | null

getPoolName(): Promise;

Get Authing User pool name

const authing = WechatyAuthing(config);
await authing.getPoolName(); // '我的企业'

filterAuthingUsers(contacts: Contact[]): Promise<ContactsFilterResult>;

Batch check users exists from Authing

Params: Contact[]

Returns:

type ContactsFilterResult = {
  registered: Contact[];
  unregistered: Contact[];
  fail: Contact[];
};

createAuthingUsers(contacts: Contact[]): Promise<ContactsOperationResult>;

Batch create users to Authing

Params: Contact[]

Returns:

type ContactsOperationResult = {
  success: Contact[];
  fail: Contact[];
};

deleteAuthingUsers(contacts: Contact[]): Promise<ContactsOperationResult>;

Batch delete users from Authing

Params and Return values are same with the create function.

bindAuthingPhone(contact: Contact, phone: string): Promise;

Create or update a authing user with Wechaty contact and phone

Params:

  • Contact
  • string

Returns: boolean

checkPhone(phone: string): Promise;

Check if user with the phone number exists in Authing

Params: string

Returns: boolean

bindPhoneContact(phone: string, contact: Contact): Promise;

Bind Wechaty contact to a Authing user by phone number

Params:

  • string
  • Contact

Returns: boolean

checkEmail(email: string): Promise;

Check if user with the email exists in Authing

Params: string

Returns: boolean

bindEmailContact(email: string, contact: Contact): Promise;

Bind Wechaty contact to a Authing user by email

Params:

  • string
  • Contact

Returns: boolean

Utils

getAuthingGender: (gender: any) => string

Convert Wechaty ContactGender to Authing Gender format

import { getAuthingGender } from 'wechaty-authing';

getAuthingGender(contact.gender()); // ContactGender.Unknown --> U

getContactId: (contact: any) => string

Get Valid Contact ID

import { getContactId } from 'wechaty-authing';

getContactId(contact); // weixin or empty string

arrayDiff: <T = Contact>(arr: T[], diff: T[]) => T[]

Array Set Difference

import { arrayDiff } from 'wechaty-authing';

arrayDiff([contact1, contact2, contact3], [contact2, contact3, contact4]);
// [contact1]

LICENSE

Apache 2.0

wechaty-authing's People

Contributors

willin avatar xuancaosu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wechaty-authing's Issues

A introduction blog post would be great

and it would be better if we can also record a getting started screen cast for beginners, such as the developers who are familiar with Wechaty but not Authing (like me)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.