@tomgiee/tsdp 1.0.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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/src/builder/media-builder.d.ts +221 -0
- package/dist/src/builder/media-builder.d.ts.map +1 -0
- package/dist/src/builder/media-builder.js +385 -0
- package/dist/src/builder/session-builder.d.ts +195 -0
- package/dist/src/builder/session-builder.d.ts.map +1 -0
- package/dist/src/builder/session-builder.js +366 -0
- package/dist/src/index.d.ts +67 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +250 -0
- package/dist/src/parser/attribute-parser.d.ts +100 -0
- package/dist/src/parser/attribute-parser.d.ts.map +1 -0
- package/dist/src/parser/attribute-parser.js +217 -0
- package/dist/src/parser/field-parser.d.ts +124 -0
- package/dist/src/parser/field-parser.d.ts.map +1 -0
- package/dist/src/parser/field-parser.js +335 -0
- package/dist/src/parser/media-parser.d.ts +45 -0
- package/dist/src/parser/media-parser.d.ts.map +1 -0
- package/dist/src/parser/media-parser.js +157 -0
- package/dist/src/parser/primitive-parser.d.ts +138 -0
- package/dist/src/parser/primitive-parser.d.ts.map +1 -0
- package/dist/src/parser/primitive-parser.js +316 -0
- package/dist/src/parser/scanner.d.ts +142 -0
- package/dist/src/parser/scanner.d.ts.map +1 -0
- package/dist/src/parser/scanner.js +284 -0
- package/dist/src/parser/session-parser.d.ts +35 -0
- package/dist/src/parser/session-parser.d.ts.map +1 -0
- package/dist/src/parser/session-parser.js +207 -0
- package/dist/src/parser/time-parser.d.ts +74 -0
- package/dist/src/parser/time-parser.d.ts.map +1 -0
- package/dist/src/parser/time-parser.js +168 -0
- package/dist/src/serializer/attribute-serializer.d.ts +18 -0
- package/dist/src/serializer/attribute-serializer.d.ts.map +1 -0
- package/dist/src/serializer/attribute-serializer.js +34 -0
- package/dist/src/serializer/field-serializer.d.ts +112 -0
- package/dist/src/serializer/field-serializer.d.ts.map +1 -0
- package/dist/src/serializer/field-serializer.js +212 -0
- package/dist/src/serializer/media-serializer.d.ts +31 -0
- package/dist/src/serializer/media-serializer.d.ts.map +1 -0
- package/dist/src/serializer/media-serializer.js +83 -0
- package/dist/src/serializer/session-serializer.d.ts +29 -0
- package/dist/src/serializer/session-serializer.d.ts.map +1 -0
- package/dist/src/serializer/session-serializer.js +99 -0
- package/dist/src/serializer/time-serializer.d.ts +46 -0
- package/dist/src/serializer/time-serializer.d.ts.map +1 -0
- package/dist/src/serializer/time-serializer.js +86 -0
- package/dist/src/types/attributes.d.ts +318 -0
- package/dist/src/types/attributes.d.ts.map +1 -0
- package/dist/src/types/attributes.js +225 -0
- package/dist/src/types/errors.d.ts +129 -0
- package/dist/src/types/errors.d.ts.map +1 -0
- package/dist/src/types/errors.js +186 -0
- package/dist/src/types/fields.d.ts +100 -0
- package/dist/src/types/fields.d.ts.map +1 -0
- package/dist/src/types/fields.js +48 -0
- package/dist/src/types/media.d.ts +148 -0
- package/dist/src/types/media.d.ts.map +1 -0
- package/dist/src/types/media.js +137 -0
- package/dist/src/types/network.d.ts +136 -0
- package/dist/src/types/network.d.ts.map +1 -0
- package/dist/src/types/network.js +130 -0
- package/dist/src/types/primitives.d.ts +193 -0
- package/dist/src/types/primitives.d.ts.map +1 -0
- package/dist/src/types/primitives.js +195 -0
- package/dist/src/types/session.d.ts +122 -0
- package/dist/src/types/session.d.ts.map +1 -0
- package/dist/src/types/session.js +81 -0
- package/dist/src/types/time.d.ts +129 -0
- package/dist/src/types/time.d.ts.map +1 -0
- package/dist/src/types/time.js +84 -0
- package/dist/src/utils/address-parser.d.ts +100 -0
- package/dist/src/utils/address-parser.d.ts.map +1 -0
- package/dist/src/utils/address-parser.js +338 -0
- package/dist/src/utils/format-validators.d.ts +77 -0
- package/dist/src/utils/format-validators.d.ts.map +1 -0
- package/dist/src/utils/format-validators.js +504 -0
- package/dist/src/utils/line-reader.d.ts +84 -0
- package/dist/src/utils/line-reader.d.ts.map +1 -0
- package/dist/src/utils/line-reader.js +169 -0
- package/dist/src/utils/time-converter.d.ts +99 -0
- package/dist/src/utils/time-converter.d.ts.map +1 -0
- package/dist/src/utils/time-converter.js +195 -0
- package/dist/src/validator/media-validator.d.ts +27 -0
- package/dist/src/validator/media-validator.d.ts.map +1 -0
- package/dist/src/validator/media-validator.js +241 -0
- package/dist/src/validator/semantic-validator.d.ts +47 -0
- package/dist/src/validator/semantic-validator.d.ts.map +1 -0
- package/dist/src/validator/semantic-validator.js +207 -0
- package/dist/src/validator/session-validator.d.ts +36 -0
- package/dist/src/validator/session-validator.d.ts.map +1 -0
- package/dist/src/validator/session-validator.js +280 -0
- package/dist/tests/integration/round-trip.test.d.ts +5 -0
- package/dist/tests/integration/round-trip.test.d.ts.map +1 -0
- package/dist/tests/integration/round-trip.test.js +320 -0
- package/dist/tests/integration/voip-examples.test.d.ts +5 -0
- package/dist/tests/integration/voip-examples.test.d.ts.map +1 -0
- package/dist/tests/integration/voip-examples.test.js +361 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/media-builder.test.js +524 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/session-builder.test.js +367 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/attribute-parser.test.js +319 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/field-parser.test.js +355 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/media-parser.test.js +241 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/primitive-parser.test.js +261 -0
- package/dist/tests/unit/parser/scanner.test.d.ts +5 -0
- package/dist/tests/unit/parser/scanner.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/scanner.test.js +241 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/session-parser.test.js +346 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/time-parser.test.js +173 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.js +78 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/field-serializer.test.js +159 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/media-serializer.test.js +155 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/session-serializer.test.js +317 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/time-serializer.test.js +115 -0
- package/dist/tests/unit/types/errors.test.d.ts +5 -0
- package/dist/tests/unit/types/errors.test.d.ts.map +1 -0
- package/dist/tests/unit/types/errors.test.js +127 -0
- package/dist/tests/unit/types/network.test.d.ts +5 -0
- package/dist/tests/unit/types/network.test.d.ts.map +1 -0
- package/dist/tests/unit/types/network.test.js +132 -0
- package/dist/tests/unit/types/primitives.test.d.ts +5 -0
- package/dist/tests/unit/types/primitives.test.d.ts.map +1 -0
- package/dist/tests/unit/types/primitives.test.js +108 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts +5 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/address-parser.test.js +203 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts +5 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/format-validators.test.js +224 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts +5 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/line-reader.test.js +157 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts +5 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/time-converter.test.js +190 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/media-validator.test.js +313 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/semantic-validator.test.js +262 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/session-validator.test.js +447 -0
- package/package.json +50 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media description types for SDP (RFC 8866)
|
|
3
|
+
*
|
|
4
|
+
* Defines types for media descriptions including media types, ports, protocols, and formats.
|
|
5
|
+
*/
|
|
6
|
+
import { Information, Key, MediaType, Protocol, Format } from './primitives';
|
|
7
|
+
import { Connection } from './fields';
|
|
8
|
+
import { Bandwidth } from './fields';
|
|
9
|
+
import { Attribute } from './attributes';
|
|
10
|
+
/**
|
|
11
|
+
* Media Description (RFC 8866 Section 5.14)
|
|
12
|
+
*
|
|
13
|
+
* A media description consists of:
|
|
14
|
+
* - One media field (m=) [required]
|
|
15
|
+
* - Optional information field (i=)
|
|
16
|
+
* - Zero or more connection fields (c=)
|
|
17
|
+
* - Zero or more bandwidth fields (b=)
|
|
18
|
+
* - Optional encryption key field (k=) [OBSOLETE]
|
|
19
|
+
* - Zero or more attribute fields (a=)
|
|
20
|
+
*/
|
|
21
|
+
export interface MediaDescription {
|
|
22
|
+
/**
|
|
23
|
+
* Media field (required)
|
|
24
|
+
*/
|
|
25
|
+
readonly media: Media;
|
|
26
|
+
/**
|
|
27
|
+
* Media title/information (optional)
|
|
28
|
+
*/
|
|
29
|
+
readonly information?: Information;
|
|
30
|
+
/**
|
|
31
|
+
* Connection data for this media (optional if present at session level)
|
|
32
|
+
* May be multiple for hierarchical encoding schemes
|
|
33
|
+
*/
|
|
34
|
+
readonly connections: readonly Connection[];
|
|
35
|
+
/**
|
|
36
|
+
* Bandwidth information for this media (optional, multiple allowed)
|
|
37
|
+
*/
|
|
38
|
+
readonly bandwidths: readonly Bandwidth[];
|
|
39
|
+
/**
|
|
40
|
+
* Encryption key (OBSOLETE per RFC 8866, but must support for compatibility)
|
|
41
|
+
*/
|
|
42
|
+
readonly key?: Key;
|
|
43
|
+
/**
|
|
44
|
+
* Media-level attributes (optional, multiple allowed)
|
|
45
|
+
*/
|
|
46
|
+
readonly attributes: readonly Attribute[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Media field (RFC 8866 Section 5.14)
|
|
50
|
+
*
|
|
51
|
+
* Format: m=<media> <port> <proto> <fmt> ...
|
|
52
|
+
*
|
|
53
|
+
* The media field describes the type and transport address for a media stream.
|
|
54
|
+
*/
|
|
55
|
+
export interface Media {
|
|
56
|
+
/**
|
|
57
|
+
* Media type (audio, video, text, application, message, image)
|
|
58
|
+
*/
|
|
59
|
+
readonly type: MediaType;
|
|
60
|
+
/**
|
|
61
|
+
* Transport port
|
|
62
|
+
* Can be a single port or a port range
|
|
63
|
+
*/
|
|
64
|
+
readonly port: Port;
|
|
65
|
+
/**
|
|
66
|
+
* Transport protocol
|
|
67
|
+
* Examples: "RTP/AVP", "RTP/SAVP", "udp", "RTP/SAVPF"
|
|
68
|
+
*/
|
|
69
|
+
readonly proto: Protocol;
|
|
70
|
+
/**
|
|
71
|
+
* Media formats
|
|
72
|
+
* For RTP: payload type numbers
|
|
73
|
+
* For other protocols: format descriptions
|
|
74
|
+
*/
|
|
75
|
+
readonly formats: readonly Format[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Simple port - single port number
|
|
79
|
+
*/
|
|
80
|
+
export interface SimplePort {
|
|
81
|
+
readonly kind: 'simple';
|
|
82
|
+
readonly value: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Port range - base port and number of ports
|
|
86
|
+
* Format: <base>/<count>
|
|
87
|
+
* Used for hierarchical RTP sessions
|
|
88
|
+
*/
|
|
89
|
+
export interface PortRange {
|
|
90
|
+
readonly kind: 'range';
|
|
91
|
+
readonly base: number;
|
|
92
|
+
readonly count: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Port - either simple or range
|
|
96
|
+
*/
|
|
97
|
+
export type Port = SimplePort | PortRange;
|
|
98
|
+
/**
|
|
99
|
+
* Create a Media field
|
|
100
|
+
*/
|
|
101
|
+
export declare function createMedia(type: MediaType, port: Port, proto: Protocol, formats: Format[]): Media;
|
|
102
|
+
/**
|
|
103
|
+
* Create a simple port
|
|
104
|
+
*/
|
|
105
|
+
export declare function createSimplePort(value: number): SimplePort;
|
|
106
|
+
/**
|
|
107
|
+
* Create a port range
|
|
108
|
+
*/
|
|
109
|
+
export declare function createPortRange(base: number, count: number): PortRange;
|
|
110
|
+
/**
|
|
111
|
+
* Create a MediaDescription
|
|
112
|
+
*/
|
|
113
|
+
export declare function createMediaDescription(media: Media, options?: {
|
|
114
|
+
information?: Information;
|
|
115
|
+
connections?: Connection[];
|
|
116
|
+
bandwidths?: Bandwidth[];
|
|
117
|
+
key?: Key;
|
|
118
|
+
attributes?: Attribute[];
|
|
119
|
+
}): MediaDescription;
|
|
120
|
+
/**
|
|
121
|
+
* Check if port is a simple port
|
|
122
|
+
*/
|
|
123
|
+
export declare function isSimplePort(port: Port): port is SimplePort;
|
|
124
|
+
/**
|
|
125
|
+
* Check if port is a port range
|
|
126
|
+
*/
|
|
127
|
+
export declare function isPortRange(port: Port): port is PortRange;
|
|
128
|
+
/**
|
|
129
|
+
* Get the port number from a Port (simple port value or range base)
|
|
130
|
+
*
|
|
131
|
+
* This is a convenience function to extract the main port number
|
|
132
|
+
* from either a SimplePort or PortRange.
|
|
133
|
+
*
|
|
134
|
+
* @param port - The port (simple or range)
|
|
135
|
+
* @returns The port number (value for simple, base for range)
|
|
136
|
+
*/
|
|
137
|
+
export declare function getPortNumber(port: Port): number;
|
|
138
|
+
/**
|
|
139
|
+
* Get an array of all port numbers covered by a Port
|
|
140
|
+
*
|
|
141
|
+
* For a SimplePort, returns a single-element array.
|
|
142
|
+
* For a PortRange, returns all ports from base to base + count - 1.
|
|
143
|
+
*
|
|
144
|
+
* @param port - The port (simple or range)
|
|
145
|
+
* @returns Array of port numbers
|
|
146
|
+
*/
|
|
147
|
+
export declare function getPortNumbers(port: Port): number[];
|
|
148
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/types/media.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;CAC3C;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAMD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAM1C;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EAAE,GAChB,KAAK,CAUP;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAQ1D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAetE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B,GACA,gBAAgB,CASlB;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,UAAU,CAE3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,SAAS,CAEzD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAWhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,CAWnD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Media description types for SDP (RFC 8866)
|
|
4
|
+
*
|
|
5
|
+
* Defines types for media descriptions including media types, ports, protocols, and formats.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createMedia = createMedia;
|
|
9
|
+
exports.createSimplePort = createSimplePort;
|
|
10
|
+
exports.createPortRange = createPortRange;
|
|
11
|
+
exports.createMediaDescription = createMediaDescription;
|
|
12
|
+
exports.isSimplePort = isSimplePort;
|
|
13
|
+
exports.isPortRange = isPortRange;
|
|
14
|
+
exports.getPortNumber = getPortNumber;
|
|
15
|
+
exports.getPortNumbers = getPortNumbers;
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Helper Functions for Creating Media Types
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Create a Media field
|
|
21
|
+
*/
|
|
22
|
+
function createMedia(type, port, proto, formats) {
|
|
23
|
+
if (formats.length === 0) {
|
|
24
|
+
throw new Error('At least one format is required');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
type,
|
|
28
|
+
port,
|
|
29
|
+
proto,
|
|
30
|
+
formats,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a simple port
|
|
35
|
+
*/
|
|
36
|
+
function createSimplePort(value) {
|
|
37
|
+
if (value < 0 || value > 65535) {
|
|
38
|
+
throw new Error('Port must be between 0 and 65535');
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
kind: 'simple',
|
|
42
|
+
value,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a port range
|
|
47
|
+
*/
|
|
48
|
+
function createPortRange(base, count) {
|
|
49
|
+
if (base < 0 || base > 65535) {
|
|
50
|
+
throw new Error('Base port must be between 0 and 65535');
|
|
51
|
+
}
|
|
52
|
+
if (count < 1) {
|
|
53
|
+
throw new Error('Port count must be at least 1');
|
|
54
|
+
}
|
|
55
|
+
if (base + count > 65536) {
|
|
56
|
+
throw new Error('Port range exceeds maximum port number');
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kind: 'range',
|
|
60
|
+
base,
|
|
61
|
+
count,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a MediaDescription
|
|
66
|
+
*/
|
|
67
|
+
function createMediaDescription(media, options) {
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
return {
|
|
70
|
+
media,
|
|
71
|
+
information: options === null || options === void 0 ? void 0 : options.information,
|
|
72
|
+
connections: (_a = options === null || options === void 0 ? void 0 : options.connections) !== null && _a !== void 0 ? _a : [],
|
|
73
|
+
bandwidths: (_b = options === null || options === void 0 ? void 0 : options.bandwidths) !== null && _b !== void 0 ? _b : [],
|
|
74
|
+
key: options === null || options === void 0 ? void 0 : options.key,
|
|
75
|
+
attributes: (_c = options === null || options === void 0 ? void 0 : options.attributes) !== null && _c !== void 0 ? _c : [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Type Guards
|
|
80
|
+
// ============================================================================
|
|
81
|
+
/**
|
|
82
|
+
* Check if port is a simple port
|
|
83
|
+
*/
|
|
84
|
+
function isSimplePort(port) {
|
|
85
|
+
return port.kind === 'simple';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if port is a port range
|
|
89
|
+
*/
|
|
90
|
+
function isPortRange(port) {
|
|
91
|
+
return port.kind === 'range';
|
|
92
|
+
}
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Port Utility Functions
|
|
95
|
+
// ============================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Get the port number from a Port (simple port value or range base)
|
|
98
|
+
*
|
|
99
|
+
* This is a convenience function to extract the main port number
|
|
100
|
+
* from either a SimplePort or PortRange.
|
|
101
|
+
*
|
|
102
|
+
* @param port - The port (simple or range)
|
|
103
|
+
* @returns The port number (value for simple, base for range)
|
|
104
|
+
*/
|
|
105
|
+
function getPortNumber(port) {
|
|
106
|
+
switch (port.kind) {
|
|
107
|
+
case 'simple':
|
|
108
|
+
return port.value;
|
|
109
|
+
case 'range':
|
|
110
|
+
return port.base;
|
|
111
|
+
default: {
|
|
112
|
+
const _exhaustive = port;
|
|
113
|
+
return _exhaustive;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get an array of all port numbers covered by a Port
|
|
119
|
+
*
|
|
120
|
+
* For a SimplePort, returns a single-element array.
|
|
121
|
+
* For a PortRange, returns all ports from base to base + count - 1.
|
|
122
|
+
*
|
|
123
|
+
* @param port - The port (simple or range)
|
|
124
|
+
* @returns Array of port numbers
|
|
125
|
+
*/
|
|
126
|
+
function getPortNumbers(port) {
|
|
127
|
+
switch (port.kind) {
|
|
128
|
+
case 'simple':
|
|
129
|
+
return [port.value];
|
|
130
|
+
case 'range':
|
|
131
|
+
return Array.from({ length: port.count }, (_, i) => port.base + i);
|
|
132
|
+
default: {
|
|
133
|
+
const _exhaustive = port;
|
|
134
|
+
return _exhaustive;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network address types for SDP (RFC 8866)
|
|
3
|
+
*
|
|
4
|
+
* This module defines types for IP4/IP6 addresses, FQDNs, and multicast addresses.
|
|
5
|
+
* Uses branded types to prevent mixing incompatible address types at compile time.
|
|
6
|
+
*/
|
|
7
|
+
type Brand<T, B> = T & {
|
|
8
|
+
readonly __brand: B;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* IPv4 address (dotted decimal: a.b.c.d)
|
|
12
|
+
* Each octet is 0-255
|
|
13
|
+
* Examples: "192.168.1.1", "198.51.100.1"
|
|
14
|
+
*/
|
|
15
|
+
export type IP4Address = Brand<string, 'IP4Address'>;
|
|
16
|
+
/**
|
|
17
|
+
* IPv6 address (RFC 5952 canonical format)
|
|
18
|
+
* Supports all 8 compression forms
|
|
19
|
+
* Examples: "2001:db8::1", "fe80::1", "::1"
|
|
20
|
+
*/
|
|
21
|
+
export type IP6Address = Brand<string, 'IP6Address'>;
|
|
22
|
+
/**
|
|
23
|
+
* Fully Qualified Domain Name
|
|
24
|
+
* RFC 1035 compliant domain name
|
|
25
|
+
* Examples: "example.com", "sip.example.org"
|
|
26
|
+
*/
|
|
27
|
+
export type FQDN = Brand<string, 'FQDN'>;
|
|
28
|
+
/**
|
|
29
|
+
* Extension address type (for future/custom address types)
|
|
30
|
+
* Used when addrtype is not IP4 or IP6
|
|
31
|
+
*/
|
|
32
|
+
export type ExtensionAddress = Brand<string, 'ExtensionAddress'>;
|
|
33
|
+
/**
|
|
34
|
+
* Unicast address - can be IPv4, IPv6, FQDN, or extension
|
|
35
|
+
* Used for origin field and unicast connection addresses
|
|
36
|
+
*/
|
|
37
|
+
export type UnicastAddress = IP4Address | IP6Address | FQDN | ExtensionAddress;
|
|
38
|
+
/**
|
|
39
|
+
* IPv4 multicast address (224.0.0.0 - 239.255.255.255)
|
|
40
|
+
* Requires TTL, optionally includes number of addresses for hierarchical encoding
|
|
41
|
+
*/
|
|
42
|
+
export interface IP4MulticastAddress {
|
|
43
|
+
readonly kind: 'ip4-multicast';
|
|
44
|
+
readonly address: IP4Address;
|
|
45
|
+
/** Time-to-live (0-255), required for IPv4 multicast */
|
|
46
|
+
readonly ttl: number;
|
|
47
|
+
/** Number of addresses for hierarchical encoding (optional) */
|
|
48
|
+
readonly numAddresses?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* IPv6 multicast address (starts with FF)
|
|
52
|
+
* Does NOT include TTL (forbidden for IPv6)
|
|
53
|
+
* Optionally includes number of addresses for hierarchical encoding
|
|
54
|
+
*/
|
|
55
|
+
export interface IP6MulticastAddress {
|
|
56
|
+
readonly kind: 'ip6-multicast';
|
|
57
|
+
readonly address: IP6Address;
|
|
58
|
+
/** Number of addresses for hierarchical encoding (optional) */
|
|
59
|
+
readonly numAddresses?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* FQDN multicast address
|
|
63
|
+
* Domain name that resolves to a multicast address
|
|
64
|
+
* May include TTL and number of addresses
|
|
65
|
+
*/
|
|
66
|
+
export interface FQDNMulticastAddress {
|
|
67
|
+
readonly kind: 'fqdn-multicast';
|
|
68
|
+
readonly address: FQDN;
|
|
69
|
+
/** Time-to-live (optional for FQDN) */
|
|
70
|
+
readonly ttl?: number;
|
|
71
|
+
/** Number of addresses for hierarchical encoding (optional) */
|
|
72
|
+
readonly numAddresses?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Multicast address - IPv4, IPv6, or FQDN based
|
|
76
|
+
* Discriminated union for type-safe handling
|
|
77
|
+
*/
|
|
78
|
+
export type MulticastAddress = IP4MulticastAddress | IP6MulticastAddress | FQDNMulticastAddress;
|
|
79
|
+
/**
|
|
80
|
+
* Connection address - can be unicast or multicast
|
|
81
|
+
* Used in connection field (c=)
|
|
82
|
+
*/
|
|
83
|
+
export type ConnectionAddress = UnicastAddress | MulticastAddress;
|
|
84
|
+
/**
|
|
85
|
+
* Create an IP4Address from a string
|
|
86
|
+
* Note: Validation should be done by address-parser utility
|
|
87
|
+
*/
|
|
88
|
+
export declare function createIP4Address(value: string): IP4Address;
|
|
89
|
+
/**
|
|
90
|
+
* Create an IP6Address from a string
|
|
91
|
+
* Note: Validation should be done by address-parser utility
|
|
92
|
+
*/
|
|
93
|
+
export declare function createIP6Address(value: string): IP6Address;
|
|
94
|
+
/**
|
|
95
|
+
* Create an FQDN from a string
|
|
96
|
+
* Note: Validation should be done by address-parser utility
|
|
97
|
+
*/
|
|
98
|
+
export declare function createFQDN(value: string): FQDN;
|
|
99
|
+
/**
|
|
100
|
+
* Create an ExtensionAddress from a string
|
|
101
|
+
*/
|
|
102
|
+
export declare function createExtensionAddress(value: string): ExtensionAddress;
|
|
103
|
+
/**
|
|
104
|
+
* Create an IPv4 multicast address
|
|
105
|
+
*/
|
|
106
|
+
export declare function createIP4MulticastAddress(address: IP4Address, ttl: number, numAddresses?: number): IP4MulticastAddress;
|
|
107
|
+
/**
|
|
108
|
+
* Create an IPv6 multicast address
|
|
109
|
+
*/
|
|
110
|
+
export declare function createIP6MulticastAddress(address: IP6Address, numAddresses?: number): IP6MulticastAddress;
|
|
111
|
+
/**
|
|
112
|
+
* Create an FQDN multicast address
|
|
113
|
+
*/
|
|
114
|
+
export declare function createFQDNMulticastAddress(address: FQDN, ttl?: number, numAddresses?: number): FQDNMulticastAddress;
|
|
115
|
+
/**
|
|
116
|
+
* Check if an address is a multicast address
|
|
117
|
+
*/
|
|
118
|
+
export declare function isMulticastAddress(addr: ConnectionAddress): addr is MulticastAddress;
|
|
119
|
+
/**
|
|
120
|
+
* Check if an address is a unicast address
|
|
121
|
+
*/
|
|
122
|
+
export declare function isUnicastAddress(addr: ConnectionAddress): addr is UnicastAddress;
|
|
123
|
+
/**
|
|
124
|
+
* Check if a multicast address is IPv4
|
|
125
|
+
*/
|
|
126
|
+
export declare function isIP4MulticastAddress(addr: MulticastAddress): addr is IP4MulticastAddress;
|
|
127
|
+
/**
|
|
128
|
+
* Check if a multicast address is IPv6
|
|
129
|
+
*/
|
|
130
|
+
export declare function isIP6MulticastAddress(addr: MulticastAddress): addr is IP6MulticastAddress;
|
|
131
|
+
/**
|
|
132
|
+
* Check if a multicast address is FQDN-based
|
|
133
|
+
*/
|
|
134
|
+
export declare function isFQDNMulticastAddress(addr: MulticastAddress): addr is FQDNMulticastAddress;
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/types/network.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network address types for SDP (RFC 8866)
|
|
4
|
+
*
|
|
5
|
+
* This module defines types for IP4/IP6 addresses, FQDNs, and multicast addresses.
|
|
6
|
+
* Uses branded types to prevent mixing incompatible address types at compile time.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createIP4Address = createIP4Address;
|
|
10
|
+
exports.createIP6Address = createIP6Address;
|
|
11
|
+
exports.createFQDN = createFQDN;
|
|
12
|
+
exports.createExtensionAddress = createExtensionAddress;
|
|
13
|
+
exports.createIP4MulticastAddress = createIP4MulticastAddress;
|
|
14
|
+
exports.createIP6MulticastAddress = createIP6MulticastAddress;
|
|
15
|
+
exports.createFQDNMulticastAddress = createFQDNMulticastAddress;
|
|
16
|
+
exports.isMulticastAddress = isMulticastAddress;
|
|
17
|
+
exports.isUnicastAddress = isUnicastAddress;
|
|
18
|
+
exports.isIP4MulticastAddress = isIP4MulticastAddress;
|
|
19
|
+
exports.isIP6MulticastAddress = isIP6MulticastAddress;
|
|
20
|
+
exports.isFQDNMulticastAddress = isFQDNMulticastAddress;
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Helper Functions for Creating Network Types
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Create an IP4Address from a string
|
|
26
|
+
* Note: Validation should be done by address-parser utility
|
|
27
|
+
*/
|
|
28
|
+
function createIP4Address(value) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create an IP6Address from a string
|
|
33
|
+
* Note: Validation should be done by address-parser utility
|
|
34
|
+
*/
|
|
35
|
+
function createIP6Address(value) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create an FQDN from a string
|
|
40
|
+
* Note: Validation should be done by address-parser utility
|
|
41
|
+
*/
|
|
42
|
+
function createFQDN(value) {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create an ExtensionAddress from a string
|
|
47
|
+
*/
|
|
48
|
+
function createExtensionAddress(value) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create an IPv4 multicast address
|
|
53
|
+
*/
|
|
54
|
+
function createIP4MulticastAddress(address, ttl, numAddresses) {
|
|
55
|
+
if (ttl < 0 || ttl > 255) {
|
|
56
|
+
throw new Error(`Invalid TTL: ${ttl}. Must be 0-255`);
|
|
57
|
+
}
|
|
58
|
+
if (numAddresses !== undefined && numAddresses < 1) {
|
|
59
|
+
throw new Error(`Invalid numAddresses: ${numAddresses}. Must be >= 1`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
kind: 'ip4-multicast',
|
|
63
|
+
address,
|
|
64
|
+
ttl,
|
|
65
|
+
numAddresses
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create an IPv6 multicast address
|
|
70
|
+
*/
|
|
71
|
+
function createIP6MulticastAddress(address, numAddresses) {
|
|
72
|
+
if (numAddresses !== undefined && numAddresses < 1) {
|
|
73
|
+
throw new Error(`Invalid numAddresses: ${numAddresses}. Must be >= 1`);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
kind: 'ip6-multicast',
|
|
77
|
+
address,
|
|
78
|
+
numAddresses
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create an FQDN multicast address
|
|
83
|
+
*/
|
|
84
|
+
function createFQDNMulticastAddress(address, ttl, numAddresses) {
|
|
85
|
+
if (ttl !== undefined && (ttl < 0 || ttl > 255)) {
|
|
86
|
+
throw new Error(`Invalid TTL: ${ttl}. Must be 0-255`);
|
|
87
|
+
}
|
|
88
|
+
if (numAddresses !== undefined && numAddresses < 1) {
|
|
89
|
+
throw new Error(`Invalid numAddresses: ${numAddresses}. Must be >= 1`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
kind: 'fqdn-multicast',
|
|
93
|
+
address,
|
|
94
|
+
ttl,
|
|
95
|
+
numAddresses
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Type Guards
|
|
100
|
+
// ============================================================================
|
|
101
|
+
/**
|
|
102
|
+
* Check if an address is a multicast address
|
|
103
|
+
*/
|
|
104
|
+
function isMulticastAddress(addr) {
|
|
105
|
+
return typeof addr === 'object' && 'kind' in addr;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if an address is a unicast address
|
|
109
|
+
*/
|
|
110
|
+
function isUnicastAddress(addr) {
|
|
111
|
+
return typeof addr === 'string';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if a multicast address is IPv4
|
|
115
|
+
*/
|
|
116
|
+
function isIP4MulticastAddress(addr) {
|
|
117
|
+
return addr.kind === 'ip4-multicast';
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if a multicast address is IPv6
|
|
121
|
+
*/
|
|
122
|
+
function isIP6MulticastAddress(addr) {
|
|
123
|
+
return addr.kind === 'ip6-multicast';
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Check if a multicast address is FQDN-based
|
|
127
|
+
*/
|
|
128
|
+
function isFQDNMulticastAddress(addr) {
|
|
129
|
+
return addr.kind === 'fqdn-multicast';
|
|
130
|
+
}
|