@larksuiteoapi/node-sdk 1.26.0 → 1.27.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.
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/es/index.js +7 -0
- package/lib/index.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -433,13 +433,13 @@ const eventDispatcher = new lark.EventDispatcher({
|
|
|
433
433
|
},
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
-
server.use(
|
|
436
|
+
server.use(lark.adaptKoa('/webhook/event', eventDispatcher));
|
|
437
437
|
server.listen(3000);
|
|
438
438
|
````
|
|
439
439
|
#### Combined with koa-router
|
|
440
440
|
When using Koa to write services, in most cases, koa-router is used to process routing, so the SDK also provides adaptations for this situation:
|
|
441
441
|
```typescript
|
|
442
|
-
import * as
|
|
442
|
+
import * as lark from '@larksuiteoapi/node-sdk';
|
|
443
443
|
import Koa from 'koa';
|
|
444
444
|
import Router from '@koa/router';
|
|
445
445
|
import koaBody from 'koa-body';
|
package/README.zh.md
CHANGED
|
@@ -433,13 +433,13 @@ const eventDispatcher = new lark.EventDispatcher({
|
|
|
433
433
|
},
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
-
server.use(
|
|
436
|
+
server.use(lark.adaptKoa('/webhook/event', eventDispatcher));
|
|
437
437
|
server.listen(3000);
|
|
438
438
|
```
|
|
439
439
|
#### 和koa-router结合
|
|
440
440
|
在使用koa来编写服务时,大多情况下会配合使用koa-router来对路由进行处理,因此SDK也提供了针对这一情况的适配:
|
|
441
441
|
```typescript
|
|
442
|
-
import * as
|
|
442
|
+
import * as lark from '@larksuiteoapi/node-sdk';
|
|
443
443
|
import Koa from 'koa';
|
|
444
444
|
import Router from '@koa/router';
|
|
445
445
|
import koaBody from 'koa-body';
|
package/es/index.js
CHANGED
|
@@ -59445,6 +59445,13 @@ class RequestHandle {
|
|
|
59445
59445
|
return Object.assign(Object.assign({ [CEventType]: get(targetData, 'event.type') }, event), rest);
|
|
59446
59446
|
}
|
|
59447
59447
|
checkIsCardEventValidated(data) {
|
|
59448
|
+
/**
|
|
59449
|
+
* 1. new message card encrypt ('encrypt' in data)
|
|
59450
|
+
* 2. new message card but not encrypt ('schema' in data)
|
|
59451
|
+
*/
|
|
59452
|
+
if ('encrypt' in data || 'schema' in data) {
|
|
59453
|
+
return this.checkIsEventValidated(data);
|
|
59454
|
+
}
|
|
59448
59455
|
const { 'x-lark-request-timestamp': timestamp, 'x-lark-request-nonce': nonce, 'x-lark-signature': signature, } = data.headers;
|
|
59449
59456
|
if (!this.verificationToken) {
|
|
59450
59457
|
return true;
|
package/lib/index.js
CHANGED
|
@@ -59462,6 +59462,13 @@ class RequestHandle {
|
|
|
59462
59462
|
return Object.assign(Object.assign({ [CEventType]: get__default["default"](targetData, 'event.type') }, event), rest);
|
|
59463
59463
|
}
|
|
59464
59464
|
checkIsCardEventValidated(data) {
|
|
59465
|
+
/**
|
|
59466
|
+
* 1. new message card encrypt ('encrypt' in data)
|
|
59467
|
+
* 2. new message card but not encrypt ('schema' in data)
|
|
59468
|
+
*/
|
|
59469
|
+
if ('encrypt' in data || 'schema' in data) {
|
|
59470
|
+
return this.checkIsEventValidated(data);
|
|
59471
|
+
}
|
|
59465
59472
|
const { 'x-lark-request-timestamp': timestamp, 'x-lark-request-nonce': nonce, 'x-lark-signature': signature, } = data.headers;
|
|
59466
59473
|
if (!this.verificationToken) {
|
|
59467
59474
|
return true;
|