GithubHelp home page GithubHelp logo

javen205 / tnwx Goto Github PK

View Code? Open in Web Editor NEW
639.0 639.0 97.0 2.85 MB

TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业微信/企业号。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)

License: Apache License 2.0

TypeScript 99.74% JavaScript 0.26%
ijpay javascript nestjs node nodejs typescript wechat wechat-mini-program

tnwx's Introduction

tnwx's People

Contributors

chunmenglu avatar gabwz avatar ghostsf avatar huixisheng avatar icemanpro avatar javen205 avatar li-xunhuan avatar lltx avatar taixw2 avatar vnimy avatar wanxger avatar weiyunpeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tnwx's Issues

OCRApi 请求需要改成POST请求方式,否则报错

版本信息

  • 当前版本:
  • 操作系统:
  • 复现操作:

报错信息 (注意格式化)

这里粘贴代码或者、日志

问题描述(包括回显步骤、截图 )

kits_1.HttpKit.getHttpDelegate.httpGet(url.concat('&img_url=').concat(imgUrl));

使用缓存中的 accesstoken 会导致 jssdk 签名失败

版本信息

  • 当前版本: "tnwx": "^2.5.0",
  • 操作系统: centos
  • 复现操作:一开始没有问题。隔段时间jssdk签名就失败

报错信息 (注意格式化)

大致实现的伪代码:

    const qyApiConfig = new ApiConfig(agentId, appScrect, 'anytoken', true, '', corpId);

    QyApiConfigKit.putApiConfig(qyApiConfig);
    QyApiConfigKit.devMode = true;
    QyApiConfigKit.setCurrentAppId(qyApiConfig.getAppId, qyApiConfig.getCorpId);
    await QyAccessTokenApi.getAccessToken();

    ...
    const jssdkConfig = await this.appSerice.fetchQyJsSdkConfig(currentUrl);

  async fetchQyJsSdkConfig(url) {
    const corpId = 'xxx';
    const timestamp = new Date().getTime().toString();
    const nonceStr: string = uuid.v1();
    const signature = await QyWeChat.jssdkSignature(nonceStr, timestamp, url, QyJsApiType.CORP);
    ...
}

问题描述(包括回显步骤、截图 )

如上代码调用,隔段时间使用缓存中的 accesstoken 就会有问题

jssdkSignature 不传 jsapi_ticket 报错

const signature = await WeChat.jssdkSignature(nonceStr, timestamp, url);

jssdkSignature 不传 jsapi_ticket 报错:

nodejs.SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at new JsTicket (F:\housekeeping-system\egg-serve\node_modules\@tnwx\commons\dist\entity\JsTicket.js:6:27)
    at Function.<anonymous> (F:\housekeeping-system\egg-serve\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:44:32)       
    at Generator.next (<anonymous>)
    at fulfilled (F:\housekeeping-system\egg-serve\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:10:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
```

 传个个空对象的jsapi_ticket就可以了

```
const signature = await WeChat.jssdkSignature(nonceStr, timestamp, url, {});
```

集成nest获取授权url

版本信息

  • 当前版本: 2.5.0
  • 操作系统: macos
  • 复现操作:

报错信息 (注意格式化)

image

问题描述(包括回显步骤、截图 )

在controller的构造函数中执行了:

    ApiConfigKit.putApiConfig(
      new ApiConfig(
        configService.get('WECHAT_APP_ID'),
        configService.get('WECHAT_APP_SECRET'),
      ),
    )

执行的时候,第三行的打印语句已经能打出APP_ID的值,但是仍然提示没有设置,这是什么情况?

谢谢

jssdk 签名使用缓存中的 accesstoken 间隔一段时间会签名失败

版本信息

  • 当前版本: "tnwx": "^2.5.0",
  • 操作系统: centos
  • 复现操作:一开始没有问题。隔段时间jssdk签名就失败

报错信息 (注意格式化)

大致实现的伪代码:

    const qyApiConfig = new ApiConfig(agentId, appScrect, 'anytoken', true, '', corpId);

    QyApiConfigKit.putApiConfig(qyApiConfig);
    QyApiConfigKit.devMode = true;
    QyApiConfigKit.setCurrentAppId(qyApiConfig.getAppId, qyApiConfig.getCorpId);
    await QyAccessTokenApi.getAccessToken();

    ...
    const jssdkConfig = await this.appSerice.fetchQyJsSdkConfig(currentUrl);

  async fetchQyJsSdkConfig(url) {
    const corpId = 'xxx';
    const timestamp = new Date().getTime().toString();
    const nonceStr: string = uuid.v1();
    const signature = await QyWeChat.jssdkSignature(nonceStr, timestamp, url, QyJsApiType.CORP);
    ...
}

问题描述(包括回显步骤、截图 )

如上代码调用,隔段时间使用缓存中的 accesstoken 就会有问题

关于jssdk+微信支付v3

版本信息

  • 当前版本:2.5.6
  • 操作系统:win11
  • 复现操作:

报错信息 (注意格式化)

这里粘贴代码或者、日志

问题描述(包括回显步骤、截图 )

我参考https://gitee.com/javen205/TNWX/blob/master/sample/egg/app/controller/wxpay.ts中的case 13发起微信支付
内网穿透环境
当package为 “prepayId=xxx”时,手机客户端jssdk调起支付报错“缺少参数total_fee”

我在网上查阅资料,看到相关问题,并尝试修改package为 “prepay_id=xxx”,这时jssdk调起支付报错 “支付验证签名失败”

我似乎已经完全参照“示例”去写了,可能是我的操作有问题,但是由于缺少经验+提示信息少之又少 确实很难排查

感谢作者伟大的付出,非常完善的库,Nodejs社区福音

isAvailable 传入参数为空时未处理

版本信息

  • 当前版本:2.5.1
  • 操作系统:Windows Server 2012 R2
  • 复现操作:

报错信息 (注意格式化)

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Function.isAvailable (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:64:29)
    at Function.<anonymous> (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:34:38)
    at Generator.next (<anonymous>)
    at fulfilled (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:10:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

问题描述(包括回显步骤、截图 )

首先非常感谢作者发布的这个框架,太好用了!哈哈。

我是在项目中第一次接入这个框架,在使用 WeChat.jssdkSignature 这个方法时,发现调用始终不成功,报错代码如上所示。

经过多次 debug,发现是 JsTicketApi.js 中的 isAvailable 这个方法,没有对传入参数为空的情况进行处理。遗憾的是我不知道该如何复现这个 bug,只是在我的测试环境中会有这个 bug。

我用的临时的解决办法,是在 JsTicketApi.js 中的 isAvailable 这个方法里,先判断传入参数是否为空,为空则直接返回 false。之后再调用 WeChat.jssdkSignature,就一切正常了。

开发者模式验证失败

let signature = ctx.request.query.signature,//微信加密签名
        timestamp = ctx.request.query.timestamp,//时间戳
        nonce = ctx.request.query.nonce,//随机数
        echostr = ctx.request.query.echostr;//随机字符串
    console.log('signature', signature)
    console.log('timestamp', timestamp)
    console.log('nonce', nonce)
    console.log('echostr', echostr)
    const result = WeChat. (signature, timestamp,nonce, echostr)
    console.log('result', result)
    ctx.send(WeChat.checkSignature(signature, timestamp,nonce, echostr));

经打印确认 result 时跟 echostr 一样的

Cannot find module './entity/QyMiniProgramNoticeMsg'.

build报错。mac下没有报错,生产环境ubuntu build失败。使用过cnpm yarn npm 分别安装依赖都不行。

使用的nest

node_modules/_@[email protected]@@tnwx/wxcp/dist/index.d.ts:13:61 - error TS2307: Cannot find module './entity/QyMiniProgramNoticeMsg'.

13 export { QyMiniProgramNoticeMsg, QyMiniprogram, QyKv } from './entity/QyMiniProgramNoticeMsg';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

第三方平台票据验证

你好,
在nodejs中,使用cnpm安装tnw,版本是1.2.0,里面没找到ComponentVerifyTicket,是不是发布的版本中还不支持呢?

服务号的订阅通知

版本信息

  • 当前版本:
  • 操作系统:
  • 复现操作:

报错信息 (注意格式化)

这里粘贴代码或者、日志

问题描述(包括回显步骤、截图 )

原模板消息4月30日关闭,现在TNWX支持订阅消息吗?代码中没看到订阅消息的请求地址。

多账号accesstoken是否存在错乱问题

问题描述

我查看了一下所有接口的发送逻辑,先从缓存获取accesstoken

let accessToken: AccessToken = await OpenCpAccessTokenApi.getAccessToken(AccessTokenType.SUITE_TOKEN)

当多个服务号或企业号时,我们调用接口时需要先设置当前的appId并存入缓存ApiConfigKit.setCurrentAppId(appId)
然后去调用接口,上面代码获取到的token是根据缓存中当前的appId去取token,但是如果多个人同时操作,因为是异步操作,可能存在我发送请求时,当前的appId已经发生变化,获取到的token已经不是我这个appid所对应的token

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.