@tomgiee/tsdp 1.0.1 → 1.1.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/README.md +0 -39
- package/dist/src/builder/media-builder.d.ts.map +1 -1
- package/dist/src/builder/media-builder.js +5 -12
- package/dist/src/builder/session-builder.d.ts.map +1 -1
- package/dist/src/builder/session-builder.js +4 -14
- package/dist/src/index.d.ts +6 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +37 -49
- package/dist/src/parser/core.d.ts +366 -0
- package/dist/src/parser/core.d.ts.map +1 -0
- package/dist/src/parser/core.js +802 -0
- package/dist/src/parser/field-parser.d.ts +51 -8
- package/dist/src/parser/field-parser.d.ts.map +1 -1
- package/dist/src/parser/field-parser.js +91 -23
- package/dist/src/parser/media-parser.d.ts +1 -1
- package/dist/src/parser/media-parser.d.ts.map +1 -1
- package/dist/src/parser/media-parser.js +9 -15
- package/dist/src/parser/session-parser.d.ts.map +1 -1
- package/dist/src/parser/session-parser.js +16 -17
- package/dist/src/parser/time-parser.d.ts +1 -1
- package/dist/src/parser/time-parser.d.ts.map +1 -1
- package/dist/src/parser/time-parser.js +8 -8
- package/dist/src/serializer/fields.d.ts +167 -0
- package/dist/src/serializer/fields.d.ts.map +1 -0
- package/dist/src/serializer/fields.js +320 -0
- package/dist/src/serializer/media-serializer.js +6 -7
- package/dist/src/serializer/session-serializer.js +13 -15
- package/dist/src/types/attributes.d.ts.map +1 -1
- package/dist/src/types/fields.d.ts +5 -5
- package/dist/src/types/fields.d.ts.map +1 -1
- package/dist/src/types/fields.js +4 -4
- package/dist/src/types/media.d.ts +9 -10
- package/dist/src/types/media.d.ts.map +1 -1
- package/dist/src/types/media.js +2 -4
- package/dist/src/types/network.d.ts +15 -56
- package/dist/src/types/network.d.ts.map +1 -1
- package/dist/src/types/network.js +3 -34
- package/dist/src/types/primitives.d.ts +3 -147
- package/dist/src/types/primitives.d.ts.map +1 -1
- package/dist/src/types/primitives.js +2 -171
- package/dist/src/types/session.d.ts +14 -14
- package/dist/src/types/session.d.ts.map +1 -1
- package/dist/src/types/time.d.ts +4 -4
- package/dist/src/types/time.d.ts.map +1 -1
- package/dist/src/types/time.js +8 -6
- package/dist/src/utils/address-parser.d.ts +4 -4
- package/dist/src/utils/address-parser.d.ts.map +1 -1
- package/dist/src/utils/address-parser.js +9 -16
- package/dist/src/validator/validator.d.ts +94 -0
- package/dist/src/validator/validator.d.ts.map +1 -0
- package/dist/src/validator/validator.js +573 -0
- package/dist/tests/unit/parser/attribute-parser.test.js +106 -107
- package/dist/tests/unit/parser/field-parser.test.js +66 -66
- package/dist/tests/unit/parser/media-parser.test.js +38 -38
- package/dist/tests/unit/parser/primitive-parser.test.js +89 -90
- package/dist/tests/unit/parser/scanner.test.js +32 -32
- package/dist/tests/unit/parser/time-parser.test.js +22 -22
- package/dist/tests/unit/serializer/attribute-serializer.test.js +22 -22
- package/dist/tests/unit/serializer/field-serializer.test.js +57 -57
- package/dist/tests/unit/serializer/media-serializer.test.js +5 -6
- package/dist/tests/unit/serializer/session-serializer.test.js +24 -24
- package/dist/tests/unit/serializer/time-serializer.test.js +16 -16
- package/dist/tests/unit/types/network.test.js +21 -56
- package/dist/tests/unit/types/primitives.test.js +0 -39
- package/dist/tests/unit/validator/media-validator.test.js +34 -35
- package/dist/tests/unit/validator/semantic-validator.test.js +36 -37
- package/dist/tests/unit/validator/session-validator.test.js +54 -54
- package/package.json +1 -1
|
@@ -1,194 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Primitive types
|
|
4
|
-
*
|
|
5
|
-
* This module defines branded primitive types to ensure type safety at compile time
|
|
6
|
-
* and enums for various SDP field values.
|
|
3
|
+
* Primitive types for SDP (RFC 8866)
|
|
7
4
|
*/
|
|
8
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
6
|
exports.isNumericString = isNumericString;
|
|
10
|
-
exports.createVersion = createVersion;
|
|
11
|
-
exports.createSessionName = createSessionName;
|
|
12
|
-
exports.createUsername = createUsername;
|
|
13
|
-
exports.createSessionId = createSessionId;
|
|
14
|
-
exports.createSessionVersion = createSessionVersion;
|
|
15
|
-
exports.createInformation = createInformation;
|
|
16
|
-
exports.createURI = createURI;
|
|
17
|
-
exports.createEmail = createEmail;
|
|
18
|
-
exports.createPhone = createPhone;
|
|
19
|
-
exports.createKey = createKey;
|
|
20
|
-
exports.createBandwidthType = createBandwidthType;
|
|
21
|
-
exports.createMediaType = createMediaType;
|
|
22
|
-
exports.createProtocol = createProtocol;
|
|
23
|
-
exports.createFormat = createFormat;
|
|
24
|
-
exports.createAttributeName = createAttributeName;
|
|
25
|
-
exports.createAttributeValue = createAttributeValue;
|
|
26
|
-
exports.createToken = createToken;
|
|
27
|
-
exports.createByteString = createByteString;
|
|
28
|
-
exports.createNonWSString = createNonWSString;
|
|
29
|
-
exports.createNtpTime = createNtpTime;
|
|
30
7
|
exports.createTypedTime = createTypedTime;
|
|
31
8
|
// ============================================================================
|
|
32
9
|
// Validation Helpers
|
|
33
10
|
// ============================================================================
|
|
34
|
-
/**
|
|
35
|
-
* Regular expression for numeric strings per RFC 8866 grammar
|
|
36
|
-
* sess-id = 1*DIGIT
|
|
37
|
-
* sess-version = 1*DIGIT
|
|
38
|
-
*/
|
|
39
11
|
const NUMERIC_STRING_REGEX = /^[0-9]+$/;
|
|
40
12
|
/**
|
|
41
13
|
* Check if a string contains only digits (0-9)
|
|
42
|
-
*
|
|
43
|
-
* Per RFC 8866 Section 9 (Grammar):
|
|
44
|
-
* - sess-id = 1*DIGIT
|
|
45
|
-
* - sess-version = 1*DIGIT
|
|
46
|
-
*
|
|
47
|
-
* @param value - String to validate
|
|
48
|
-
* @returns true if string contains one or more digits only
|
|
49
14
|
*/
|
|
50
15
|
function isNumericString(value) {
|
|
51
16
|
return value.length > 0 && NUMERIC_STRING_REGEX.test(value);
|
|
52
17
|
}
|
|
53
18
|
// ============================================================================
|
|
54
|
-
// Helper Functions
|
|
19
|
+
// Helper Functions
|
|
55
20
|
// ============================================================================
|
|
56
|
-
/**
|
|
57
|
-
* Create a Version (currently must be 0)
|
|
58
|
-
*/
|
|
59
|
-
function createVersion(value) {
|
|
60
|
-
if (value !== 0) {
|
|
61
|
-
throw new Error(`Invalid SDP version: ${value}. Currently only version 0 is defined.`);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create a SessionName from a string
|
|
67
|
-
*/
|
|
68
|
-
function createSessionName(value) {
|
|
69
|
-
if (value.length === 0) {
|
|
70
|
-
throw new Error('Session name cannot be empty');
|
|
71
|
-
}
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Create a Username from a string
|
|
76
|
-
*/
|
|
77
|
-
function createUsername(value) {
|
|
78
|
-
if (value.length === 0) {
|
|
79
|
-
throw new Error('Username cannot be empty');
|
|
80
|
-
}
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Create a SessionId from a string
|
|
85
|
-
*/
|
|
86
|
-
function createSessionId(value) {
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Create a SessionVersion from a string
|
|
91
|
-
*/
|
|
92
|
-
function createSessionVersion(value) {
|
|
93
|
-
return value;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Create an Information string
|
|
97
|
-
*/
|
|
98
|
-
function createInformation(value) {
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create a URI
|
|
103
|
-
*/
|
|
104
|
-
function createURI(value) {
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Create an Email
|
|
109
|
-
*/
|
|
110
|
-
function createEmail(value) {
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Create a Phone
|
|
115
|
-
*/
|
|
116
|
-
function createPhone(value) {
|
|
117
|
-
return value;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Create a Key (OBSOLETE but must support for compatibility)
|
|
121
|
-
*/
|
|
122
|
-
function createKey(value) {
|
|
123
|
-
return value;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Create a BandwidthType
|
|
127
|
-
*/
|
|
128
|
-
function createBandwidthType(value) {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Create a MediaType
|
|
133
|
-
*/
|
|
134
|
-
function createMediaType(value) {
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Create a Protocol
|
|
139
|
-
*/
|
|
140
|
-
function createProtocol(value) {
|
|
141
|
-
return value;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Create a Format
|
|
145
|
-
*/
|
|
146
|
-
function createFormat(value) {
|
|
147
|
-
return value;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Create an AttributeName
|
|
151
|
-
*/
|
|
152
|
-
function createAttributeName(value) {
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create an AttributeValue
|
|
157
|
-
*/
|
|
158
|
-
function createAttributeValue(value) {
|
|
159
|
-
return value;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Create a Token
|
|
163
|
-
*/
|
|
164
|
-
function createToken(value) {
|
|
165
|
-
return value;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Create a ByteString
|
|
169
|
-
*/
|
|
170
|
-
function createByteString(value) {
|
|
171
|
-
return value;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Create a NonWSString
|
|
175
|
-
*/
|
|
176
|
-
function createNonWSString(value) {
|
|
177
|
-
return value;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Create an NtpTime
|
|
181
|
-
*/
|
|
182
|
-
function createNtpTime(value) {
|
|
183
|
-
if (value < 0) {
|
|
184
|
-
throw new Error('NTP time cannot be negative');
|
|
185
|
-
}
|
|
186
|
-
return value;
|
|
187
|
-
}
|
|
188
21
|
/**
|
|
189
22
|
* Create a TypedTime
|
|
190
|
-
*
|
|
191
|
-
* Note: Value can be negative for timezone offsets
|
|
192
23
|
*/
|
|
193
24
|
function createTypedTime(value, unit) {
|
|
194
25
|
return { value, unit };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This is the main type representing a complete SDP session description.
|
|
5
5
|
*/
|
|
6
|
-
import { Version
|
|
6
|
+
import { Version } from './primitives';
|
|
7
7
|
import { Origin, Connection, Bandwidth } from './fields';
|
|
8
8
|
import { TimeDescription } from './time';
|
|
9
9
|
import { Attribute } from './attributes';
|
|
@@ -42,23 +42,23 @@ export interface SessionDescription {
|
|
|
42
42
|
/**
|
|
43
43
|
* Session name (required, use " " if no meaningful name)
|
|
44
44
|
*/
|
|
45
|
-
readonly sessionName:
|
|
45
|
+
readonly sessionName: string;
|
|
46
46
|
/**
|
|
47
47
|
* Session information/title (optional)
|
|
48
48
|
*/
|
|
49
|
-
readonly sessionInformation?:
|
|
49
|
+
readonly sessionInformation?: string;
|
|
50
50
|
/**
|
|
51
51
|
* URI for more information about the session (optional)
|
|
52
52
|
*/
|
|
53
|
-
readonly uri?:
|
|
53
|
+
readonly uri?: string;
|
|
54
54
|
/**
|
|
55
55
|
* Email addresses for contact (optional, multiple allowed)
|
|
56
56
|
*/
|
|
57
|
-
readonly emails: readonly
|
|
57
|
+
readonly emails: readonly string[];
|
|
58
58
|
/**
|
|
59
59
|
* Phone numbers for contact (optional, multiple allowed)
|
|
60
60
|
*/
|
|
61
|
-
readonly phones: readonly
|
|
61
|
+
readonly phones: readonly string[];
|
|
62
62
|
/**
|
|
63
63
|
* Connection information for the session (optional if present in all media)
|
|
64
64
|
* If omitted, each media description MUST have connection information
|
|
@@ -76,7 +76,7 @@ export interface SessionDescription {
|
|
|
76
76
|
/**
|
|
77
77
|
* Encryption key (OBSOLETE per RFC 8866, but must support for compatibility)
|
|
78
78
|
*/
|
|
79
|
-
readonly key?:
|
|
79
|
+
readonly key?: string;
|
|
80
80
|
/**
|
|
81
81
|
* Session-level attributes (optional, multiple allowed)
|
|
82
82
|
*/
|
|
@@ -97,15 +97,15 @@ export interface SessionDescription {
|
|
|
97
97
|
export declare function createSessionDescription(options: {
|
|
98
98
|
version: Version;
|
|
99
99
|
origin: Origin;
|
|
100
|
-
sessionName:
|
|
101
|
-
sessionInformation?:
|
|
102
|
-
uri?:
|
|
103
|
-
emails?:
|
|
104
|
-
phones?:
|
|
100
|
+
sessionName: string;
|
|
101
|
+
sessionInformation?: string;
|
|
102
|
+
uri?: string;
|
|
103
|
+
emails?: string[];
|
|
104
|
+
phones?: string[];
|
|
105
105
|
connection?: Connection;
|
|
106
106
|
bandwidths?: Bandwidth[];
|
|
107
107
|
timeDescriptions: TimeDescription[];
|
|
108
|
-
key?:
|
|
108
|
+
key?: string;
|
|
109
109
|
attributes?: Attribute[];
|
|
110
110
|
mediaDescriptions?: MediaDescription[];
|
|
111
111
|
}): SessionDescription;
|
|
@@ -118,5 +118,5 @@ export declare function createSessionDescription(options: {
|
|
|
118
118
|
* - Session name
|
|
119
119
|
* - One time description (0 to 0 = permanent/unbounded)
|
|
120
120
|
*/
|
|
121
|
-
export declare function createMinimalSessionDescription(origin: Origin, sessionName:
|
|
121
|
+
export declare function createMinimalSessionDescription(origin: Origin, sessionName: string): SessionDescription;
|
|
122
122
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/types/session.ts"],"names":[],"mappings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AwB,CAAC,OAAO,EAAE;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACxC,GAAG,kBAAkB,CAqCrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAoBpB"}
|
package/dist/src/types/time.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Defines types for timing, repeat times, and timezone adjustments.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { TypedTime } from './primitives';
|
|
7
7
|
/**
|
|
8
8
|
* Time Description (RFC 8866 Section 5.9-5.11)
|
|
9
9
|
*
|
|
@@ -42,12 +42,12 @@ export interface Timing {
|
|
|
42
42
|
* Start time of the session (NTP timestamp)
|
|
43
43
|
* 0 means the session is not bounded
|
|
44
44
|
*/
|
|
45
|
-
readonly startTime:
|
|
45
|
+
readonly startTime: number;
|
|
46
46
|
/**
|
|
47
47
|
* Stop time of the session (NTP timestamp)
|
|
48
48
|
* 0 means the session is not bounded
|
|
49
49
|
*/
|
|
50
|
-
readonly stopTime:
|
|
50
|
+
readonly stopTime: number;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Repeat field (RFC 8866 Section 5.10)
|
|
@@ -95,7 +95,7 @@ export interface TimezoneAdjustment {
|
|
|
95
95
|
/**
|
|
96
96
|
* Time at which the adjustment takes effect (NTP timestamp)
|
|
97
97
|
*/
|
|
98
|
-
readonly time:
|
|
98
|
+
readonly time: number;
|
|
99
99
|
/**
|
|
100
100
|
* Offset to apply at the adjustment time
|
|
101
101
|
* Positive for forward adjustment, negative for backward
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/types/time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/types/time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAMD;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;CACxC;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAK9C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,SAAS,EAAE,GACnB,MAAM,CASR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,kBAAkB,CAQ5F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAO1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,MAAM,EAAO,EACtB,QAAQ,CAAC,EAAE,QAAQ,GAClB,eAAe,CAMjB"}
|
package/dist/src/types/time.js
CHANGED
|
@@ -11,7 +11,6 @@ exports.createRepeat = createRepeat;
|
|
|
11
11
|
exports.createTimezoneAdjustment = createTimezoneAdjustment;
|
|
12
12
|
exports.createTimezone = createTimezone;
|
|
13
13
|
exports.createTimeDescription = createTimeDescription;
|
|
14
|
-
const primitives_1 = require("./primitives");
|
|
15
14
|
// ============================================================================
|
|
16
15
|
// Helper Functions for Creating Time Types
|
|
17
16
|
// ============================================================================
|
|
@@ -26,8 +25,8 @@ function createTiming(startTime, stopTime) {
|
|
|
26
25
|
throw new Error('Start time must be before or equal to stop time');
|
|
27
26
|
}
|
|
28
27
|
return {
|
|
29
|
-
startTime
|
|
30
|
-
stopTime
|
|
28
|
+
startTime,
|
|
29
|
+
stopTime,
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
@@ -35,8 +34,8 @@ function createTiming(startTime, stopTime) {
|
|
|
35
34
|
*/
|
|
36
35
|
function createPermanentTiming() {
|
|
37
36
|
return {
|
|
38
|
-
startTime:
|
|
39
|
-
stopTime:
|
|
37
|
+
startTime: 0,
|
|
38
|
+
stopTime: 0,
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
@@ -56,8 +55,11 @@ function createRepeat(interval, duration, offsets) {
|
|
|
56
55
|
* Create a TimezoneAdjustment
|
|
57
56
|
*/
|
|
58
57
|
function createTimezoneAdjustment(time, offset) {
|
|
58
|
+
if (time < 0) {
|
|
59
|
+
throw new Error('NTP time must be non-negative');
|
|
60
|
+
}
|
|
59
61
|
return {
|
|
60
|
-
time
|
|
62
|
+
time,
|
|
61
63
|
offset,
|
|
62
64
|
};
|
|
63
65
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Handles IPv4, IPv6 (RFC 5952), and FQDN (RFC 1035) address formats
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { UnicastAddress } from '../types/network';
|
|
7
7
|
import { AddrType } from '../types/primitives';
|
|
8
8
|
/**
|
|
9
9
|
* Check if a string is a valid IPv4 address
|
|
@@ -28,7 +28,7 @@ export declare function isIP4MulticastAddress(input: string): boolean;
|
|
|
28
28
|
* @returns IP4Address
|
|
29
29
|
* @throws ParseError if invalid
|
|
30
30
|
*/
|
|
31
|
-
export declare function parseIP4Address(input: string):
|
|
31
|
+
export declare function parseIP4Address(input: string): string;
|
|
32
32
|
/**
|
|
33
33
|
* Check if a string is a valid IPv6 address (RFC 5952)
|
|
34
34
|
*
|
|
@@ -55,7 +55,7 @@ export declare function isIP6MulticastAddress(input: string): boolean;
|
|
|
55
55
|
* @returns IP6Address
|
|
56
56
|
* @throws ParseError if invalid
|
|
57
57
|
*/
|
|
58
|
-
export declare function parseIP6Address(input: string):
|
|
58
|
+
export declare function parseIP6Address(input: string): string;
|
|
59
59
|
/**
|
|
60
60
|
* Check if a string is a valid FQDN (RFC 1035)
|
|
61
61
|
*
|
|
@@ -76,7 +76,7 @@ export declare function isFQDN(input: string): boolean;
|
|
|
76
76
|
* @returns FQDN
|
|
77
77
|
* @throws ParseError if invalid
|
|
78
78
|
*/
|
|
79
|
-
export declare function parseFQDN(input: string):
|
|
79
|
+
export declare function parseFQDN(input: string): string;
|
|
80
80
|
/**
|
|
81
81
|
* Parse a unicast address based on address type
|
|
82
82
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-parser.d.ts","sourceRoot":"","sources":["../../../src/utils/address-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"address-parser.d.ts","sourceRoot":"","sources":["../../../src/utils/address-parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA4BnD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrD;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAsFnD;AAeD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAoB5D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrD;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA4B7C;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/C;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,cAAc,CA4BrF;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAgBzD"}
|
|
@@ -15,7 +15,6 @@ exports.isFQDN = isFQDN;
|
|
|
15
15
|
exports.parseFQDN = parseFQDN;
|
|
16
16
|
exports.parseUnicastAddress = parseUnicastAddress;
|
|
17
17
|
exports.detectAddressType = detectAddressType;
|
|
18
|
-
const network_1 = require("../types/network");
|
|
19
18
|
const errors_1 = require("../types/errors");
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// IPv4 Address Validation
|
|
@@ -78,7 +77,7 @@ function parseIP4Address(input) {
|
|
|
78
77
|
if (!isIP4Address(input)) {
|
|
79
78
|
throw new errors_1.ParseError(`Invalid IPv4 address: '${input}'`, 0, 0);
|
|
80
79
|
}
|
|
81
|
-
return
|
|
80
|
+
return input;
|
|
82
81
|
}
|
|
83
82
|
// ============================================================================
|
|
84
83
|
// IPv6 Address Validation
|
|
@@ -219,7 +218,7 @@ function parseIP6Address(input) {
|
|
|
219
218
|
if (!isIP6Address(input)) {
|
|
220
219
|
throw new errors_1.ParseError(`Invalid IPv6 address: '${input}'`, 0, 0);
|
|
221
220
|
}
|
|
222
|
-
return
|
|
221
|
+
return input;
|
|
223
222
|
}
|
|
224
223
|
// ============================================================================
|
|
225
224
|
// FQDN Validation
|
|
@@ -271,7 +270,7 @@ function parseFQDN(input) {
|
|
|
271
270
|
if (!isFQDN(input)) {
|
|
272
271
|
throw new errors_1.ParseError(`Invalid FQDN: '${input}'`, 0, 0);
|
|
273
272
|
}
|
|
274
|
-
return
|
|
273
|
+
return input;
|
|
275
274
|
}
|
|
276
275
|
// ============================================================================
|
|
277
276
|
// Unicast Address Parsing
|
|
@@ -292,25 +291,19 @@ function parseUnicastAddress(input, addrType) {
|
|
|
292
291
|
switch (addrType) {
|
|
293
292
|
case 'IP4':
|
|
294
293
|
// Try IPv4 first, then FQDN
|
|
295
|
-
if (isIP4Address(input)) {
|
|
296
|
-
return
|
|
297
|
-
}
|
|
298
|
-
if (isFQDN(input)) {
|
|
299
|
-
return (0, network_1.createFQDN)(input);
|
|
294
|
+
if (isIP4Address(input) || isFQDN(input)) {
|
|
295
|
+
return input;
|
|
300
296
|
}
|
|
301
297
|
throw new errors_1.ParseError(`Invalid address for type IP4: '${input}' (expected IPv4 or FQDN)`, 0, 0);
|
|
302
298
|
case 'IP6':
|
|
303
299
|
// Try IPv6 first, then FQDN
|
|
304
|
-
if (isIP6Address(input)) {
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
if (isFQDN(input)) {
|
|
308
|
-
return (0, network_1.createFQDN)(input);
|
|
300
|
+
if (isIP6Address(input) || isFQDN(input)) {
|
|
301
|
+
return input;
|
|
309
302
|
}
|
|
310
303
|
throw new errors_1.ParseError(`Invalid address for type IP6: '${input}' (expected IPv6 or FQDN)`, 0, 0);
|
|
311
304
|
default:
|
|
312
|
-
// Extension address type
|
|
313
|
-
return
|
|
305
|
+
// Extension address type - accept any string
|
|
306
|
+
return input;
|
|
314
307
|
}
|
|
315
308
|
}
|
|
316
309
|
// ============================================================================
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validators for SDP (RFC 8866)
|
|
3
|
+
*
|
|
4
|
+
* This module consolidates:
|
|
5
|
+
* - Session-level validation
|
|
6
|
+
* - Media description validation
|
|
7
|
+
* - Cross-field semantic validation
|
|
8
|
+
*/
|
|
9
|
+
import { SessionDescription } from '../types/session';
|
|
10
|
+
import { MediaDescription } from '../types/media';
|
|
11
|
+
import { ValidationError } from '../types/errors';
|
|
12
|
+
/**
|
|
13
|
+
* Result of validation - either valid or contains errors
|
|
14
|
+
*/
|
|
15
|
+
export interface ValidationResult {
|
|
16
|
+
readonly valid: boolean;
|
|
17
|
+
readonly errors: readonly ValidationError[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a valid result
|
|
21
|
+
*/
|
|
22
|
+
export declare function validResult(): ValidationResult;
|
|
23
|
+
/**
|
|
24
|
+
* Create an invalid result with errors
|
|
25
|
+
*/
|
|
26
|
+
export declare function invalidResult(errors: ValidationError[]): ValidationResult;
|
|
27
|
+
/**
|
|
28
|
+
* Options for customizing validation behavior
|
|
29
|
+
*/
|
|
30
|
+
export interface ValidationOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Whether to skip semantic validation (cross-field checks)
|
|
33
|
+
*/
|
|
34
|
+
skipSemanticValidation?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to allow deprecated k= field without warning
|
|
37
|
+
*/
|
|
38
|
+
allowDeprecatedKeyField?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to require connection at session level
|
|
41
|
+
*/
|
|
42
|
+
requireSessionConnection?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Perform complete semantic validation of a session description
|
|
46
|
+
*
|
|
47
|
+
* This is the main validation entry point that checks:
|
|
48
|
+
* 1. Session-level validation
|
|
49
|
+
* 2. Media-level validation
|
|
50
|
+
* 3. Cross-field semantic constraints
|
|
51
|
+
*
|
|
52
|
+
* @param session - Session description to validate
|
|
53
|
+
* @param options - Optional validation options
|
|
54
|
+
* @returns ValidationResult with all errors found
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateSdp(session: SessionDescription, options?: ValidationOptions): ValidationResult;
|
|
57
|
+
/**
|
|
58
|
+
* Validate a complete session description
|
|
59
|
+
*
|
|
60
|
+
* Checks RFC 8866 Section 5 requirements:
|
|
61
|
+
* - Required fields are present (v, o, s, t)
|
|
62
|
+
* - Version is 0
|
|
63
|
+
* - At least one time description
|
|
64
|
+
* - Connection coverage (session or all media)
|
|
65
|
+
*
|
|
66
|
+
* @param session - Session description to validate
|
|
67
|
+
* @returns ValidationResult with any errors found
|
|
68
|
+
*/
|
|
69
|
+
export declare function validateSessionDescription(session: SessionDescription): ValidationResult;
|
|
70
|
+
/**
|
|
71
|
+
* Validate a media description
|
|
72
|
+
*
|
|
73
|
+
* @param media - Media description to validate
|
|
74
|
+
* @param index - Index of media description (for error messages)
|
|
75
|
+
* @param hasSessionConnection - Whether session-level connection exists
|
|
76
|
+
* @returns ValidationResult with any errors found
|
|
77
|
+
*/
|
|
78
|
+
export declare function validateMediaDescription(media: MediaDescription, index: number, hasSessionConnection: boolean): ValidationResult;
|
|
79
|
+
/**
|
|
80
|
+
* Validate all media descriptions in a session
|
|
81
|
+
*
|
|
82
|
+
* @param mediaDescriptions - Array of media descriptions
|
|
83
|
+
* @param hasSessionConnection - Whether session-level connection exists
|
|
84
|
+
* @returns ValidationResult with any errors found
|
|
85
|
+
*/
|
|
86
|
+
export declare function validateAllMediaDescriptions(mediaDescriptions: readonly MediaDescription[], hasSessionConnection: boolean): ValidationResult;
|
|
87
|
+
/**
|
|
88
|
+
* Validate cross-field semantic constraints
|
|
89
|
+
*
|
|
90
|
+
* @param session - Session description to validate
|
|
91
|
+
* @returns ValidationResult with any errors found
|
|
92
|
+
*/
|
|
93
|
+
export declare function validateSemanticConstraints(session: SessionDescription): ValidationResult;
|
|
94
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/validator/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACl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