@tapd/tapd-node-sdk 1.43.1-alpha.4 → 1.44.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/node-sdk/src/sdk.js +15 -10
  2. package/package.json +2 -2
@@ -6,6 +6,8 @@ const FormData = require('form-data');
6
6
  const { Base64 } = require('js-base64');
7
7
  const { CODE_MAP } = require('./constant');
8
8
  const { FILE } = require('./file');
9
+ const { version } = require('../../package.json');
10
+
9
11
  class SDK {
10
12
  constructor({
11
13
  client = '',
@@ -136,19 +138,20 @@ class SDK {
136
138
  const authHeader = this.isOauth() ? `Bearer ${accessToken}` : `Basic ${Base64.encode(`${this.client}:${this.secret}`)}`;
137
139
  const upperMethod = method.toUpperCase();
138
140
 
139
- const headers = {}
140
- if ( this.rioToken !== ""){
141
- const timestamp = (Date.now() / 1000).toFixed()
142
- const signature = crypto.createHash('sha256').update(`${timestamp}${this.rioToken }${timestamp}`).digest('hex');
143
-
144
- headers['timestamp'] = timestamp
145
- headers['signature'] = signature
141
+ const headers = {};
142
+ if (this.rioToken !== '') {
143
+ const timestamp = (Date.now() / 1000).toFixed();
144
+ const signature = crypto.createHash('sha256').update(`${timestamp}${this.rioToken}${timestamp}`)
145
+ .digest('hex');
146
+
147
+ headers.timestamp = timestamp;
148
+ headers.signature = signature;
146
149
  }
147
150
 
148
151
  // 添加企微数据
149
152
  if (this.corpid && this.corpsecret) {
150
- params.corpid = this.corpid
151
- params.corpsecret = this.corpsecret
153
+ params.corpid = this.corpid;
154
+ params.corpsecret = this.corpsecret;
152
155
  }
153
156
 
154
157
  const config = {
@@ -158,7 +161,9 @@ class SDK {
158
161
  params: upperMethod === 'GET' ? params : {},
159
162
  data: upperMethod === 'GET' ? undefined : params,
160
163
  // 使用Bearer or Basic方式发起鉴权
161
- headers: { ...headers, ...{ Authorization: authHeader }},
164
+ headers: { ...headers, ...{ Authorization: authHeader },
165
+ 'User-Agent': `TAPD-API-NODE-SDK/V-${version}`,
166
+ },
162
167
  };
163
168
 
164
169
  if (Object.values(params).some(value => value instanceof ReadStream || value instanceof FILE)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapd/tapd-node-sdk",
3
- "version": "1.43.1-alpha.4",
3
+ "version": "1.44.1-alpha.0",
4
4
  "description": "node sdk for open tapd ",
5
5
  "main": "node-sdk/src/index.js",
6
6
  "scripts": {
@@ -44,5 +44,5 @@
44
44
  "directories": {
45
45
  "test": "test"
46
46
  },
47
- "gitHead": "bca7c5c36fa185f3ce5a80071338c566ec9035c8"
47
+ "gitHead": "86a65ee540d9949c0579526f0d7d8aa8b8dea74a"
48
48
  }