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

awesome-wechat-sdk

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-wechat-sdk

an awesome sdk for wechat oauth, api and message middleware

  • 2.9.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

awesome-wechat-sdk

Features

  • WechatApi - Library to call wechat backend
  • middleware - Koa middleware to process user message and event notification
  • WechatPay - Library to call wxpay api backend

Document

Class: WechatApi

new WechatApi(appid, appsecret)
  • appid <string> Wechat appid.
  • appsecret <string> Wechat appsecret.

Create an instance of WechatApi.

api.setEndpoint(domain)
  • domain <string> Alternative wechat endpoint domain.

Set endpoint to alternative access point. Available value can be api.weixin.qq.com|sh.api.weixin.qq.com|sz.api.weixin.qq.com|hk.api.weixin.qq.com.

api.setOpts(opts)
  • opts <UrlLibOptions> Options for urllib request.

Set default options for urllib request.

api.registerAccessTokenHandler(handler)
  • handler <object>
    • handler.loadAccessToken <Function> The handler for load access token, should return a promise which resolved with an instance of AccessToken.
    • handler.saveAccessToken <Function> The handler for save access token, accept an instance of AccessToken as parameter, should return a promise which resolved with void.

Register custom handler to handle access token. It is useful for a distributed application.

api.registerAuthAccessTokenHandler(handler)
  • handler <object>
    • handler.loadAuthAccessToken <Function> The handler for load auth access token, should return a promise which resolved with an instance of AuthAccessToken.
    • handler.saveAuthAccessToken <Function> The handler for save auth access token, accept an instance of AuthAccessToken as parameter, should return a promise which resolved with void.

Register custom handler to handle auth access token. It is useful for a distributed application.

api.getAuthorizeURL(redirect[, state[, scope]])
  • redirect <string> The target redirect uri. It's domain should match the config at wechat admin panel.
  • state <string> The reserved state value which will be send back unchanged at redirect page. Default value is an empty string.
  • scope <string> The auth scope. Available values are snsapi_base or snsapi_userinfo. Default value is snsapi_base
  • Returns: <string>

Get the well-formatted url for oauth.

api.getAuthUser(openid[, lang])
  • openid <string>
  • lang <string>
  • Returns: <Promise>
api.getAuthUserByCode(code[, lang])
  • code <string>
  • lang <string>
  • Returns: <Promise>

Class: AccessToken

new AccessToken(token)
  • token <object>
    • token.accessToken <string> The value of access token.
    • token.expireTime <number> The expire timestamp of access token.
token.isValid()
  • Returns: <boolean>

Determine whether the token is valid or not.

token.toJSON()
  • Returns: <object>

Valid for JSON stringify.

Class: AuthAccessToken

new AuthAccessToken(token)
  • token <object>
    • token.accessToken <string> The value of auth access token.
    • token.expireTime <number> The expire timestamp of auth access token.
    • token.refreshToken <string> The value of auth refresh token.
    • token.openid <string> The openid of user.
    • token.scope <string> The scope of auth access token.
token.isValid()
  • Returns: <boolean>
token.toJSON()
  • Returns: <object>

FAQs

Package last updated on 09 Jul 2018

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