@plolink/sdk 0.0.6 → 0.0.9
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 +58 -4
- package/dist/{chunk-LHNCGCWW.js → chunk-4H4RACSE.js} +3 -137
- package/dist/chunk-4H4RACSE.js.map +1 -0
- package/dist/{chunk-WFBN23AH.cjs → chunk-NS3DJP2O.cjs} +2 -141
- package/dist/chunk-NS3DJP2O.cjs.map +1 -0
- package/dist/chunk-PJAJFV7D.js +139 -0
- package/dist/chunk-PJAJFV7D.js.map +1 -0
- package/dist/chunk-V6NFRYO2.cjs +145 -0
- package/dist/chunk-V6NFRYO2.cjs.map +1 -0
- package/dist/client-CAjIQKPm.d.cts +193 -0
- package/dist/client-CwNikk7i.d.ts +193 -0
- package/dist/common/index.cjs +19 -18
- package/dist/common/index.d.cts +2 -126
- package/dist/common/index.d.ts +2 -126
- package/dist/common/index.js +2 -1
- package/dist/index.cjs +18 -647
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -410
- package/dist/index.d.ts +4 -410
- package/dist/index.js +4 -631
- package/dist/index.js.map +1 -1
- package/dist/modules/billing/index.cjs +1 -1
- package/dist/modules/billing/index.d.cts +1 -1
- package/dist/modules/billing/index.d.ts +1 -1
- package/dist/modules/billing/index.js +1 -1
- package/dist/modules/info-sync/index.cjs +275 -0
- package/dist/modules/info-sync/index.cjs.map +1 -0
- package/dist/modules/info-sync/index.d.cts +431 -0
- package/dist/modules/info-sync/index.d.ts +431 -0
- package/dist/modules/info-sync/index.js +269 -0
- package/dist/modules/info-sync/index.js.map +1 -0
- package/dist/modules/psychology-test/index.cjs +475 -0
- package/dist/modules/psychology-test/index.cjs.map +1 -0
- package/dist/{client-D2HlV7GT.d.ts → modules/psychology-test/index.d.cts} +124 -206
- package/dist/{client-BuUQTr8R.d.cts → modules/psychology-test/index.d.ts} +124 -206
- package/dist/modules/psychology-test/index.js +473 -0
- package/dist/modules/psychology-test/index.js.map +1 -0
- package/dist/modules/rbac/index.d.cts +1 -1
- package/dist/modules/rbac/index.d.ts +1 -1
- package/dist/modules/report-writer/index.cjs +282 -0
- package/dist/modules/report-writer/index.cjs.map +1 -0
- package/dist/modules/report-writer/index.d.cts +476 -0
- package/dist/modules/report-writer/index.d.ts +476 -0
- package/dist/modules/report-writer/index.js +280 -0
- package/dist/modules/report-writer/index.js.map +1 -0
- package/dist/modules/team/index.d.cts +1 -1
- package/dist/modules/team/index.d.ts +1 -1
- package/dist/modules/video-psych-analysis/index.cjs +1 -1
- package/dist/modules/video-psych-analysis/index.d.cts +1 -1
- package/dist/modules/video-psych-analysis/index.d.ts +1 -1
- package/dist/modules/video-psych-analysis/index.js +1 -1
- package/dist/modules/virtual-account/index.d.cts +1 -1
- package/dist/modules/virtual-account/index.d.ts +1 -1
- package/dist/signature-B5LL3Zij.d.cts +126 -0
- package/dist/signature-B5LL3Zij.d.ts +126 -0
- package/package.json +16 -1
- package/dist/chunk-LHNCGCWW.js.map +0 -1
- package/dist/chunk-WFBN23AH.cjs.map +0 -1
package/dist/common/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { P as Poller } from '../poller-BlIRbwL4.cjs';
|
|
2
|
+
export { I as InfoSyncSignature } from '../signature-B5LL3Zij.cjs';
|
|
2
3
|
import '../core-77EbLgbp.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -419,129 +420,4 @@ declare function assertEnvironment(expectedEnv: 'node' | 'browser' | 'worker', m
|
|
|
419
420
|
*/
|
|
420
421
|
declare function safeDynamicImport<T = unknown>(moduleName: string): Promise<T>;
|
|
421
422
|
|
|
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 };
|
|
423
|
+
export { EventEmitter, type FileInput, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { P as Poller } from '../poller-DWKZjuSw.js';
|
|
2
|
+
export { I as InfoSyncSignature } from '../signature-B5LL3Zij.js';
|
|
2
3
|
import '../core-77EbLgbp.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -419,129 +420,4 @@ declare function assertEnvironment(expectedEnv: 'node' | 'browser' | 'worker', m
|
|
|
419
420
|
*/
|
|
420
421
|
declare function safeDynamicImport<T = unknown>(moduleName: string): Promise<T>;
|
|
421
422
|
|
|
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 };
|
|
423
|
+
export { EventEmitter, type FileInput, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport };
|
package/dist/common/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { EventEmitter,
|
|
1
|
+
export { EventEmitter, TypedEventEmitter, assertEnvironment, environmentInfo, features, getEnvironment, getFileName, getFileSize, isBrowser, isNode, isValidFileInput, isWebWorker, safeDynamicImport } from '../chunk-4H4RACSE.js';
|
|
2
2
|
export { Poller } from '../chunk-IHAAKFEJ.js';
|
|
3
|
+
export { InfoSyncSignature } from '../chunk-PJAJFV7D.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
4
5
|
//# sourceMappingURL=index.js.map
|