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

yiren-wxwork-api

v1.0.3

Published

企业微信Node库API,ES6版本

Downloads

9

Readme

WeiXin Work API(ES6版)

企业微信API。

模块状态

  • NPM version
  • Build Status
  • Dependencies Status
  • Coverage Status

功能列表

  • API 企业微信API基类
    • Crypto Lib(微信服务器消息推送AES加、解密库)
  • CorpAPI 企业微信自建应用API
    • OAuth API(授权、获取基本信息)
    • JS API(JS SDK配置)
    • 通讯录管理
      • User API(成员管理)
      • Department API(部门管理)
      • Tag API(标签管理)
      • Batch API(异步任务管理)
  • SuiteAPI 企业微信套件API
    • 3RD API(第三方应用)
  • SuiteCorpAPI 企业微信套件应用API,继承自CorpAPI,包含CorpAPI的所有API
  • ProviderAPI 企业微信服务商API
    • OAuth API(商户授权)

企业微信官方文档(https://work.weixin.qq.com/api/doc)

订阅号和服务号版本请前往:https://github.com/node-webot/co-wechat-api

Installation

$ npm install co-wxwork-api

Usage

创建自建应用API实例

const CorpAPI = require('co-wxwork-api').CorpAPI;

const corpAPI = new CorpAPI(corpId, corpSecret);
const result = await corpAPI.getUserIdByCode('code');

创建套件API实例

const SuiteAPI = require('co-wxwork-api').SuiteAPI;

const suiteAPI = new SuiteAPI(suiteId, suiteSecret);
const result = await suiteAPI.getPreAuthCode();

创建套件应用API实例

const {SuiteAPI, SuiteCorpAPI} = require('co-wxwork-api');

// 实例化套件API
const suiteAPI = new SuiteAPI(suiteId, suiteSecret);

//... 根据授权企业ID获取永久授权码
const permanentCode = getPermanentCode...(authCorpId)

// 实例化套件应用API
const suiteCorpAPI = new SuiteCorpAPI(suiteAPI, authCorpId, permanentCode);
const result = await corpAPI.getUserIdByCode('code');

多进程

当多进程或多机器时,token需要全局维护,以下为多进程保存token的接口。

var api = new CorpAPI('corpId', 'corpSecret', async function () {
  // 传入一个获取全局token的方法
  var txt = await fs.readFile('access_token.txt', 'utf8');
  return JSON.parse(txt);
}, async function (token) {
  // 请将token存储到全局,跨进程、跨机器级别的全局,比如写到数据库、redis等
  // 这样才能在cluster模式及多机情况下使用,以下为写入到文件的示例
  await fs.writeFile('access_token.txt', JSON.stringify(token));
});

当多进程或多机器时,ticket需要全局维护,以下为保存ticket的接口,一个实例可以包含多种ticket,如:jsapi ticket, suite ticket等

var api = new CorpAPI('corpId', 'corpSecret', ...) // 多进程参照上面token保存方式

api.registerTicketHandle(async function (type) {
// 传入一个获取全局ticket的方法
  var txt = await fs.readFile('access_token_' + type + '.txt', 'utf8');
  return JSON.parse(txt);
}, async function (type, ticketToken) {
  // 请将token存储到全局,跨进程、跨机器级别的全局,比如写到数据库、redis等
  // 这样才能在cluster模式及多机情况下使用,以下为写入到文件的示例
  await fs.writeFile('access_token_' + type + '.txt', JSON.stringify(ticketToken));
});

License

The MIT license.