@routr/common 2.16.0 → 2.19.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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/connect/config.d.ts +5 -1
  3. package/dist/connect/mappers/agent.js +1 -0
  4. package/dist/connect/mappers/domain.js +1 -0
  5. package/dist/connect/mappers/peer.js +1 -0
  6. package/dist/connect/mappers/trunk.js +1 -0
  7. package/dist/connect/protos/agents.proto +7 -0
  8. package/dist/connect/protos/domains.proto +7 -0
  9. package/dist/connect/protos/peers.proto +7 -0
  10. package/dist/connect/protos/trace.proto +28 -0
  11. package/dist/connect/protos/trunks.proto +7 -0
  12. package/dist/connect/schemas/agent.d.ts +10 -0
  13. package/dist/connect/schemas/agent.js +8 -0
  14. package/dist/connect/schemas/domain.d.ts +10 -0
  15. package/dist/connect/schemas/domain.js +8 -0
  16. package/dist/connect/schemas/peer.d.ts +10 -0
  17. package/dist/connect/schemas/peer.js +8 -0
  18. package/dist/connect/schemas/trunk.d.ts +10 -0
  19. package/dist/connect/schemas/trunk.js +8 -0
  20. package/dist/connect/types.d.ts +7 -0
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +2 -1
  23. package/dist/protos/processor.proto +4 -0
  24. package/dist/trace/compat.d.ts +37 -0
  25. package/dist/trace/compat.js +131 -0
  26. package/dist/trace/diff.d.ts +48 -0
  27. package/dist/trace/diff.js +152 -0
  28. package/dist/trace/index.d.ts +11 -0
  29. package/dist/trace/index.js +68 -0
  30. package/dist/trace/metadata.d.ts +28 -0
  31. package/dist/trace/metadata.js +75 -0
  32. package/dist/trace/normalize.d.ts +11 -0
  33. package/dist/trace/normalize.js +39 -0
  34. package/dist/trace/redact.d.ts +19 -0
  35. package/dist/trace/redact.js +52 -0
  36. package/dist/trace/rules/facts.d.ts +43 -0
  37. package/dist/trace/rules/facts.js +117 -0
  38. package/dist/trace/rules/index.d.ts +34 -0
  39. package/dist/trace/rules/index.js +153 -0
  40. package/dist/trace/rules/sip/ack-2xx.d.ts +2 -0
  41. package/dist/trace/rules/sip/ack-2xx.js +56 -0
  42. package/dist/trace/rules/sip/cancel-matches.d.ts +2 -0
  43. package/dist/trace/rules/sip/cancel-matches.js +46 -0
  44. package/dist/trace/rules/sip/credentials-stripped.d.ts +2 -0
  45. package/dist/trace/rules/sip/credentials-stripped.js +41 -0
  46. package/dist/trace/rules/sip/cseq-ack.d.ts +2 -0
  47. package/dist/trace/rules/sip/cseq-ack.js +40 -0
  48. package/dist/trace/rules/sip/cseq-monotonic.d.ts +2 -0
  49. package/dist/trace/rules/sip/cseq-monotonic.js +50 -0
  50. package/dist/trace/rules/sip/max-forwards.d.ts +2 -0
  51. package/dist/trace/rules/sip/max-forwards.js +47 -0
  52. package/dist/trace/rules/sip/private-address.d.ts +2 -0
  53. package/dist/trace/rules/sip/private-address.js +48 -0
  54. package/dist/trace/rules/sip/record-route-self.d.ts +2 -0
  55. package/dist/trace/rules/sip/record-route-self.js +46 -0
  56. package/dist/trace/rules/sip/register-ok.d.ts +2 -0
  57. package/dist/trace/rules/sip/register-ok.js +52 -0
  58. package/dist/trace/rules/sip/retransmission.d.ts +2 -0
  59. package/dist/trace/rules/sip/retransmission.js +47 -0
  60. package/dist/trace/rules/sip/route-self-removed.d.ts +2 -0
  61. package/dist/trace/rules/sip/route-self-removed.js +38 -0
  62. package/dist/trace/rules/sip/via.d.ts +2 -0
  63. package/dist/trace/rules/sip/via.js +50 -0
  64. package/dist/trace/rules/sip-connect/from-e164-or-anonymous.d.ts +2 -0
  65. package/dist/trace/rules/sip-connect/from-e164-or-anonymous.js +43 -0
  66. package/dist/trace/rules/sip-connect/pai-e164.d.ts +2 -0
  67. package/dist/trace/rules/sip-connect/pai-e164.js +44 -0
  68. package/dist/trace/rules/sip-connect/pai-single.d.ts +2 -0
  69. package/dist/trace/rules/sip-connect/pai-single.js +41 -0
  70. package/dist/trace/rules/sip-connect/privacy.d.ts +2 -0
  71. package/dist/trace/rules/sip-connect/privacy.js +50 -0
  72. package/dist/trace/rules/sip-connect/request-uri-e164.d.ts +2 -0
  73. package/dist/trace/rules/sip-connect/request-uri-e164.js +44 -0
  74. package/dist/trace/rules/sip-connect/scope.d.ts +11 -0
  75. package/dist/trace/rules/sip-connect/scope.js +19 -0
  76. package/dist/trace/rules/types.d.ts +34 -0
  77. package/dist/trace/rules/types.js +13 -0
  78. package/dist/trace/sanitize.d.ts +40 -0
  79. package/dist/trace/sanitize.js +85 -0
  80. package/dist/trace/schema.d.ts +338 -0
  81. package/dist/trace/schema.js +197 -0
  82. package/dist/trace/status.d.ts +15 -0
  83. package/dist/trace/status.js +102 -0
  84. package/dist/trace/types.d.ts +126 -0
  85. package/dist/trace/types.js +82 -0
  86. package/dist/trace/validate.d.ts +56 -0
  87. package/dist/trace/validate.js +140 -0
  88. package/dist/types.d.ts +2 -0
  89. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- <a href="https://gitpod.io/#https://github.com/fonoster/routr"> <img src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod" alt="Contribute with Gitpod" />
1
+ <a href="https://docs.routr.io/guides/develop-with-dev-containers"> <img src="https://img.shields.io/badge/Contribute%20with-Dev%20Containers-908a85?logo=docker" alt="Contribute with Dev Containers" />
2
2
 
3
3
  This module is part of the [Routr](https://routr.io) project. By itself, it does not do much. It is intended to be used as a dependency for other modules. For more information about the project, please visit [https://github.com/fonoster/routr](https://github.com/fonoster/routr).
@@ -1,5 +1,5 @@
1
1
  import { LoadBalancingAlgorithm, Privacy, Transport } from "../types";
2
- import { APIVersion, Kind } from "./types";
2
+ import { APIVersion, Kind, TraceSettings } from "./types";
3
3
  export interface ConfigBase {
4
4
  apiVersion: APIVersion;
5
5
  ref: string;
@@ -26,6 +26,7 @@ export interface AgentConfig extends ConfigBase {
26
26
  maxContacts?: number;
27
27
  expires?: number;
28
28
  enabled: boolean;
29
+ trace?: TraceSettings;
29
30
  };
30
31
  }
31
32
  export interface PeerConfig extends ConfigBase {
@@ -42,6 +43,7 @@ export interface PeerConfig extends ConfigBase {
42
43
  algorithm: LoadBalancingAlgorithm;
43
44
  withSessionAffinity: boolean;
44
45
  };
46
+ trace?: TraceSettings;
45
47
  };
46
48
  }
47
49
  export interface CredentialsConfig extends ConfigBase {
@@ -64,6 +66,7 @@ export interface DomainConfig extends ConfigBase {
64
66
  numberRef: string;
65
67
  }[];
66
68
  };
69
+ trace?: TraceSettings;
67
70
  };
68
71
  }
69
72
  export interface NumberConfig extends Omit<ConfigBase, "metadata"> {
@@ -112,6 +115,7 @@ export interface TrunkConfig extends ConfigBase {
112
115
  enabled: boolean;
113
116
  }[];
114
117
  };
118
+ trace?: TraceSettings;
115
119
  };
116
120
  }
117
121
  export type UserConfig = AccessControlListConfig | AgentConfig | PeerConfig | CredentialsConfig | DomainConfig | NumberConfig | TrunkConfig;
@@ -39,6 +39,7 @@ function mapToAgent(config) {
39
39
  credentialsRef: config.spec.credentialsRef,
40
40
  maxContacts: config.spec.maxContacts,
41
41
  expires: config.spec.expires,
42
+ trace: config.spec.trace,
42
43
  createdAt: new Date().getTime(),
43
44
  updatedAt: new Date().getTime()
44
45
  };
@@ -14,6 +14,7 @@ function mapToDomain(config) {
14
14
  domainUri: config.spec.context.domainUri,
15
15
  accessControlListRef: config.spec.accessControlListRef,
16
16
  egressPolicies: config.spec.context.egressPolicies,
17
+ trace: config.spec.trace,
17
18
  createdAt: new Date().getTime(),
18
19
  updatedAt: new Date().getTime()
19
20
  };
@@ -22,6 +22,7 @@ function mapToPeer(config) {
22
22
  withSessionAffinity: (_b = config.spec.loadBalancing) === null || _b === void 0 ? void 0 : _b.withSessionAffinity,
23
23
  maxContacts: config.spec.maxContacts,
24
24
  expires: config.spec.expires,
25
+ trace: config.spec.trace,
25
26
  createdAt: new Date().getTime(),
26
27
  updatedAt: new Date().getTime()
27
28
  };
@@ -29,6 +29,7 @@ function mapToTrunk(config) {
29
29
  priority: entry.priority
30
30
  };
31
31
  }),
32
+ trace: config.spec.trace,
32
33
  createdAt: new Date().getTime(),
33
34
  updatedAt: new Date().getTime()
34
35
  };
@@ -22,6 +22,7 @@ package fonoster.routr.connect.agents.v2beta1;
22
22
 
23
23
  import "google/protobuf/struct.proto";
24
24
  import "google/protobuf/empty.proto";
25
+ import "trace.proto";
25
26
  import "domains.proto";
26
27
  import "credentials.proto";
27
28
 
@@ -74,6 +75,8 @@ message Agent {
74
75
  fonoster.routr.connect.credentials.v2beta1.Credentials credentials = 10;
75
76
  // The extended attributes of the Agent
76
77
  .google.protobuf.Struct extended = 11;
78
+ // Message recording for the calls that touch this Agent
79
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 14;
77
80
  }
78
81
 
79
82
  // The request message for the Agents.Create method
@@ -96,6 +99,8 @@ message CreateAgentRequest {
96
99
  int32 expires = 9;
97
100
  // The extended attributes of the Agent
98
101
  .google.protobuf.Struct extended = 7;
102
+ // Message recording for the calls that touch this Agent
103
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 10;
99
104
  }
100
105
 
101
106
  // The request message for the Agents.Update method
@@ -118,6 +123,8 @@ message UpdateAgentRequest {
118
123
  optional int32 expires = 9;
119
124
  // The extended attributes of the Agent
120
125
  .google.protobuf.Struct extended = 7;
126
+ // Message recording for the calls that touch this Agent
127
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 10;
121
128
  }
122
129
 
123
130
  // The request message for the Agents.Get method
@@ -22,6 +22,7 @@ package fonoster.routr.connect.domains.v2beta1;
22
22
 
23
23
  import "google/protobuf/struct.proto";
24
24
  import "google/protobuf/empty.proto";
25
+ import "trace.proto";
25
26
  import "acl.proto";
26
27
  import "numbers.proto";
27
28
 
@@ -71,6 +72,8 @@ message Domain {
71
72
  repeated EgressPolicy egress_policies = 8;
72
73
  // The extended attributes of the Domain
73
74
  .google.protobuf.Struct extended = 9;
75
+ // Message recording for the calls that touch this Domain
76
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 10;
74
77
  }
75
78
 
76
79
  // The request message for Domains.Create
@@ -85,6 +88,8 @@ message CreateDomainRequest {
85
88
  repeated EgressPolicy egress_policies = 4;
86
89
  // The extended attributes of the Domain
87
90
  .google.protobuf.Struct extended = 5;
91
+ // Message recording for the calls that touch this Domain
92
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 6;
88
93
  }
89
94
 
90
95
  // The request message for Domains.Update
@@ -99,6 +104,8 @@ message UpdateDomainRequest {
99
104
  repeated EgressPolicy egress_policies = 4;
100
105
  // The extended attributes of the Domain
101
106
  .google.protobuf.Struct extended = 5;
107
+ // Message recording for the calls that touch this Domain
108
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 6;
102
109
  }
103
110
 
104
111
  // The request message for Domains.Get
@@ -22,6 +22,7 @@ package fonoster.routr.connect.peers.v2beta1;
22
22
 
23
23
  import "google/protobuf/struct.proto";
24
24
  import "google/protobuf/empty.proto";
25
+ import "trace.proto";
25
26
  import "acl.proto";
26
27
  import "credentials.proto";
27
28
 
@@ -85,6 +86,8 @@ message Peer {
85
86
  int32 expires = 16;
86
87
  // The extended attributes of the Peer
87
88
  .google.protobuf.Struct extended = 14;
89
+ // Message recording for the calls that touch this Peer
90
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 17;
88
91
  }
89
92
 
90
93
  // The request message for the Peers.Create method
@@ -113,6 +116,8 @@ message CreatePeerRequest {
113
116
  int32 expires = 12;
114
117
  // The extended attributes of the Peer
115
118
  .google.protobuf.Struct extended = 10;
119
+ // Message recording for the calls that touch this Peer
120
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 13;
116
121
  }
117
122
 
118
123
  // The request message for the Peers.Update method
@@ -141,6 +146,8 @@ message UpdatePeerRequest {
141
146
  optional int32 expires = 12;
142
147
  // The extended attributes of the Peer
143
148
  .google.protobuf.Struct extended = 10;
149
+ // Message recording for the calls that touch this Peer
150
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 13;
144
151
  }
145
152
 
146
153
  // The request message for the Peers.Get method
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/routr
4
+ *
5
+ * This file is part of Routr.
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ syntax = "proto3";
20
+
21
+ package fonoster.routr.connect.trace.v2beta1;
22
+
23
+ // Message recording for the calls that touch a resource
24
+ message Trace {
25
+ // When true, the Message Dispatcher records every message of a call that
26
+ // touches this resource (in its "flagged" mode)
27
+ bool enabled = 1;
28
+ }
@@ -22,6 +22,7 @@ package fonoster.routr.connect.trunks.v2beta1;
22
22
 
23
23
  import "google/protobuf/struct.proto";
24
24
  import "google/protobuf/empty.proto";
25
+ import "trace.proto";
25
26
  import "acl.proto";
26
27
  import "credentials.proto";
27
28
 
@@ -85,6 +86,8 @@ message Trunk {
85
86
  repeated TrunkURI uris = 11;
86
87
  // The extended attributes of the Trunk
87
88
  .google.protobuf.Struct extended = 12;
89
+ // Message recording for the calls that touch this Trunk
90
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 13;
88
91
  }
89
92
 
90
93
  // The message for the Trunk.Create
@@ -107,6 +110,8 @@ message CreateTrunkRequest {
107
110
  repeated TrunkURI uris = 8;
108
111
  // The extended attributes of the Trunk
109
112
  .google.protobuf.Struct extended = 9;
113
+ // Message recording for the calls that touch this Trunk
114
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 10;
110
115
  }
111
116
 
112
117
  // The message for the Trunk.Update
@@ -131,6 +136,8 @@ message UpdateTrunkRequest {
131
136
  repeated TrunkURI uris = 9;
132
137
  // The extended attributes of the Trunk
133
138
  .google.protobuf.Struct extended = 10;
139
+ // Message recording for the calls that touch this Trunk
140
+ fonoster.routr.connect.trace.v2beta1.Trace trace = 11;
134
141
  }
135
142
 
136
143
  // The message for the Trunk.Get
@@ -30,6 +30,16 @@ declare const _default: {
30
30
  description: string;
31
31
  type: string;
32
32
  properties: {
33
+ trace: {
34
+ description: string;
35
+ type: string;
36
+ properties: {
37
+ enabled: {
38
+ type: string;
39
+ };
40
+ };
41
+ required: string[];
42
+ };
33
43
  username: {
34
44
  description: string;
35
45
  type: string;
@@ -50,6 +50,14 @@ exports.default = {
50
50
  description: "Operations spec for an Agent",
51
51
  type: "object",
52
52
  properties: {
53
+ trace: {
54
+ description: "Message recording for the calls that touch this Agent",
55
+ type: "object",
56
+ properties: {
57
+ enabled: { type: "boolean" }
58
+ },
59
+ required: ["enabled"]
60
+ },
53
61
  username: {
54
62
  description: "The username for the Agent",
55
63
  type: "string",
@@ -30,6 +30,16 @@ declare const _default: {
30
30
  description: string;
31
31
  type: string;
32
32
  properties: {
33
+ trace: {
34
+ description: string;
35
+ type: string;
36
+ properties: {
37
+ enabled: {
38
+ type: string;
39
+ };
40
+ };
41
+ required: string[];
42
+ };
33
43
  context: {
34
44
  description: string;
35
45
  type: string;
@@ -50,6 +50,14 @@ exports.default = {
50
50
  description: "Operations spec for an Domain",
51
51
  type: "object",
52
52
  properties: {
53
+ trace: {
54
+ description: "Message recording for the calls that touch this Domain",
55
+ type: "object",
56
+ properties: {
57
+ enabled: { type: "boolean" }
58
+ },
59
+ required: ["enabled"]
60
+ },
53
61
  context: {
54
62
  description: "The username for the Domain",
55
63
  type: "object",
@@ -30,6 +30,16 @@ declare const _default: {
30
30
  description: string;
31
31
  type: string;
32
32
  properties: {
33
+ trace: {
34
+ description: string;
35
+ type: string;
36
+ properties: {
37
+ enabled: {
38
+ type: string;
39
+ };
40
+ };
41
+ required: string[];
42
+ };
33
43
  username: {
34
44
  description: string;
35
45
  type: string;
@@ -50,6 +50,14 @@ exports.default = {
50
50
  description: "Operations spec for an Peer",
51
51
  type: "object",
52
52
  properties: {
53
+ trace: {
54
+ description: "Message recording for the calls that touch this Peer",
55
+ type: "object",
56
+ properties: {
57
+ enabled: { type: "boolean" }
58
+ },
59
+ required: ["enabled"]
60
+ },
53
61
  username: {
54
62
  description: "The username for the Peer",
55
63
  type: "string",
@@ -30,6 +30,16 @@ declare const _default: {
30
30
  description: string;
31
31
  type: string;
32
32
  properties: {
33
+ trace: {
34
+ description: string;
35
+ type: string;
36
+ properties: {
37
+ enabled: {
38
+ type: string;
39
+ };
40
+ };
41
+ required: string[];
42
+ };
33
43
  inbound: {
34
44
  description: string;
35
45
  type: string;
@@ -50,6 +50,14 @@ exports.default = {
50
50
  description: "Operations spec for an Trunk",
51
51
  type: "object",
52
52
  properties: {
53
+ trace: {
54
+ description: "Message recording for the calls that touch this Trunk",
55
+ type: "object",
56
+ properties: {
57
+ enabled: { type: "boolean" }
58
+ },
59
+ required: ["enabled"]
60
+ },
53
61
  inbound: {
54
62
  description: "Inbound configuration",
55
63
  type: "object",
@@ -22,6 +22,9 @@ export interface BaseConnectModel {
22
22
  updatedAt: number;
23
23
  extended?: Record<string, unknown>;
24
24
  }
25
+ export interface TraceSettings {
26
+ enabled: boolean;
27
+ }
25
28
  export interface AccessControlList extends BaseConnectModel {
26
29
  allow: string[];
27
30
  deny: string[];
@@ -31,6 +34,7 @@ export interface Domain extends BaseConnectModel {
31
34
  accessControlListRef?: string;
32
35
  accessControlList?: AccessControlList;
33
36
  egressPolicies?: EgressPolicy[];
37
+ trace?: TraceSettings;
34
38
  }
35
39
  export interface EgressPolicy {
36
40
  numberRef: string;
@@ -47,6 +51,7 @@ export interface Agent extends BaseConnectModel {
47
51
  expires?: number;
48
52
  credentialsRef?: string;
49
53
  credentials?: Credentials;
54
+ trace?: TraceSettings;
50
55
  }
51
56
  export interface Credentials extends BaseConnectModel {
52
57
  username: string;
@@ -76,6 +81,7 @@ export interface Trunk extends BaseConnectModel {
76
81
  outboundCredentialsRef?: string;
77
82
  outboundCredentials?: Credentials;
78
83
  uris?: TrunkURI[];
84
+ trace?: TraceSettings;
79
85
  }
80
86
  export interface TrunkURI {
81
87
  ref?: string;
@@ -101,6 +107,7 @@ export interface Peer extends BaseConnectModel {
101
107
  expires?: number;
102
108
  balancingAlgorithm?: LoadBalancingAlgorithm;
103
109
  withSessionAffinity?: boolean;
110
+ trace?: TraceSettings;
104
111
  }
105
112
  export type ConnectModel = Agent | Peer | INumber | Trunk | Domain | Credentials | AccessControlList;
106
113
  export type RoutableResourceUnion = Agent | Peer | INumber;
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * as CommonErrors from "./errors";
15
15
  export * as ConnectSchemas from "./connect/schemas";
16
16
  export * as Environment from "./envs";
17
17
  export * as Verifier from "./verifier";
18
+ export * as Trace from "./trace";
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Verifier = exports.Environment = exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonResponse = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.statusMap = exports.GRPC_SERVING_STATUS = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
36
+ exports.Trace = exports.Verifier = exports.Environment = exports.ConnectSchemas = exports.CommonErrors = exports.CommonTypes = exports.CommonResponse = exports.CommonRequester = exports.CommonConnect = exports.Assertions = exports.Tracer = exports.IpUtils = exports.Helper = exports.Redis = exports.Auth = exports.statusMap = exports.GRPC_SERVING_STATUS = exports.LOCATION_OBJECT_PROTO = exports.PROCESSOR_OBJECT_PROTO = exports.Method = exports.Transport = exports.getObjectProto = exports.createService = void 0;
37
37
  /*
38
38
  * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
39
39
  * http://github.com/fonoster/routr
@@ -76,3 +76,4 @@ exports.CommonErrors = __importStar(require("./errors"));
76
76
  exports.ConnectSchemas = __importStar(require("./connect/schemas"));
77
77
  exports.Environment = __importStar(require("./envs"));
78
78
  exports.Verifier = __importStar(require("./verifier"));
79
+ exports.Trace = __importStar(require("./trace"));
@@ -83,6 +83,10 @@ message MessageRequest {
83
83
  repeated string localnets = 7;
84
84
  fonoster.routr.sipmessage.v2beta1.SIPMessage message = 8;
85
85
  map<string, string> metadata = 9;
86
+ // Version of the EdgePort that received the message (e.g. 2.18.0)
87
+ string edge_port_version = 10;
88
+ // Local socket the EdgePort received the message on
89
+ NetInterface received_on = 11;
86
90
  }
87
91
 
88
92
  message MessageResponse {
@@ -0,0 +1,37 @@
1
+ import { MessageRequest } from "../types";
2
+ import { MessageDiff, Profile, TraceRecord } from "./types";
3
+ /** File name: <origin>_<flow>_<far-end>_<YYYYMMDD>.jsonl */
4
+ export declare const CORPUS_FILE_NAME: RegExp;
5
+ export interface CorpusEntry {
6
+ file: string;
7
+ profiles: Profile[];
8
+ replay: boolean;
9
+ findings: string[];
10
+ note?: string;
11
+ }
12
+ export interface CorpusManifest {
13
+ resources: string;
14
+ files: CorpusEntry[];
15
+ }
16
+ /**
17
+ * Validates a parsed manifest (YAML or JSON) and fills the defaults.
18
+ *
19
+ * @param {unknown} input - The parsed manifest
20
+ * @return {CorpusManifest} A complete manifest
21
+ */
22
+ export declare function parseManifest(input: unknown): CorpusManifest;
23
+ export interface Drift {
24
+ seq: number;
25
+ reason: string;
26
+ diff?: MessageDiff;
27
+ }
28
+ /**
29
+ * Compares what the live chain answered with what the recording holds,
30
+ * after normalizing the values that differ between runs. Timing never
31
+ * counts.
32
+ *
33
+ * @param {TraceRecord} record - The recorded message
34
+ * @param {MessageRequest} live - What the chain returned for record.request
35
+ * @return {Drift | undefined} The drift, or undefined when they agree
36
+ */
37
+ export declare function compareLive(record: TraceRecord, live: MessageRequest): Drift | undefined;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CORPUS_FILE_NAME = void 0;
4
+ exports.parseManifest = parseManifest;
5
+ exports.compareLive = compareLive;
6
+ /*
7
+ * Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
8
+ * http://github.com/fonoster/routr
9
+ *
10
+ * This file is part of Routr.
11
+ *
12
+ * Licensed under the MIT License (the "License");
13
+ * you may not use this file except in compliance with
14
+ * the License. You may obtain a copy of the License at
15
+ *
16
+ * https://opensource.org/licenses/MIT
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ const types_1 = require("../types");
25
+ const diff_1 = require("./diff");
26
+ const normalize_1 = require("./normalize");
27
+ const status_1 = require("./status");
28
+ const types_2 = require("./types");
29
+ /*
30
+ * A known-good corpus: recordings committed to the repository and replayed
31
+ * through the live chain on every change, so a drift in what the chain
32
+ * answers to known traffic fails the build.
33
+ */
34
+ /** File name: <origin>_<flow>_<far-end>_<YYYYMMDD>.jsonl */
35
+ exports.CORPUS_FILE_NAME = /^[a-z0-9][a-z0-9-]*_[a-z0-9][a-z0-9.-]*_[a-z0-9][a-z0-9-]*_\d{8}\.jsonl$/;
36
+ /**
37
+ * Validates a parsed manifest (YAML or JSON) and fills the defaults.
38
+ *
39
+ * @param {unknown} input - The parsed manifest
40
+ * @return {CorpusManifest} A complete manifest
41
+ */
42
+ function parseManifest(input) {
43
+ const m = input;
44
+ if (!m || typeof m !== "object")
45
+ throw new Error("manifest is not an object");
46
+ if (typeof m.resources !== "string" || !m.resources) {
47
+ throw new Error("manifest needs a resources directory");
48
+ }
49
+ if (!Array.isArray(m.files))
50
+ throw new Error("manifest needs a files list");
51
+ const files = m.files.map((raw, i) => {
52
+ var _a, _b;
53
+ const e = raw;
54
+ if (!e || typeof e.file !== "string") {
55
+ throw new Error(`files[${i}] has no file name`);
56
+ }
57
+ if (!exports.CORPUS_FILE_NAME.test(e.file)) {
58
+ throw new Error(`${e.file} does not follow <origin>_<flow>_<far-end>_<YYYYMMDD>.jsonl`);
59
+ }
60
+ const profiles = Array.from(new Set([types_2.Profile.SIP, ...((_a = e.profiles) !== null && _a !== void 0 ? _a : [])]));
61
+ profiles.forEach((p) => {
62
+ if (!Object.values(types_2.Profile).includes(p)) {
63
+ throw new Error(`${e.file}: unknown profile ${p}`);
64
+ }
65
+ });
66
+ const findings = (_b = e.findings) !== null && _b !== void 0 ? _b : [];
67
+ if (!Array.isArray(findings) ||
68
+ findings.some((f) => typeof f !== "string")) {
69
+ throw new Error(`${e.file}: findings must be a list of rule ids`);
70
+ }
71
+ return Object.assign({ file: e.file, profiles, replay: e.replay !== false, findings: Array.from(new Set(findings)).sort() }, (e.note ? { note: e.note } : {}));
72
+ });
73
+ return { resources: m.resources, files };
74
+ }
75
+ const outcomeOf = (live) => {
76
+ var _a;
77
+ const isResponse = ((_a = live.message) === null || _a === void 0 ? void 0 : _a.messageType) === types_1.MessageType.RESPONSE;
78
+ const status = isResponse
79
+ ? (0, status_1.statusCodeOf)(live.message.responseType)
80
+ : undefined;
81
+ return isResponse
82
+ ? {
83
+ outcome: status !== undefined && status < 300
84
+ ? types_2.TraceOutcome.ANSWERED
85
+ : types_2.TraceOutcome.REJECTED,
86
+ status
87
+ }
88
+ : { outcome: types_2.TraceOutcome.FORWARDED };
89
+ };
90
+ /**
91
+ * Compares what the live chain answered with what the recording holds,
92
+ * after normalizing the values that differ between runs. Timing never
93
+ * counts.
94
+ *
95
+ * @param {TraceRecord} record - The recorded message
96
+ * @param {MessageRequest} live - What the chain returned for record.request
97
+ * @return {Drift | undefined} The drift, or undefined when they agree
98
+ */
99
+ function compareLive(record, live) {
100
+ var _a, _b, _c;
101
+ const recordedIsResponse = record.request.message.messageType === types_1.MessageType.RESPONSE;
102
+ if (!recordedIsResponse) {
103
+ const got = outcomeOf(live);
104
+ if (got.outcome !== record.outcome ||
105
+ ((_a = record.status) !== null && _a !== void 0 ? _a : got.status) !== got.status) {
106
+ return {
107
+ seq: record.seq,
108
+ reason: `recorded ${record.outcome}${record.status ? " " + record.status : ""}, live ${got.outcome}${got.status ? " " + got.status : ""}`
109
+ };
110
+ }
111
+ }
112
+ if (!((_b = record.response) === null || _b === void 0 ? void 0 : _b.message) || !live.message) {
113
+ return ((_c = record.response) === null || _c === void 0 ? void 0 : _c.message) || live.message
114
+ ? { seq: record.seq, reason: "one side has no outgoing message" }
115
+ : undefined;
116
+ }
117
+ const diff = (0, diff_1.diffMessages)((0, normalize_1.normalizeMessage)(record.response.message), (0, normalize_1.normalizeMessage)(live.message));
118
+ if ((0, diff_1.isEmptyDiff)(diff))
119
+ return undefined;
120
+ const changed = [
121
+ ...(diff.requestUri ? ["Request-URI"] : []),
122
+ ...Object.keys(diff.headers.changed),
123
+ ...Object.keys(diff.headers.added).map((h) => "+" + h),
124
+ ...Object.keys(diff.headers.removed).map((h) => "-" + h)
125
+ ];
126
+ return {
127
+ seq: record.seq,
128
+ reason: `outgoing message differs: ${changed.join(", ")}`,
129
+ diff
130
+ };
131
+ }