@larksuiteoapi/node-sdk 1.2.3 → 1.4.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 CHANGED
@@ -403,6 +403,32 @@ const resule = await dispatcher.invoke(data);
403
403
  server.sendResult(result);
404
404
  ````
405
405
 
406
+ #### Challenge check
407
+ When configuring the event request address, The Open Platform will push a POST request in `application/json` format to the request address. The POST request is used to verify the validity of the configured request address, and the request body will carry a `challenge` field , **The application needs to return the received challenge value to the Open Platform within 1 second**. See: [ Document](https://open.feishu.cn/document/ukTMukTMukTM/uYDNxYjL2QTM24iN0EjN/event-subscription-configure-/request-url-configuration-case)
408
+
409
+ The adapter provided by the sdk above encapsulates the verification logic. Set the `autoChallenge` field in the options parameter to true to enable:
410
+ ```typescript
411
+ // adaptDefault
412
+ lark.adaptDefault('/webhook/event', eventDispatcher, {
413
+ autoChallenge: true,
414
+ });
415
+ // express
416
+ lark.adaptExpress(eventDispatcher, {
417
+ autoChallenge: true,
418
+ });
419
+ // koa
420
+ lark.adaptKoa('/webhook/event', eventDispatcher, {
421
+ autoChallenge: true,
422
+ });
423
+ // koa-router
424
+ router.post(
425
+ '/webhook/event',
426
+ lark.adaptKoaRouter(eventDispatcher, {
427
+ autoChallenge: true,
428
+ })
429
+ );
430
+ ```
431
+
406
432
  ### [Message Card](https://open.feishu.cn/document/ukTMukTMukTM/uczM3QjL3MzN04yNzcDN)
407
433
  The processing of the Message Card is also a kind of Event processing. The only difference between the two is that the processor of the Message Card is used to respond to the events generated by the interaction between the user and the Message Card. If the processor has a return value (*the value structure should be in line with the structure defined by [Message Card Structure](https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN)*), then the return value is used to update the responded message card:
408
434
 
@@ -443,6 +469,10 @@ import * as lark from '@larksuiteoapi/node-sdk';
443
469
 
444
470
  new lark.AESCipher('encrypt key').decrypt('content');
445
471
  ````
472
+
473
+ ## Blog
474
+ [ISV Application Development Guide](https://bytedance.feishu.cn/docx/RUZKdGwdyoH4KexMJgDcITQnn0b)
475
+
446
476
  ## LICENSE
447
477
  MIT
448
478
 
package/README.zh.md CHANGED
@@ -402,6 +402,32 @@ const resule = await dispatcher.invoke(data);
402
402
  server.sendResult(result);
403
403
  ```
404
404
 
405
+ #### challenge校验
406
+ 在配置事件请求地址时,开放平台会向请求地址推送一个`application/json`格式的 POST请求,该POST请求用于验证所配置的请求地址的合法性,请求体中会携带一个`challenge`字段,**应用需要在 1 秒内,将接收到的challenge值原样返回给飞书开放平台**。详见:[文档](https://open.feishu.cn/document/ukTMukTMukTM/uYDNxYjL2QTM24iN0EjN/event-subscription-configure-/request-url-configuration-case)
407
+
408
+ 上面sdk提供出的适配器内部封装了这部分验证的逻辑,将options参数中的`autoChallenge`字段设为true即可启用:
409
+ ```typescript
410
+ // adaptDefault
411
+ lark.adaptDefault('/webhook/event', eventDispatcher, {
412
+ autoChallenge: true,
413
+ });
414
+ // express
415
+ lark.adaptExpress(eventDispatcher, {
416
+ autoChallenge: true,
417
+ });
418
+ // koa
419
+ lark.adaptKoa('/webhook/event', eventDispatcher, {
420
+ autoChallenge: true,
421
+ });
422
+ // koa-router
423
+ router.post(
424
+ '/webhook/event',
425
+ lark.adaptKoaRouter(eventDispatcher, {
426
+ autoChallenge: true,
427
+ })
428
+ );
429
+ ```
430
+
405
431
  ### [消息卡片](https://open.feishu.cn/document/ukTMukTMukTM/uczM3QjL3MzN04yNzcDN)
406
432
  对消息卡片的处理亦是对事件处理的一种,两者的不同点仅在于消息卡片的处理器用于响应用户与消息卡片交互所产生的事件,若处理器有返回值(*返回值的数据结构理应为符合[消息卡片结构](https://open.feishu.cn/document/ukTMukTMukTM/uEjNwUjLxYDM14SM2ATN)所定义的结构*),则返回值被用来更新被响应的消息卡片:
407
433
 
@@ -442,6 +468,10 @@ import * as lark from '@larksuiteoapi/node-sdk';
442
468
 
443
469
  new lark.AESCipher('encrypt key').decrypt('content');
444
470
  ```
471
+
472
+ ## Blog
473
+ [ISV(商店应用)开发指南](https://bytedance.feishu.cn/docx/RUZKdGwdyoH4KexMJgDcITQnn0b)
474
+
445
475
  ## 许可协议
446
476
  MIT
447
477