From b82a760f3fcf7ee669163e1ce1c8300990ff1025 Mon Sep 17 00:00:00 2001 From: "junlong.hjl" Date: Wed, 18 Oct 2023 10:41:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/client.ts | 6 +++--- src/constants.ts | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d13d033..c0124a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dingtalk-stream", - "version": "2.1.0", + "version": "2.1.1", "description": "Nodejs SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/client.ts b/src/client.ts index 88f4c0e..e4435b1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,7 +1,7 @@ import WebSocket from 'ws'; import axios from 'axios'; import EventEmitter from 'events'; -import { GraphAPIResponse } from './constants'; +import { GET_TOKEN_URL, GATEWAY_URL,GraphAPIResponse } from './constants'; export enum EventAck { SUCCESS = "SUCCESS", @@ -153,12 +153,12 @@ export class DWClient extends EventEmitter { this.printDebug('get connect endpoint by config'); this.printDebug(this.config); const result = await axios.get( - `https://oapi.dingtalk.com/gettoken?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}` + `${GET_TOKEN_URL}?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}` ); if (result.status === 200 && result.data.access_token) { this.config.access_token = result.data.access_token; const res = await axios({ - url: 'https://pre-api.dingtalk.com/v1.0/gateway/connections/open', + url: GATEWAY_URL, method: 'POST', responseType: 'json', data: { diff --git a/src/constants.ts b/src/constants.ts index 521596e..e556b4b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,6 @@ +export const GATEWAY_URL = 'https://api.dingtalk.com/v1.0/gateway/connections/open'; +export const GET_TOKEN_URL = 'https://oapi.dingtalk.com/gettoken'; + /** 机器人消息回调 */ export const TOPIC_ROBOT = '/v1.0/im/bot/messages/get';