@plolink/sdk 0.0.5 → 0.0.8

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 (56) hide show
  1. package/README.md +40 -26
  2. package/dist/{chunk-4H4RACSE.js → chunk-LHNCGCWW.js} +137 -3
  3. package/dist/chunk-LHNCGCWW.js.map +1 -0
  4. package/dist/{chunk-NS3DJP2O.cjs → chunk-WFBN23AH.cjs} +141 -2
  5. package/dist/chunk-WFBN23AH.cjs.map +1 -0
  6. package/dist/client-DXKAtLg1.d.ts +848 -0
  7. package/dist/client-l6cekf09.d.cts +848 -0
  8. package/dist/common/index.cjs +18 -14
  9. package/dist/common/index.d.cts +126 -1
  10. package/dist/common/index.d.ts +126 -1
  11. package/dist/common/index.js +1 -1
  12. package/dist/index.cjs +751 -13
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +410 -3
  15. package/dist/index.d.ts +410 -3
  16. package/dist/index.js +735 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/modules/billing/index.cjs +1 -1
  19. package/dist/modules/billing/index.d.cts +1 -1
  20. package/dist/modules/billing/index.d.ts +1 -1
  21. package/dist/modules/billing/index.js +1 -1
  22. package/dist/modules/rbac/index.d.cts +1 -1
  23. package/dist/modules/rbac/index.d.ts +1 -1
  24. package/dist/modules/team/index.d.cts +1 -1
  25. package/dist/modules/team/index.d.ts +1 -1
  26. package/dist/modules/video-psych-analysis/index.cjs +123 -4
  27. package/dist/modules/video-psych-analysis/index.cjs.map +1 -1
  28. package/dist/modules/video-psych-analysis/index.d.cts +231 -93
  29. package/dist/modules/video-psych-analysis/index.d.ts +231 -93
  30. package/dist/modules/video-psych-analysis/index.js +123 -4
  31. package/dist/modules/video-psych-analysis/index.js.map +1 -1
  32. package/dist/modules/virtual-account/index.d.cts +1 -1
  33. package/dist/modules/virtual-account/index.d.ts +1 -1
  34. package/package.json +1 -16
  35. package/dist/chunk-4H4RACSE.js.map +0 -1
  36. package/dist/chunk-NS3DJP2O.cjs.map +0 -1
  37. package/dist/client-CAjIQKPm.d.cts +0 -193
  38. package/dist/client-CwNikk7i.d.ts +0 -193
  39. package/dist/modules/agent/index.cjs +0 -21
  40. package/dist/modules/agent/index.cjs.map +0 -1
  41. package/dist/modules/agent/index.d.cts +0 -71
  42. package/dist/modules/agent/index.d.ts +0 -71
  43. package/dist/modules/agent/index.js +0 -19
  44. package/dist/modules/agent/index.js.map +0 -1
  45. package/dist/modules/chat/index.cjs +0 -20
  46. package/dist/modules/chat/index.cjs.map +0 -1
  47. package/dist/modules/chat/index.d.cts +0 -68
  48. package/dist/modules/chat/index.d.ts +0 -68
  49. package/dist/modules/chat/index.js +0 -18
  50. package/dist/modules/chat/index.js.map +0 -1
  51. package/dist/modules/psych/index.cjs +0 -20
  52. package/dist/modules/psych/index.cjs.map +0 -1
  53. package/dist/modules/psych/index.d.cts +0 -69
  54. package/dist/modules/psych/index.d.ts +0 -69
  55. package/dist/modules/psych/index.js +0 -18
  56. package/dist/modules/psych/index.js.map +0 -1
@@ -1,61 +1,65 @@
1
1
  'use strict';
2
2
 
3
- var chunkNS3DJP2O_cjs = require('../chunk-NS3DJP2O.cjs');
3
+ var chunkWFBN23AH_cjs = require('../chunk-WFBN23AH.cjs');
4
4
  var chunkJR4HYYQI_cjs = require('../chunk-JR4HYYQI.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "EventEmitter", {
9
9
  enumerable: true,
10
- get: function () { return chunkNS3DJP2O_cjs.EventEmitter; }
10
+ get: function () { return chunkWFBN23AH_cjs.EventEmitter; }
11
+ });
12
+ Object.defineProperty(exports, "InfoSyncSignature", {
13
+ enumerable: true,
14
+ get: function () { return chunkWFBN23AH_cjs.InfoSyncSignature; }
11
15
  });
12
16
  Object.defineProperty(exports, "TypedEventEmitter", {
13
17
  enumerable: true,
14
- get: function () { return chunkNS3DJP2O_cjs.TypedEventEmitter; }
18
+ get: function () { return chunkWFBN23AH_cjs.TypedEventEmitter; }
15
19
  });
16
20
  Object.defineProperty(exports, "assertEnvironment", {
17
21
  enumerable: true,
18
- get: function () { return chunkNS3DJP2O_cjs.assertEnvironment; }
22
+ get: function () { return chunkWFBN23AH_cjs.assertEnvironment; }
19
23
  });
20
24
  Object.defineProperty(exports, "environmentInfo", {
21
25
  enumerable: true,
22
- get: function () { return chunkNS3DJP2O_cjs.environmentInfo; }
26
+ get: function () { return chunkWFBN23AH_cjs.environmentInfo; }
23
27
  });
24
28
  Object.defineProperty(exports, "features", {
25
29
  enumerable: true,
26
- get: function () { return chunkNS3DJP2O_cjs.features; }
30
+ get: function () { return chunkWFBN23AH_cjs.features; }
27
31
  });
28
32
  Object.defineProperty(exports, "getEnvironment", {
29
33
  enumerable: true,
30
- get: function () { return chunkNS3DJP2O_cjs.getEnvironment; }
34
+ get: function () { return chunkWFBN23AH_cjs.getEnvironment; }
31
35
  });
32
36
  Object.defineProperty(exports, "getFileName", {
33
37
  enumerable: true,
34
- get: function () { return chunkNS3DJP2O_cjs.getFileName; }
38
+ get: function () { return chunkWFBN23AH_cjs.getFileName; }
35
39
  });
36
40
  Object.defineProperty(exports, "getFileSize", {
37
41
  enumerable: true,
38
- get: function () { return chunkNS3DJP2O_cjs.getFileSize; }
42
+ get: function () { return chunkWFBN23AH_cjs.getFileSize; }
39
43
  });
40
44
  Object.defineProperty(exports, "isBrowser", {
41
45
  enumerable: true,
42
- get: function () { return chunkNS3DJP2O_cjs.isBrowser; }
46
+ get: function () { return chunkWFBN23AH_cjs.isBrowser; }
43
47
  });
44
48
  Object.defineProperty(exports, "isNode", {
45
49
  enumerable: true,
46
- get: function () { return chunkNS3DJP2O_cjs.isNode; }
50
+ get: function () { return chunkWFBN23AH_cjs.isNode; }
47
51
  });
48
52
  Object.defineProperty(exports, "isValidFileInput", {
49
53
  enumerable: true,
50
- get: function () { return chunkNS3DJP2O_cjs.isValidFileInput; }
54
+ get: function () { return chunkWFBN23AH_cjs.isValidFileInput; }
51
55
  });
52
56
  Object.defineProperty(exports, "isWebWorker", {
53
57
  enumerable: true,
54
- get: function () { return chunkNS3DJP2O_cjs.isWebWorker; }
58
+ get: function () { return chunkWFBN23AH_cjs.isWebWorker; }
55
59
  });
56
60
  Object.defineProperty(exports, "safeDynamicImport", {
57
61
  enumerable: true,
58
- get: function () { return chunkNS3DJP2O_cjs.safeDynamicImport; }
62
+ get: function () { return chunkWFBN23AH_cjs.safeDynamicImport; }
59
63
  });
60
64
  Object.defineProperty(exports, "Poller", {
61
65
  enumerable: true,
@@ -419,4 +419,129 @@ declare function assertEnvironment(expectedEnv: 'node' | 'browser' | 'worker', m
419
419
  */
420
420
  declare function safeDynamicImport<T = unknown>(moduleName: string): Promise<T>;
421
421
 
422
- export { EventEmitter, type FileInput, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
422
+ /**
423
+ * 信息同步签名工具
424
+ *
425
+ * 用于生成和验证 Webhook 请求的 HMAC-SHA256 签名
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * // 验证 Webhook 签名
430
+ * const timestamp = parseInt(req.headers['x-sync-timestamp']);
431
+ * const signature = req.headers['x-sync-signature'];
432
+ * const payload = JSON.stringify(req.body);
433
+ *
434
+ * const isValid = InfoSyncSignature.verifySignature(
435
+ * secretKey,
436
+ * timestamp,
437
+ * payload,
438
+ * signature
439
+ * );
440
+ *
441
+ * if (!isValid) {
442
+ * return res.status(401).json({ error: 'Invalid signature' });
443
+ * }
444
+ * ```
445
+ */
446
+ declare class InfoSyncSignature {
447
+ /**
448
+ * 生成 HMAC-SHA256 签名
449
+ *
450
+ * 签名算法:
451
+ * - message = `${timestamp}.${payload}`
452
+ * - signature = HMAC-SHA256(secretKey, message)
453
+ *
454
+ * @param secretKey - 密钥(从创建 Webhook 配置时获得)
455
+ * @param timestamp - 时间戳(毫秒)
456
+ * @param payload - 负载字符串(通常是 JSON.stringify 后的请求体)
457
+ * @returns 签名(hex 格式)
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const timestamp = Date.now();
462
+ * const payload = JSON.stringify({ foo: 'bar' });
463
+ * const signature = InfoSyncSignature.generateSignature(
464
+ * 'your-secret-key',
465
+ * timestamp,
466
+ * payload
467
+ * );
468
+ * ```
469
+ */
470
+ static generateSignature(secretKey: string, timestamp: number, payload: string): string;
471
+ /**
472
+ * 验证 HMAC-SHA256 签名
473
+ *
474
+ * @param secretKey - 密钥
475
+ * @param timestamp - 时间戳(毫秒)
476
+ * @param payload - 负载字符串
477
+ * @param signature - 待验证的签名
478
+ * @returns 签名是否有效
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * const isValid = InfoSyncSignature.verifySignature(
483
+ * secretKey,
484
+ * timestamp,
485
+ * payload,
486
+ * signature
487
+ * );
488
+ *
489
+ * if (!isValid) {
490
+ * throw new Error('Invalid signature');
491
+ * }
492
+ * ```
493
+ */
494
+ static verifySignature(secretKey: string, timestamp: number, payload: string, signature: string): boolean;
495
+ /**
496
+ * 验证时间戳是否在有效期内
497
+ *
498
+ * 用于防止重放攻击,确保请求是最近发送的
499
+ *
500
+ * @param timestamp - 时间戳(毫秒)
501
+ * @param maxAge - 最大有效期(毫秒),默认 5 分钟
502
+ * @returns 时间戳是否有效
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const timestamp = parseInt(req.headers['x-sync-timestamp']);
507
+ *
508
+ * // 验证时间戳是否在 5 分钟内
509
+ * if (!InfoSyncSignature.verifyTimestamp(timestamp, 5 * 60 * 1000)) {
510
+ * return res.status(401).json({ error: 'Timestamp expired' });
511
+ * }
512
+ * ```
513
+ */
514
+ static verifyTimestamp(timestamp: number, maxAge?: number): boolean;
515
+ /**
516
+ * 完整的 Webhook 请求验证
517
+ *
518
+ * 同时验证签名和时间戳,是推荐的验证方式
519
+ *
520
+ * @param secretKey - 密钥
521
+ * @param timestamp - 时间戳(毫秒)
522
+ * @param payload - 负载字符串
523
+ * @param signature - 待验证的签名
524
+ * @param maxAge - 最大有效期(毫秒),默认 5 分钟
525
+ * @returns 验证结果
526
+ *
527
+ * @example
528
+ * ```typescript
529
+ * const result = InfoSyncSignature.verifyWebhookRequest(
530
+ * secretKey,
531
+ * timestamp,
532
+ * payload,
533
+ * signature
534
+ * );
535
+ *
536
+ * if (!result.valid) {
537
+ * return res.status(401).json({ error: result.error });
538
+ * }
539
+ * ```
540
+ */
541
+ static verifyWebhookRequest(secretKey: string, timestamp: number, payload: string, signature: string, maxAge?: number): {
542
+ valid: boolean;
543
+ error?: string;
544
+ };
545
+ }
546
+
547
+ export { EventEmitter, type FileInput, InfoSyncSignature, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
@@ -419,4 +419,129 @@ declare function assertEnvironment(expectedEnv: 'node' | 'browser' | 'worker', m
419
419
  */
420
420
  declare function safeDynamicImport<T = unknown>(moduleName: string): Promise<T>;
421
421
 
422
- export { EventEmitter, type FileInput, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
422
+ /**
423
+ * 信息同步签名工具
424
+ *
425
+ * 用于生成和验证 Webhook 请求的 HMAC-SHA256 签名
426
+ *
427
+ * @example
428
+ * ```typescript
429
+ * // 验证 Webhook 签名
430
+ * const timestamp = parseInt(req.headers['x-sync-timestamp']);
431
+ * const signature = req.headers['x-sync-signature'];
432
+ * const payload = JSON.stringify(req.body);
433
+ *
434
+ * const isValid = InfoSyncSignature.verifySignature(
435
+ * secretKey,
436
+ * timestamp,
437
+ * payload,
438
+ * signature
439
+ * );
440
+ *
441
+ * if (!isValid) {
442
+ * return res.status(401).json({ error: 'Invalid signature' });
443
+ * }
444
+ * ```
445
+ */
446
+ declare class InfoSyncSignature {
447
+ /**
448
+ * 生成 HMAC-SHA256 签名
449
+ *
450
+ * 签名算法:
451
+ * - message = `${timestamp}.${payload}`
452
+ * - signature = HMAC-SHA256(secretKey, message)
453
+ *
454
+ * @param secretKey - 密钥(从创建 Webhook 配置时获得)
455
+ * @param timestamp - 时间戳(毫秒)
456
+ * @param payload - 负载字符串(通常是 JSON.stringify 后的请求体)
457
+ * @returns 签名(hex 格式)
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const timestamp = Date.now();
462
+ * const payload = JSON.stringify({ foo: 'bar' });
463
+ * const signature = InfoSyncSignature.generateSignature(
464
+ * 'your-secret-key',
465
+ * timestamp,
466
+ * payload
467
+ * );
468
+ * ```
469
+ */
470
+ static generateSignature(secretKey: string, timestamp: number, payload: string): string;
471
+ /**
472
+ * 验证 HMAC-SHA256 签名
473
+ *
474
+ * @param secretKey - 密钥
475
+ * @param timestamp - 时间戳(毫秒)
476
+ * @param payload - 负载字符串
477
+ * @param signature - 待验证的签名
478
+ * @returns 签名是否有效
479
+ *
480
+ * @example
481
+ * ```typescript
482
+ * const isValid = InfoSyncSignature.verifySignature(
483
+ * secretKey,
484
+ * timestamp,
485
+ * payload,
486
+ * signature
487
+ * );
488
+ *
489
+ * if (!isValid) {
490
+ * throw new Error('Invalid signature');
491
+ * }
492
+ * ```
493
+ */
494
+ static verifySignature(secretKey: string, timestamp: number, payload: string, signature: string): boolean;
495
+ /**
496
+ * 验证时间戳是否在有效期内
497
+ *
498
+ * 用于防止重放攻击,确保请求是最近发送的
499
+ *
500
+ * @param timestamp - 时间戳(毫秒)
501
+ * @param maxAge - 最大有效期(毫秒),默认 5 分钟
502
+ * @returns 时间戳是否有效
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const timestamp = parseInt(req.headers['x-sync-timestamp']);
507
+ *
508
+ * // 验证时间戳是否在 5 分钟内
509
+ * if (!InfoSyncSignature.verifyTimestamp(timestamp, 5 * 60 * 1000)) {
510
+ * return res.status(401).json({ error: 'Timestamp expired' });
511
+ * }
512
+ * ```
513
+ */
514
+ static verifyTimestamp(timestamp: number, maxAge?: number): boolean;
515
+ /**
516
+ * 完整的 Webhook 请求验证
517
+ *
518
+ * 同时验证签名和时间戳,是推荐的验证方式
519
+ *
520
+ * @param secretKey - 密钥
521
+ * @param timestamp - 时间戳(毫秒)
522
+ * @param payload - 负载字符串
523
+ * @param signature - 待验证的签名
524
+ * @param maxAge - 最大有效期(毫秒),默认 5 分钟
525
+ * @returns 验证结果
526
+ *
527
+ * @example
528
+ * ```typescript
529
+ * const result = InfoSyncSignature.verifyWebhookRequest(
530
+ * secretKey,
531
+ * timestamp,
532
+ * payload,
533
+ * signature
534
+ * );
535
+ *
536
+ * if (!result.valid) {
537
+ * return res.status(401).json({ error: result.error });
538
+ * }
539
+ * ```
540
+ */
541
+ static verifyWebhookRequest(secretKey: string, timestamp: number, payload: string, signature: string, maxAge?: number): {
542
+ valid: boolean;
543
+ error?: string;
544
+ };
545
+ }
546
+
547
+ export { EventEmitter, type FileInput, InfoSyncSignature, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
@@ -1,4 +1,4 @@
1
- export { EventEmitter, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport } from '../chunk-4H4RACSE.js';
1
+ export { EventEmitter, InfoSyncSignature, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport } from '../chunk-LHNCGCWW.js';
2
2
  export { Poller } from '../chunk-IHAAKFEJ.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map