@frp-bridge/types 0.0.1 → 0.0.3

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/dist/index.d.mts CHANGED
@@ -350,8 +350,27 @@ interface ClientConfig extends ClientCommonConfig {
350
350
  * FRP Proxy configuration types
351
351
  * Based on: https://gofrp.org/zh-cn/docs/reference/proxy-config/
352
352
  */
353
- /** Proxy type */
354
- type ProxyType = 'tcp' | 'udp' | 'http' | 'https' | 'tcpmux' | 'stcp' | 'xtcp' | 'sudp';
353
+ /** Proxy type enum */
354
+ declare enum ProxyType {
355
+ /** TCP proxy */
356
+ TCP = "tcp",
357
+ /** UDP proxy */
358
+ UDP = "udp",
359
+ /** HTTP proxy */
360
+ HTTP = "http",
361
+ /** HTTPS proxy */
362
+ HTTPS = "https",
363
+ /** TCP multiplexer proxy */
364
+ TCPMUX = "tcpmux",
365
+ /** Secure TCP proxy */
366
+ STCP = "stcp",
367
+ /** XTCP (P2P) proxy */
368
+ XTCP = "xtcp",
369
+ /** Secure UDP proxy */
370
+ SUDP = "sudp"
371
+ }
372
+ /** Proxy type (union type for compatibility) */
373
+ type ProxyTypeUnion = `${ProxyType}`;
355
374
  /** Load balancer strategy */
356
375
  type LoadBalancerStrategy = 'random' | 'round_robin';
357
376
  /** Base proxy configuration */
@@ -375,7 +394,7 @@ interface BaseProxyConfig {
375
394
  /** Health check configuration */
376
395
  healthCheck?: {
377
396
  /** Health check type */
378
- type?: 'tcp' | 'http';
397
+ type?: ProxyType.TCP | ProxyType.HTTP;
379
398
  /** Health check timeout (seconds) */
380
399
  timeoutSeconds?: number;
381
400
  /** Max failed checks before marking unhealthy */
@@ -396,19 +415,19 @@ interface BaseProxyConfig {
396
415
  }
397
416
  /** TCP proxy configuration */
398
417
  interface TCPProxyConfig extends BaseProxyConfig {
399
- type: 'tcp';
418
+ type: ProxyType.TCP;
400
419
  /** Remote port on server */
401
420
  remotePort?: number;
402
421
  }
403
422
  /** UDP proxy configuration */
404
423
  interface UDPProxyConfig extends BaseProxyConfig {
405
- type: 'udp';
424
+ type: ProxyType.UDP;
406
425
  /** Remote port on server */
407
426
  remotePort?: number;
408
427
  }
409
428
  /** HTTP proxy configuration */
410
429
  interface HTTPProxyConfig extends BaseProxyConfig {
411
- type: 'http';
430
+ type: ProxyType.HTTP;
412
431
  /** Custom domain names */
413
432
  customDomains?: string[];
414
433
  /** Subdomain under server's subdomain_host */
@@ -434,7 +453,7 @@ interface HTTPProxyConfig extends BaseProxyConfig {
434
453
  }
435
454
  /** HTTPS proxy configuration */
436
455
  interface HTTPSProxyConfig extends BaseProxyConfig {
437
- type: 'https';
456
+ type: ProxyType.HTTPS;
438
457
  /** Custom domain names */
439
458
  customDomains?: string[];
440
459
  /** Subdomain under server's subdomain_host */
@@ -442,7 +461,7 @@ interface HTTPSProxyConfig extends BaseProxyConfig {
442
461
  }
443
462
  /** TCPMUX proxy configuration */
444
463
  interface TCPMUXProxyConfig extends BaseProxyConfig {
445
- type: 'tcpmux';
464
+ type: ProxyType.TCPMUX;
446
465
  /** Multiplexer type */
447
466
  multiplexer?: 'httpconnect';
448
467
  /** Custom domain names */
@@ -458,7 +477,7 @@ interface TCPMUXProxyConfig extends BaseProxyConfig {
458
477
  }
459
478
  /** STCP proxy configuration */
460
479
  interface STCPProxyConfig extends BaseProxyConfig {
461
- type: 'stcp';
480
+ type: ProxyType.STCP;
462
481
  /** Secret key shared with visitor */
463
482
  secretKey?: string;
464
483
  /** Allowed visitor users */
@@ -466,7 +485,7 @@ interface STCPProxyConfig extends BaseProxyConfig {
466
485
  }
467
486
  /** XTCP proxy configuration */
468
487
  interface XTCPProxyConfig extends BaseProxyConfig {
469
- type: 'xtcp';
488
+ type: ProxyType.XTCP;
470
489
  /** Secret key shared with visitor */
471
490
  secretKey?: string;
472
491
  /** Allowed visitor users */
@@ -474,7 +493,7 @@ interface XTCPProxyConfig extends BaseProxyConfig {
474
493
  }
475
494
  /** SUDP proxy configuration */
476
495
  interface SUDPProxyConfig extends BaseProxyConfig {
477
- type: 'sudp';
496
+ type: ProxyType.SUDP;
478
497
  /** Secret key shared with visitor */
479
498
  secretKey?: string;
480
499
  /** Allowed visitor users */
@@ -482,8 +501,17 @@ interface SUDPProxyConfig extends BaseProxyConfig {
482
501
  }
483
502
  /** Union type of all proxy configurations */
484
503
  type ProxyConfig = TCPProxyConfig | UDPProxyConfig | HTTPProxyConfig | HTTPSProxyConfig | TCPMUXProxyConfig | STCPProxyConfig | XTCPProxyConfig | SUDPProxyConfig;
485
- /** Visitor type */
486
- type VisitorType = 'stcp' | 'xtcp' | 'sudp';
504
+ /** Visitor type enum */
505
+ declare enum VisitorType {
506
+ /** Secure TCP visitor */
507
+ STCP = "stcp",
508
+ /** XTCP (P2P) visitor */
509
+ XTCP = "xtcp",
510
+ /** Secure UDP visitor */
511
+ SUDP = "sudp"
512
+ }
513
+ /** Visitor type (union type for compatibility) */
514
+ type VisitorTypeUnion = `${VisitorType}`;
487
515
  /** Base visitor configuration */
488
516
  interface BaseVisitorConfig {
489
517
  /** Visitor name (unique) */
@@ -501,11 +529,11 @@ interface BaseVisitorConfig {
501
529
  }
502
530
  /** STCP visitor configuration */
503
531
  interface STCPVisitorConfig extends BaseVisitorConfig {
504
- type: 'stcp';
532
+ type: VisitorType.STCP;
505
533
  }
506
534
  /** XTCP visitor configuration */
507
535
  interface XTCPVisitorConfig extends BaseVisitorConfig {
508
- type: 'xtcp';
536
+ type: VisitorType.XTCP;
509
537
  /** Keep tunnel alive even when no connection */
510
538
  keepTunnelOpen?: boolean;
511
539
  /** Max retries for establishing connection */
@@ -519,9 +547,208 @@ interface XTCPVisitorConfig extends BaseVisitorConfig {
519
547
  }
520
548
  /** SUDP visitor configuration */
521
549
  interface SUDPVisitorConfig extends BaseVisitorConfig {
522
- type: 'sudp';
550
+ type: VisitorType.SUDP;
523
551
  }
524
552
  /** Union type of all visitor configurations */
525
553
  type VisitorConfig = STCPVisitorConfig | XTCPVisitorConfig | SUDPVisitorConfig;
526
554
 
527
- export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, PortsRange, ProxyConfig, ProxyType, QUICOptions, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorType, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
555
+ /**
556
+ * Node management types
557
+ * Defines types for managing frp-bridge client nodes connected to server
558
+ */
559
+
560
+ /** Node information structure */
561
+ interface NodeInfo {
562
+ id: string;
563
+ ip: string;
564
+ port: number;
565
+ protocol: 'tcp' | 'udp';
566
+ serverAddr: string;
567
+ serverPort: number;
568
+ hostname?: string;
569
+ osType?: string;
570
+ osRelease?: string;
571
+ platform?: string;
572
+ cpuCores?: number;
573
+ memTotal?: number;
574
+ frpVersion?: string;
575
+ bridgeVersion?: string;
576
+ status: 'online' | 'offline' | 'connecting' | 'error';
577
+ lastHeartbeat?: number;
578
+ connectedAt?: number;
579
+ labels?: Record<string, string>;
580
+ metadata?: Record<string, unknown>;
581
+ token?: string;
582
+ tunnels?: ProxyConfig[];
583
+ createdAt: number;
584
+ updatedAt: number;
585
+ }
586
+ /** Payload for node registration (Client → Server) */
587
+ interface NodeRegisterPayload {
588
+ ip: string;
589
+ port: number;
590
+ serverAddr: string;
591
+ serverPort: number;
592
+ protocol: 'tcp' | 'udp';
593
+ hostname: string;
594
+ osType: string;
595
+ osRelease: string;
596
+ platform: string;
597
+ cpuCores: number;
598
+ memTotal: number;
599
+ frpVersion: string;
600
+ bridgeVersion: string;
601
+ token?: string;
602
+ }
603
+ /** Payload for node heartbeat (Client → Server) */
604
+ interface NodeHeartbeatPayload {
605
+ nodeId: string;
606
+ status: 'online' | 'error';
607
+ lastHeartbeat: number;
608
+ cpuCores?: number;
609
+ memTotal?: number;
610
+ }
611
+ /** Payload for tunnel synchronization (Client → Server) */
612
+ interface TunnelSyncPayload {
613
+ nodeId: string;
614
+ tunnels: ProxyConfig[];
615
+ timestamp: number;
616
+ }
617
+ /** Payload for tunnel management via RPC (Server → Client) */
618
+ interface TunnelManagePayload {
619
+ action: 'add' | 'update' | 'remove' | 'list';
620
+ tunnel?: ProxyConfig | Partial<ProxyConfig>;
621
+ name?: string;
622
+ }
623
+ /** Response for tunnel management */
624
+ interface TunnelManageResponse {
625
+ success: boolean;
626
+ tunnel?: ProxyConfig;
627
+ tunnels?: ProxyConfig[];
628
+ error?: string;
629
+ }
630
+ /** Query parameters for listing nodes */
631
+ interface NodeListQuery {
632
+ page?: number;
633
+ pageSize?: number;
634
+ status?: NodeInfo['status'];
635
+ labels?: Record<string, string>;
636
+ search?: string;
637
+ }
638
+ /** Response for node list query */
639
+ interface NodeListResponse {
640
+ items: NodeInfo[];
641
+ total: number;
642
+ page: number;
643
+ pageSize: number;
644
+ hasMore: boolean;
645
+ }
646
+ /** Node statistics */
647
+ interface NodeStatistics {
648
+ total: number;
649
+ online: number;
650
+ offline: number;
651
+ connecting: number;
652
+ error: number;
653
+ }
654
+ /** Error codes for node operations */
655
+ type NodeErrorCode = 'NODE_NOT_FOUND' | 'NODE_ALREADY_EXISTS' | 'INVALID_NODE_DATA' | 'HEARTBEAT_TIMEOUT' | 'STORAGE_ERROR' | 'UNAUTHORIZED';
656
+
657
+ interface RpcRequest {
658
+ id: string;
659
+ method: string;
660
+ params: Record<string, unknown>;
661
+ timeout?: number;
662
+ }
663
+ interface RpcResponse {
664
+ id: string;
665
+ status: 'success' | 'error';
666
+ result?: unknown;
667
+ error?: {
668
+ code: string;
669
+ message: string;
670
+ };
671
+ }
672
+ interface PingMessage {
673
+ type: 'ping';
674
+ timestamp: number;
675
+ }
676
+ interface PongMessage {
677
+ type: 'pong';
678
+ timestamp: number;
679
+ }
680
+ interface RegisterMessage {
681
+ type: 'register';
682
+ nodeId: string;
683
+ payload: NodeInfo;
684
+ }
685
+ type RpcInboundMessage = RpcResponse | PongMessage;
686
+ type RpcOutboundMessage = RpcRequest | PingMessage | RegisterMessage;
687
+ /**
688
+ * Base RPC message type with 'command' or 'event' type
689
+ * This format matches the RPC architecture document specification
690
+ */
691
+ interface RpcMessage {
692
+ type: 'command' | 'event';
693
+ action: string;
694
+ payload: unknown;
695
+ id?: string;
696
+ targetNodeId?: string;
697
+ }
698
+ /**
699
+ * Command message (frps -> frpc)
700
+ */
701
+ interface CommandMessage extends RpcMessage {
702
+ type: 'command';
703
+ id: string;
704
+ }
705
+ /**
706
+ * Event message (frpc -> frps)
707
+ */
708
+ interface EventMessage extends RpcMessage {
709
+ type: 'event';
710
+ id?: string;
711
+ }
712
+ /**
713
+ * Tunnel add payload
714
+ */
715
+ interface TunnelAddPayload {
716
+ name: string;
717
+ type: 'tcp' | 'http' | 'https' | 'stcp' | 'sudp' | 'xtcp';
718
+ localPort: number;
719
+ remotePort?: number;
720
+ customDomains?: string[];
721
+ subdomain?: string;
722
+ [key: string]: unknown;
723
+ }
724
+ /**
725
+ * Tunnel delete payload
726
+ */
727
+ interface TunnelDeletePayload {
728
+ name: string;
729
+ }
730
+ /**
731
+ * Tunnel response payload
732
+ */
733
+ interface TunnelResponsePayload {
734
+ success: boolean;
735
+ error?: string;
736
+ tunnel?: TunnelAddPayload;
737
+ }
738
+ /**
739
+ * Node delete payload
740
+ */
741
+ interface NodeDeletePayload {
742
+ name: string;
743
+ }
744
+ /**
745
+ * Node response payload
746
+ */
747
+ interface NodeResponsePayload {
748
+ success: boolean;
749
+ error?: string;
750
+ deletedNode?: string;
751
+ }
752
+
753
+ export { ProxyType, VisitorType };
754
+ export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, CommandMessage, EventMessage, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, NodeDeletePayload, NodeErrorCode, NodeHeartbeatPayload, NodeInfo, NodeListQuery, NodeListResponse, NodeRegisterPayload, NodeResponsePayload, NodeStatistics, PingMessage, PongMessage, PortsRange, ProxyConfig, ProxyTypeUnion, QUICOptions, RegisterMessage, RpcInboundMessage, RpcMessage, RpcOutboundMessage, RpcRequest, RpcResponse, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, TunnelAddPayload, TunnelDeletePayload, TunnelManagePayload, TunnelManageResponse, TunnelResponsePayload, TunnelSyncPayload, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorTypeUnion, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
package/dist/index.d.ts CHANGED
@@ -350,8 +350,27 @@ interface ClientConfig extends ClientCommonConfig {
350
350
  * FRP Proxy configuration types
351
351
  * Based on: https://gofrp.org/zh-cn/docs/reference/proxy-config/
352
352
  */
353
- /** Proxy type */
354
- type ProxyType = 'tcp' | 'udp' | 'http' | 'https' | 'tcpmux' | 'stcp' | 'xtcp' | 'sudp';
353
+ /** Proxy type enum */
354
+ declare enum ProxyType {
355
+ /** TCP proxy */
356
+ TCP = "tcp",
357
+ /** UDP proxy */
358
+ UDP = "udp",
359
+ /** HTTP proxy */
360
+ HTTP = "http",
361
+ /** HTTPS proxy */
362
+ HTTPS = "https",
363
+ /** TCP multiplexer proxy */
364
+ TCPMUX = "tcpmux",
365
+ /** Secure TCP proxy */
366
+ STCP = "stcp",
367
+ /** XTCP (P2P) proxy */
368
+ XTCP = "xtcp",
369
+ /** Secure UDP proxy */
370
+ SUDP = "sudp"
371
+ }
372
+ /** Proxy type (union type for compatibility) */
373
+ type ProxyTypeUnion = `${ProxyType}`;
355
374
  /** Load balancer strategy */
356
375
  type LoadBalancerStrategy = 'random' | 'round_robin';
357
376
  /** Base proxy configuration */
@@ -375,7 +394,7 @@ interface BaseProxyConfig {
375
394
  /** Health check configuration */
376
395
  healthCheck?: {
377
396
  /** Health check type */
378
- type?: 'tcp' | 'http';
397
+ type?: ProxyType.TCP | ProxyType.HTTP;
379
398
  /** Health check timeout (seconds) */
380
399
  timeoutSeconds?: number;
381
400
  /** Max failed checks before marking unhealthy */
@@ -396,19 +415,19 @@ interface BaseProxyConfig {
396
415
  }
397
416
  /** TCP proxy configuration */
398
417
  interface TCPProxyConfig extends BaseProxyConfig {
399
- type: 'tcp';
418
+ type: ProxyType.TCP;
400
419
  /** Remote port on server */
401
420
  remotePort?: number;
402
421
  }
403
422
  /** UDP proxy configuration */
404
423
  interface UDPProxyConfig extends BaseProxyConfig {
405
- type: 'udp';
424
+ type: ProxyType.UDP;
406
425
  /** Remote port on server */
407
426
  remotePort?: number;
408
427
  }
409
428
  /** HTTP proxy configuration */
410
429
  interface HTTPProxyConfig extends BaseProxyConfig {
411
- type: 'http';
430
+ type: ProxyType.HTTP;
412
431
  /** Custom domain names */
413
432
  customDomains?: string[];
414
433
  /** Subdomain under server's subdomain_host */
@@ -434,7 +453,7 @@ interface HTTPProxyConfig extends BaseProxyConfig {
434
453
  }
435
454
  /** HTTPS proxy configuration */
436
455
  interface HTTPSProxyConfig extends BaseProxyConfig {
437
- type: 'https';
456
+ type: ProxyType.HTTPS;
438
457
  /** Custom domain names */
439
458
  customDomains?: string[];
440
459
  /** Subdomain under server's subdomain_host */
@@ -442,7 +461,7 @@ interface HTTPSProxyConfig extends BaseProxyConfig {
442
461
  }
443
462
  /** TCPMUX proxy configuration */
444
463
  interface TCPMUXProxyConfig extends BaseProxyConfig {
445
- type: 'tcpmux';
464
+ type: ProxyType.TCPMUX;
446
465
  /** Multiplexer type */
447
466
  multiplexer?: 'httpconnect';
448
467
  /** Custom domain names */
@@ -458,7 +477,7 @@ interface TCPMUXProxyConfig extends BaseProxyConfig {
458
477
  }
459
478
  /** STCP proxy configuration */
460
479
  interface STCPProxyConfig extends BaseProxyConfig {
461
- type: 'stcp';
480
+ type: ProxyType.STCP;
462
481
  /** Secret key shared with visitor */
463
482
  secretKey?: string;
464
483
  /** Allowed visitor users */
@@ -466,7 +485,7 @@ interface STCPProxyConfig extends BaseProxyConfig {
466
485
  }
467
486
  /** XTCP proxy configuration */
468
487
  interface XTCPProxyConfig extends BaseProxyConfig {
469
- type: 'xtcp';
488
+ type: ProxyType.XTCP;
470
489
  /** Secret key shared with visitor */
471
490
  secretKey?: string;
472
491
  /** Allowed visitor users */
@@ -474,7 +493,7 @@ interface XTCPProxyConfig extends BaseProxyConfig {
474
493
  }
475
494
  /** SUDP proxy configuration */
476
495
  interface SUDPProxyConfig extends BaseProxyConfig {
477
- type: 'sudp';
496
+ type: ProxyType.SUDP;
478
497
  /** Secret key shared with visitor */
479
498
  secretKey?: string;
480
499
  /** Allowed visitor users */
@@ -482,8 +501,17 @@ interface SUDPProxyConfig extends BaseProxyConfig {
482
501
  }
483
502
  /** Union type of all proxy configurations */
484
503
  type ProxyConfig = TCPProxyConfig | UDPProxyConfig | HTTPProxyConfig | HTTPSProxyConfig | TCPMUXProxyConfig | STCPProxyConfig | XTCPProxyConfig | SUDPProxyConfig;
485
- /** Visitor type */
486
- type VisitorType = 'stcp' | 'xtcp' | 'sudp';
504
+ /** Visitor type enum */
505
+ declare enum VisitorType {
506
+ /** Secure TCP visitor */
507
+ STCP = "stcp",
508
+ /** XTCP (P2P) visitor */
509
+ XTCP = "xtcp",
510
+ /** Secure UDP visitor */
511
+ SUDP = "sudp"
512
+ }
513
+ /** Visitor type (union type for compatibility) */
514
+ type VisitorTypeUnion = `${VisitorType}`;
487
515
  /** Base visitor configuration */
488
516
  interface BaseVisitorConfig {
489
517
  /** Visitor name (unique) */
@@ -501,11 +529,11 @@ interface BaseVisitorConfig {
501
529
  }
502
530
  /** STCP visitor configuration */
503
531
  interface STCPVisitorConfig extends BaseVisitorConfig {
504
- type: 'stcp';
532
+ type: VisitorType.STCP;
505
533
  }
506
534
  /** XTCP visitor configuration */
507
535
  interface XTCPVisitorConfig extends BaseVisitorConfig {
508
- type: 'xtcp';
536
+ type: VisitorType.XTCP;
509
537
  /** Keep tunnel alive even when no connection */
510
538
  keepTunnelOpen?: boolean;
511
539
  /** Max retries for establishing connection */
@@ -519,9 +547,208 @@ interface XTCPVisitorConfig extends BaseVisitorConfig {
519
547
  }
520
548
  /** SUDP visitor configuration */
521
549
  interface SUDPVisitorConfig extends BaseVisitorConfig {
522
- type: 'sudp';
550
+ type: VisitorType.SUDP;
523
551
  }
524
552
  /** Union type of all visitor configurations */
525
553
  type VisitorConfig = STCPVisitorConfig | XTCPVisitorConfig | SUDPVisitorConfig;
526
554
 
527
- export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, PortsRange, ProxyConfig, ProxyType, QUICOptions, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorType, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
555
+ /**
556
+ * Node management types
557
+ * Defines types for managing frp-bridge client nodes connected to server
558
+ */
559
+
560
+ /** Node information structure */
561
+ interface NodeInfo {
562
+ id: string;
563
+ ip: string;
564
+ port: number;
565
+ protocol: 'tcp' | 'udp';
566
+ serverAddr: string;
567
+ serverPort: number;
568
+ hostname?: string;
569
+ osType?: string;
570
+ osRelease?: string;
571
+ platform?: string;
572
+ cpuCores?: number;
573
+ memTotal?: number;
574
+ frpVersion?: string;
575
+ bridgeVersion?: string;
576
+ status: 'online' | 'offline' | 'connecting' | 'error';
577
+ lastHeartbeat?: number;
578
+ connectedAt?: number;
579
+ labels?: Record<string, string>;
580
+ metadata?: Record<string, unknown>;
581
+ token?: string;
582
+ tunnels?: ProxyConfig[];
583
+ createdAt: number;
584
+ updatedAt: number;
585
+ }
586
+ /** Payload for node registration (Client → Server) */
587
+ interface NodeRegisterPayload {
588
+ ip: string;
589
+ port: number;
590
+ serverAddr: string;
591
+ serverPort: number;
592
+ protocol: 'tcp' | 'udp';
593
+ hostname: string;
594
+ osType: string;
595
+ osRelease: string;
596
+ platform: string;
597
+ cpuCores: number;
598
+ memTotal: number;
599
+ frpVersion: string;
600
+ bridgeVersion: string;
601
+ token?: string;
602
+ }
603
+ /** Payload for node heartbeat (Client → Server) */
604
+ interface NodeHeartbeatPayload {
605
+ nodeId: string;
606
+ status: 'online' | 'error';
607
+ lastHeartbeat: number;
608
+ cpuCores?: number;
609
+ memTotal?: number;
610
+ }
611
+ /** Payload for tunnel synchronization (Client → Server) */
612
+ interface TunnelSyncPayload {
613
+ nodeId: string;
614
+ tunnels: ProxyConfig[];
615
+ timestamp: number;
616
+ }
617
+ /** Payload for tunnel management via RPC (Server → Client) */
618
+ interface TunnelManagePayload {
619
+ action: 'add' | 'update' | 'remove' | 'list';
620
+ tunnel?: ProxyConfig | Partial<ProxyConfig>;
621
+ name?: string;
622
+ }
623
+ /** Response for tunnel management */
624
+ interface TunnelManageResponse {
625
+ success: boolean;
626
+ tunnel?: ProxyConfig;
627
+ tunnels?: ProxyConfig[];
628
+ error?: string;
629
+ }
630
+ /** Query parameters for listing nodes */
631
+ interface NodeListQuery {
632
+ page?: number;
633
+ pageSize?: number;
634
+ status?: NodeInfo['status'];
635
+ labels?: Record<string, string>;
636
+ search?: string;
637
+ }
638
+ /** Response for node list query */
639
+ interface NodeListResponse {
640
+ items: NodeInfo[];
641
+ total: number;
642
+ page: number;
643
+ pageSize: number;
644
+ hasMore: boolean;
645
+ }
646
+ /** Node statistics */
647
+ interface NodeStatistics {
648
+ total: number;
649
+ online: number;
650
+ offline: number;
651
+ connecting: number;
652
+ error: number;
653
+ }
654
+ /** Error codes for node operations */
655
+ type NodeErrorCode = 'NODE_NOT_FOUND' | 'NODE_ALREADY_EXISTS' | 'INVALID_NODE_DATA' | 'HEARTBEAT_TIMEOUT' | 'STORAGE_ERROR' | 'UNAUTHORIZED';
656
+
657
+ interface RpcRequest {
658
+ id: string;
659
+ method: string;
660
+ params: Record<string, unknown>;
661
+ timeout?: number;
662
+ }
663
+ interface RpcResponse {
664
+ id: string;
665
+ status: 'success' | 'error';
666
+ result?: unknown;
667
+ error?: {
668
+ code: string;
669
+ message: string;
670
+ };
671
+ }
672
+ interface PingMessage {
673
+ type: 'ping';
674
+ timestamp: number;
675
+ }
676
+ interface PongMessage {
677
+ type: 'pong';
678
+ timestamp: number;
679
+ }
680
+ interface RegisterMessage {
681
+ type: 'register';
682
+ nodeId: string;
683
+ payload: NodeInfo;
684
+ }
685
+ type RpcInboundMessage = RpcResponse | PongMessage;
686
+ type RpcOutboundMessage = RpcRequest | PingMessage | RegisterMessage;
687
+ /**
688
+ * Base RPC message type with 'command' or 'event' type
689
+ * This format matches the RPC architecture document specification
690
+ */
691
+ interface RpcMessage {
692
+ type: 'command' | 'event';
693
+ action: string;
694
+ payload: unknown;
695
+ id?: string;
696
+ targetNodeId?: string;
697
+ }
698
+ /**
699
+ * Command message (frps -> frpc)
700
+ */
701
+ interface CommandMessage extends RpcMessage {
702
+ type: 'command';
703
+ id: string;
704
+ }
705
+ /**
706
+ * Event message (frpc -> frps)
707
+ */
708
+ interface EventMessage extends RpcMessage {
709
+ type: 'event';
710
+ id?: string;
711
+ }
712
+ /**
713
+ * Tunnel add payload
714
+ */
715
+ interface TunnelAddPayload {
716
+ name: string;
717
+ type: 'tcp' | 'http' | 'https' | 'stcp' | 'sudp' | 'xtcp';
718
+ localPort: number;
719
+ remotePort?: number;
720
+ customDomains?: string[];
721
+ subdomain?: string;
722
+ [key: string]: unknown;
723
+ }
724
+ /**
725
+ * Tunnel delete payload
726
+ */
727
+ interface TunnelDeletePayload {
728
+ name: string;
729
+ }
730
+ /**
731
+ * Tunnel response payload
732
+ */
733
+ interface TunnelResponsePayload {
734
+ success: boolean;
735
+ error?: string;
736
+ tunnel?: TunnelAddPayload;
737
+ }
738
+ /**
739
+ * Node delete payload
740
+ */
741
+ interface NodeDeletePayload {
742
+ name: string;
743
+ }
744
+ /**
745
+ * Node response payload
746
+ */
747
+ interface NodeResponsePayload {
748
+ success: boolean;
749
+ error?: string;
750
+ deletedNode?: string;
751
+ }
752
+
753
+ export { ProxyType, VisitorType };
754
+ export type { AuthClientConfig, AuthMethod, AuthOIDCClientConfig, AuthOIDCServerConfig, AuthScope, AuthServerConfig, BaseProxyConfig, BaseVisitorConfig, ClientCommonConfig, ClientConfig, ClientTransportConfig, ClientTransportProtocol, CommandMessage, EventMessage, FileSource, HTTPHeader, HTTPPluginOptions, HTTPProxyConfig, HTTPSProxyConfig, HeaderOperations, LoadBalancerStrategy, LogConfig, LogLevel, NatTraversalConfig, NodeDeletePayload, NodeErrorCode, NodeHeartbeatPayload, NodeInfo, NodeListQuery, NodeListResponse, NodeRegisterPayload, NodeResponsePayload, NodeStatistics, PingMessage, PongMessage, PortsRange, ProxyConfig, ProxyTypeUnion, QUICOptions, RegisterMessage, RpcInboundMessage, RpcMessage, RpcOutboundMessage, RpcRequest, RpcResponse, SSHTunnelGateway, STCPProxyConfig, STCPVisitorConfig, SUDPProxyConfig, SUDPVisitorConfig, ServerConfig, ServerTransportConfig, TCPMUXProxyConfig, TCPProxyConfig, TLSClientConfig, TLSConfig, TLSServerConfig, TunnelAddPayload, TunnelDeletePayload, TunnelManagePayload, TunnelManageResponse, TunnelResponsePayload, TunnelSyncPayload, UDPProxyConfig, ValueSource, ValueSourceType, VirtualNetConfig, VisitorConfig, VisitorTypeUnion, WebServerConfig, XTCPProxyConfig, XTCPVisitorConfig };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
-
1
+ var P=(p=>(p.TCP="tcp",p.UDP="udp",p.HTTP="http",p.HTTPS="https",p.TCPMUX="tcpmux",p.STCP="stcp",p.XTCP="xtcp",p.SUDP="sudp",p))(P||{}),T=(p=>(p.STCP="stcp",p.XTCP="xtcp",p.SUDP="sudp",p))(T||{});export{P as ProxyType,T as VisitorType};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frp-bridge/types",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "description": "Frp bridge type definitions",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/frp-web/bridge#readme",