@svta/cml-cmsd 1.1.0 → 1.1.2
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 +17 -10
- package/dist/index.d.ts +339 -340
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -14
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -11,16 +11,23 @@ npm i @svta/cml-cmsd
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CmsdObjectType,
|
|
16
|
+
CmsdStreamingFormat,
|
|
17
|
+
CmsdStreamType,
|
|
18
|
+
encodeCmsdStatic,
|
|
19
|
+
} from "@svta/cml-cmsd";
|
|
20
|
+
import type { CmsdStatic } from "@svta/cml-cmsd";
|
|
15
21
|
|
|
16
|
-
const input =
|
|
17
|
-
ot:
|
|
18
|
-
sf:
|
|
19
|
-
st:
|
|
20
|
-
|
|
22
|
+
const input: CmsdStatic = {
|
|
23
|
+
ot: CmsdObjectType.VIDEO,
|
|
24
|
+
sf: CmsdStreamingFormat.HLS,
|
|
25
|
+
st: CmsdStreamType.VOD,
|
|
26
|
+
d: 5000,
|
|
27
|
+
br: 2000,
|
|
28
|
+
n: "OriginProviderA",
|
|
29
|
+
};
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`ot=v,sf=h,st=v,d=5000,br=2000,n="OriginProviderA"`
|
|
25
|
-
);
|
|
31
|
+
console.log(encodeCmsdStatic(input));
|
|
32
|
+
// ot=v,sf=h,st=v,d=5000,br=2000,n="OriginProviderA"
|
|
26
33
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,462 +1,461 @@
|
|
|
1
1
|
import { CmObjectType, CmStreamType, CmStreamingFormat } from "@svta/cml-cta";
|
|
2
2
|
import { SfItem, SfToken } from "@svta/cml-structured-field-values";
|
|
3
3
|
import { ValueOf } from "@svta/cml-utils";
|
|
4
|
-
|
|
5
4
|
//#region src/CMSD_DYNAMIC.d.ts
|
|
6
5
|
/**
|
|
7
|
-
* CMSD dynamic header name.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
declare const CMSD_DYNAMIC = "CMSD-Dynamic";
|
|
6
|
+
* CMSD dynamic header name.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const CMSD_DYNAMIC = "CMSD-Dynamic";
|
|
12
11
|
//#endregion
|
|
13
12
|
//#region src/CMSD_STATIC.d.ts
|
|
14
13
|
/**
|
|
15
|
-
* CMSD static header name.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
declare const CMSD_STATIC = "CMSD-Static";
|
|
14
|
+
* CMSD static header name.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const CMSD_STATIC = "CMSD-Static";
|
|
20
19
|
//#endregion
|
|
21
20
|
//#region src/CMSD_V1.d.ts
|
|
22
21
|
/**
|
|
23
|
-
* CMSD Version 1
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
declare const CMSD_V1 = 1;
|
|
22
|
+
* CMSD Version 1
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare const CMSD_V1 = 1;
|
|
28
27
|
//#endregion
|
|
29
28
|
//#region src/CmsdCustomKey.d.ts
|
|
30
29
|
/**
|
|
31
|
-
* A custom key for CMSD. Custom keys MUST carry a hyphenated prefix
|
|
32
|
-
* to ensure that there will not be a namespace collision with future
|
|
33
|
-
* revisions to this specification. Clients SHOULD use a reverse-DNS
|
|
34
|
-
* syntax when defining their own prefix.
|
|
35
|
-
*
|
|
36
|
-
* The type requires a lowercase hyphenated string. At runtime a key
|
|
37
|
-
* must also satisfy {@link isCmsdCustomKey} (a lowercase first
|
|
38
|
-
* letter, then characters from `a-z 0-9 . -`, with a hyphen that is
|
|
39
|
-
* neither the first nor the last character), the subset of the CMSD
|
|
40
|
-
* custom-key grammar that survives RFC 8941 key serialization. Keys
|
|
41
|
-
* failing it fail structured-field serialization at encode time.
|
|
42
|
-
* Lowercase reverse-DNS names satisfy all constraints.
|
|
43
|
-
*
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
30
|
+
* A custom key for CMSD. Custom keys MUST carry a hyphenated prefix
|
|
31
|
+
* to ensure that there will not be a namespace collision with future
|
|
32
|
+
* revisions to this specification. Clients SHOULD use a reverse-DNS
|
|
33
|
+
* syntax when defining their own prefix.
|
|
34
|
+
*
|
|
35
|
+
* The type requires a lowercase hyphenated string. At runtime a key
|
|
36
|
+
* must also satisfy {@link isCmsdCustomKey} (a lowercase first
|
|
37
|
+
* letter, then characters from `a-z 0-9 . -`, with a hyphen that is
|
|
38
|
+
* neither the first nor the last character), the subset of the CMSD
|
|
39
|
+
* custom-key grammar that survives RFC 8941 key serialization. Keys
|
|
40
|
+
* failing it fail structured-field serialization at encode time.
|
|
41
|
+
* Lowercase reverse-DNS names satisfy all constraints.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
46
45
|
type CmsdCustomKey = Lowercase<`${string}-${string}`>;
|
|
47
46
|
//#endregion
|
|
48
47
|
//#region src/CmsdObjectType.d.ts
|
|
49
48
|
/**
|
|
50
|
-
* Common Media Server Data Object Type
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @enum
|
|
54
|
-
*
|
|
55
|
-
* @public
|
|
56
|
-
*/
|
|
57
|
-
declare const CmsdObjectType: typeof CmObjectType;
|
|
49
|
+
* Common Media Server Data Object Type
|
|
50
|
+
*
|
|
51
|
+
*
|
|
52
|
+
* @enum
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export declare const CmsdObjectType: typeof CmObjectType;
|
|
58
57
|
/**
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
type CmsdObjectType = CmObjectType;
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export type CmsdObjectType = CmObjectType;
|
|
62
61
|
//#endregion
|
|
63
62
|
//#region src/CmsdStreamType.d.ts
|
|
64
63
|
/**
|
|
65
|
-
* Common Media Server Data Stream Type
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @enum
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
declare const CmsdStreamType: typeof CmStreamType;
|
|
64
|
+
* Common Media Server Data Stream Type
|
|
65
|
+
*
|
|
66
|
+
*
|
|
67
|
+
* @enum
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare const CmsdStreamType: typeof CmStreamType;
|
|
73
72
|
/**
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
type CmsdStreamType = CmStreamType;
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export type CmsdStreamType = CmStreamType;
|
|
77
76
|
//#endregion
|
|
78
77
|
//#region src/CmsdStreamingFormat.d.ts
|
|
79
78
|
/**
|
|
80
|
-
* Common Media Server Data Streaming Format
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @enum
|
|
84
|
-
*
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
declare const CmsdStreamingFormat: typeof CmStreamingFormat;
|
|
79
|
+
* Common Media Server Data Streaming Format
|
|
80
|
+
*
|
|
81
|
+
*
|
|
82
|
+
* @enum
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export declare const CmsdStreamingFormat: typeof CmStreamingFormat;
|
|
88
87
|
/**
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
type CmsdStreamingFormat = CmStreamingFormat;
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export type CmsdStreamingFormat = CmStreamingFormat;
|
|
92
91
|
//#endregion
|
|
93
92
|
//#region src/CmsdValue.d.ts
|
|
94
93
|
/**
|
|
95
|
-
* CMSD Value
|
|
96
|
-
*
|
|
97
|
-
* @public
|
|
98
|
-
*/
|
|
94
|
+
* CMSD Value
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
99
98
|
type CmsdValue = CmsdObjectType | CmsdStreamingFormat | CmsdStreamType | string | number | boolean | symbol | SfToken;
|
|
100
99
|
//#endregion
|
|
101
100
|
//#region src/CmsdDynamicParams.d.ts
|
|
102
101
|
/**
|
|
103
|
-
* Common Media Server Data (CMSD) dynamic response header field parameters.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
106
|
-
*
|
|
107
|
-
* @public
|
|
108
|
-
*/
|
|
102
|
+
* Common Media Server Data (CMSD) dynamic response header field parameters.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
109
108
|
type CmsdDynamicParams = {
|
|
110
109
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
* Custom key names may be used, but they MUST carry a hyphenated prefix to ensure that there will not be a namespace collision
|
|
111
|
+
* with future revisions to this specification. Clients SHOULD use a reverse-DNS syntax when defining their own prefix.
|
|
112
|
+
*/
|
|
114
113
|
[index: CmsdCustomKey]: CmsdValue;
|
|
115
114
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
* Duress
|
|
116
|
+
*
|
|
117
|
+
* Key is included without a value if the server is under duress, due to cpu, memory, disk IO, network IO or other reasons. The
|
|
118
|
+
* thresholds for signaling duress are left to the discretion of the server operator. The intent is that the client will use this
|
|
119
|
+
* signal to move away to an alternate server if possible. This key MUST NOT be sent if it is false.
|
|
120
|
+
*
|
|
121
|
+
* Boolean
|
|
122
|
+
*/
|
|
124
123
|
du?: boolean;
|
|
125
124
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
* Estimated Throughput
|
|
126
|
+
*
|
|
127
|
+
* The throughput between the server and the client over the currently negotiated transport as estimated by the server at the start
|
|
128
|
+
* of the response. The value is expressed in units of kilobits per second and rounded to the nearest integer. The time window for
|
|
129
|
+
* this estimate is expected to be the duration of the current response at most. The throughput may vary during the response and the
|
|
130
|
+
* client SHOULD use this data as an adjunct to its own throughput estimates. As an informative example, this estimate could be
|
|
131
|
+
* derived in this way:
|
|
132
|
+
*
|
|
133
|
+
* etp = 8 * send_window / (rtt)
|
|
134
|
+
*
|
|
135
|
+
* where send_window = min (cwnd * mss, rwnd) with Congestion Window (cwnd) measured in packets, Maximum Segment Size (mss) in bytes,
|
|
136
|
+
* Receiver Window (rwnd) in bytes and rtt in milliseconds. Note that multiple client processes adjacent to the media player may pool
|
|
137
|
+
* their requests into the same connection to the server. In this case the server estimate of throughput will be against the entirety
|
|
138
|
+
* of the connection, not all of which will be accessible to the media player.
|
|
139
|
+
*
|
|
140
|
+
* Integer Kbps
|
|
141
|
+
*/
|
|
143
142
|
etp?: number;
|
|
144
143
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
* Max suggested bitrate
|
|
145
|
+
*
|
|
146
|
+
* The maximum bitrate value that the player SHOULD play in its Adaptive Bit Rate (ABR) ladder. If the player is playing a bitrate higher
|
|
147
|
+
* than this value, it SHOULD immediately switch to a bitrate lower than or equal to this value.
|
|
148
|
+
*
|
|
149
|
+
* Integer Kbps
|
|
150
|
+
*/
|
|
152
151
|
mb?: number;
|
|
153
152
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
* Response delay
|
|
154
|
+
*
|
|
155
|
+
* The time elapsed between the receipt of the request and when the first byte of the body becomes available to send to the client. The
|
|
156
|
+
* intention is for receivers to use this value to more accurately calculate the throughput of the connection [MHV22].
|
|
157
|
+
*
|
|
158
|
+
* Integer milliseconds
|
|
159
|
+
*/
|
|
161
160
|
rd?: number;
|
|
162
161
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
* Round Trip Time
|
|
163
|
+
*
|
|
164
|
+
* Estimated round trip time between client and server. This estimate may be derived from the transport handshake. For subsequent requests
|
|
165
|
+
* over the same connection, the value can be refined to be an exponentially weighted moving average of prior instantaneous values. An
|
|
166
|
+
* informative example algorithm for this averaging is provided by [18].
|
|
167
|
+
*
|
|
168
|
+
* Integer Kbps
|
|
169
|
+
*/
|
|
171
170
|
rtt?: number;
|
|
172
171
|
};
|
|
173
172
|
//#endregion
|
|
174
173
|
//#region src/CmsdDynamic.d.ts
|
|
175
174
|
/**
|
|
176
|
-
* Common Media Server Data (CMSD) dynamic response header fields.
|
|
177
|
-
*
|
|
178
|
-
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
179
|
-
*
|
|
180
|
-
* @public
|
|
181
|
-
*/
|
|
175
|
+
* Common Media Server Data (CMSD) dynamic response header fields.
|
|
176
|
+
*
|
|
177
|
+
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
178
|
+
*
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
182
181
|
type CmsdDynamic = {
|
|
183
182
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
* The server name.
|
|
184
|
+
*/
|
|
186
185
|
value: string;
|
|
187
186
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
* The CMSD dynamic parameters.
|
|
188
|
+
*/
|
|
190
189
|
params: CmsdDynamicParams;
|
|
191
190
|
};
|
|
192
191
|
//#endregion
|
|
193
192
|
//#region src/CmsdEncodeOptions.d.ts
|
|
194
193
|
/**
|
|
195
|
-
* Options for encoding CMCD values.
|
|
196
|
-
*
|
|
197
|
-
* @public
|
|
198
|
-
*/
|
|
194
|
+
* Options for encoding CMCD values.
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
199
198
|
type CmsdEncodeOptions = {
|
|
200
199
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
* Use Symbol to represent token values
|
|
201
|
+
*
|
|
202
|
+
* @defaultValue `true`
|
|
203
|
+
*/
|
|
205
204
|
useSymbol?: boolean;
|
|
206
205
|
};
|
|
207
206
|
//#endregion
|
|
208
207
|
//#region src/CmsdHeaderField.d.ts
|
|
209
208
|
/**
|
|
210
|
-
* CMSD header fields.
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* @enum
|
|
214
|
-
*
|
|
215
|
-
* @public
|
|
216
|
-
*/
|
|
217
|
-
declare const CmsdHeaderField: {
|
|
209
|
+
* CMSD header fields.
|
|
210
|
+
*
|
|
211
|
+
*
|
|
212
|
+
* @enum
|
|
213
|
+
*
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
export declare const CmsdHeaderField: {
|
|
218
217
|
/**
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
* Keys whose values persist over multiple requests for the object.
|
|
219
|
+
*/
|
|
221
220
|
readonly STATIC: typeof CMSD_STATIC;
|
|
222
221
|
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
* Keys whose values apply only to the next transmission hop. Typically a
|
|
223
|
+
* new CMSD-Dynamic header instance will be added by each intermediary
|
|
224
|
+
* participating in the delivery.
|
|
225
|
+
*/
|
|
227
226
|
readonly DYNAMIC: typeof CMSD_DYNAMIC;
|
|
228
227
|
};
|
|
229
228
|
/**
|
|
230
|
-
* @public
|
|
231
|
-
*/
|
|
232
|
-
type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
export type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;
|
|
233
232
|
//#endregion
|
|
234
233
|
//#region src/CmsdStatic.d.ts
|
|
235
234
|
/**
|
|
236
|
-
* Common Media Server Data (CMSD) static response header fields.
|
|
237
|
-
*
|
|
238
|
-
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
239
|
-
*
|
|
240
|
-
* @public
|
|
241
|
-
*/
|
|
235
|
+
* Common Media Server Data (CMSD) static response header fields.
|
|
236
|
+
*
|
|
237
|
+
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5006-final.pdf|CMSD Spec}
|
|
238
|
+
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
242
241
|
type CmsdStatic = {
|
|
243
242
|
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
* Custom key names may be used, but they MUST carry a hyphenated prefix to ensure that there will not be a namespace collision
|
|
244
|
+
* with future revisions to this specification. Clients SHOULD use a reverse-DNS syntax when defining their own prefix.
|
|
245
|
+
*/
|
|
247
246
|
[index: CmsdCustomKey]: CmsdValue;
|
|
248
247
|
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
248
|
+
* Availability time
|
|
249
|
+
*
|
|
250
|
+
* The wallclock time at which the first byte of this object became available at the origin for successful request. The time is
|
|
251
|
+
* expressed as integer milliseconds since the Unix Epoch, i.e., the number of milliseconds that have elapsed since January 1,
|
|
252
|
+
* 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970- 01-01T00:00:000Z).
|
|
253
|
+
*
|
|
254
|
+
* Integer Milliseconds
|
|
255
|
+
*/
|
|
257
256
|
at?: number;
|
|
258
257
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
258
|
+
* Encoded bitrate
|
|
259
|
+
*
|
|
260
|
+
* The encoded bitrate of the audio or video object being requested. If the instantaneous bitrate varies over the duration of the
|
|
261
|
+
* object, the average value over the duration of the object SHOULD be communicated. This key should only accompany objects that
|
|
262
|
+
* have an implicit bitrate.
|
|
263
|
+
*
|
|
264
|
+
* Integer kbps
|
|
265
|
+
*/
|
|
267
266
|
br?: number;
|
|
268
267
|
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
268
|
+
* Object duration
|
|
269
|
+
*
|
|
270
|
+
* The playback duration in milliseconds of the object being requested. If a partial segment is being requested, then this value
|
|
271
|
+
* MUST indicate the playback duration of that part and not that of its parent segment. This value can be an approximation of the
|
|
272
|
+
* estimated duration if the explicit value is not known.
|
|
273
|
+
*
|
|
274
|
+
* Integer milliseconds
|
|
275
|
+
*/
|
|
277
276
|
d?: number;
|
|
278
277
|
/**
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
* Held time
|
|
279
|
+
*
|
|
280
|
+
* The number of milliseconds that this response was held back by an origin before returning. This is applicable to blocking responses
|
|
281
|
+
* under LL-HLS [HLSbis].
|
|
282
|
+
*
|
|
283
|
+
* Integer Milliseconds
|
|
284
|
+
*/
|
|
286
285
|
ht?: number;
|
|
287
286
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
* Intermediary identifier
|
|
288
|
+
*
|
|
289
|
+
* An identifier for the processing server. The value SHOULD identify both the organization and the intermediary that is writing the key.
|
|
290
|
+
* Identifiers SHOULD be as concise as possible to reduce log file and transferred size, while still remaining unique.
|
|
291
|
+
*
|
|
292
|
+
* String
|
|
293
|
+
*/
|
|
295
294
|
n?: string;
|
|
296
295
|
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
* Next object request
|
|
297
|
+
*
|
|
298
|
+
* Relative path of the next object to be requested. This can be used to trigger pre-fetching by the CDN. This MUST be a path relative to the current
|
|
299
|
+
* request. This string MUST be URLEncoded. The client SHOULD NOT depend upon any pre-fetch action being taken - it is merely a request for such a
|
|
300
|
+
* pre-fetch to take place.
|
|
301
|
+
*
|
|
302
|
+
* String
|
|
303
|
+
*/
|
|
305
304
|
nor?: string;
|
|
306
305
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
306
|
+
* Next range request
|
|
307
|
+
*
|
|
308
|
+
* If the next request will be a partial object request, then this string denotes the byte range to be requested. If the ‘nor’ field is not set, then the
|
|
309
|
+
* object is assumed to match the object currently being requested. The client SHOULD NOT depend upon any pre-fetch action being taken – it is merely a
|
|
310
|
+
* request for such a pre-fetch to take place. Formatting is similar to the HTTP Range header, except that the unit MUST be ‘byte’, the ‘Range:’ prefix is
|
|
311
|
+
* NOT required and specifying multiple ranges is NOT allowed. Valid combinations are:
|
|
312
|
+
*
|
|
313
|
+
* - `"\<range-start\>-"`
|
|
314
|
+
* - `"\<range-start\>-\<range-end\>"`
|
|
315
|
+
* - `"-\<suffix-length\>"`
|
|
316
|
+
*
|
|
317
|
+
* String
|
|
318
|
+
*/
|
|
320
319
|
nrr?: string;
|
|
321
320
|
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
321
|
+
* Object type
|
|
322
|
+
*
|
|
323
|
+
* The media type of the current object being requested:
|
|
324
|
+
* - `m` = text file, such as a manifest or playlist
|
|
325
|
+
* - `a` = audio only
|
|
326
|
+
* - `v` = video only
|
|
327
|
+
* - `av` = muxed audio and video
|
|
328
|
+
* - `i` = init segment
|
|
329
|
+
* - `c` = caption or subtitle
|
|
330
|
+
* - `tt` = ISOBMFF timed text track
|
|
331
|
+
* - `k` = cryptographic key, license or certificate.
|
|
332
|
+
* - `o` = other
|
|
333
|
+
*
|
|
334
|
+
* If the object type being requested is unknown, then this key MUST NOT be used.
|
|
335
|
+
*
|
|
336
|
+
* Token
|
|
337
|
+
*/
|
|
339
338
|
ot?: CmsdObjectType;
|
|
340
339
|
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
340
|
+
* Streaming format
|
|
341
|
+
*
|
|
342
|
+
* The streaming format that defines the current request.
|
|
343
|
+
*
|
|
344
|
+
* - `d` = MPEG DASH
|
|
345
|
+
* - `h` = HTTP Live Streaming (HLS)
|
|
346
|
+
* - `s` = Smooth Streaming
|
|
347
|
+
* - `o` = other
|
|
348
|
+
*
|
|
349
|
+
* If the streaming format being requested is unknown, then this key MUST NOT be used.
|
|
350
|
+
*
|
|
351
|
+
* Token
|
|
352
|
+
*/
|
|
354
353
|
sf?: CmsdStreamingFormat;
|
|
355
354
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
355
|
+
* Stream type
|
|
356
|
+
* - `v` = all segments are available – e.g., VOD
|
|
357
|
+
* - `l` = segments become available over time – e.g., LIVE
|
|
358
|
+
*
|
|
359
|
+
* Token
|
|
360
|
+
*/
|
|
362
361
|
st?: CmsdStreamType;
|
|
363
362
|
/**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
* Startup
|
|
364
|
+
*
|
|
365
|
+
* Key is included without a value if the object is needed urgently due to startup, seeking or recovery after a buffer-empty event. The media SHOULD not be
|
|
366
|
+
* rendering when this request is made. This key MUST not be sent if it is FALSE.
|
|
367
|
+
*
|
|
368
|
+
* Boolean
|
|
369
|
+
*/
|
|
371
370
|
su?: boolean;
|
|
372
371
|
/**
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
372
|
+
* CMSD version
|
|
373
|
+
*
|
|
374
|
+
* The version of this specification used for interpreting the defined key names and values. If this key is omitted, the client and server MUST
|
|
375
|
+
* interpret the values as being defined by version 1. Client SHOULD omit this field if the version is 1.
|
|
376
|
+
*
|
|
377
|
+
* Integer
|
|
378
|
+
*/
|
|
380
379
|
v?: number;
|
|
381
380
|
};
|
|
382
381
|
//#endregion
|
|
383
382
|
//#region src/decodeCmsdDynamic.d.ts
|
|
384
383
|
/**
|
|
385
|
-
* Decode a CMSD dynamic string to an object.
|
|
386
|
-
*
|
|
387
|
-
* @param cmsd - The CMSD string to decode.
|
|
388
|
-
*
|
|
389
|
-
* @returns The decoded CMSD object.
|
|
390
|
-
*
|
|
391
|
-
* @public
|
|
392
|
-
*/
|
|
393
|
-
declare function decodeCmsdDynamic(cmsd: string): CmsdDynamic[];
|
|
384
|
+
* Decode a CMSD dynamic string to an object.
|
|
385
|
+
*
|
|
386
|
+
* @param cmsd - The CMSD string to decode.
|
|
387
|
+
*
|
|
388
|
+
* @returns The decoded CMSD object.
|
|
389
|
+
*
|
|
390
|
+
* @public
|
|
391
|
+
*/
|
|
392
|
+
export declare function decodeCmsdDynamic(cmsd: string): CmsdDynamic[];
|
|
394
393
|
//#endregion
|
|
395
394
|
//#region src/decodeCmsdStatic.d.ts
|
|
396
395
|
/**
|
|
397
|
-
* Decode a CMSD Static dict string to an object.
|
|
398
|
-
*
|
|
399
|
-
* @param cmsd - The CMSD string to decode.
|
|
400
|
-
*
|
|
401
|
-
* @returns The decoded CMSD object.
|
|
402
|
-
*
|
|
403
|
-
* @public
|
|
404
|
-
*/
|
|
405
|
-
declare function decodeCmsdStatic(cmsd: string): CmsdStatic;
|
|
396
|
+
* Decode a CMSD Static dict string to an object.
|
|
397
|
+
*
|
|
398
|
+
* @param cmsd - The CMSD string to decode.
|
|
399
|
+
*
|
|
400
|
+
* @returns The decoded CMSD object.
|
|
401
|
+
*
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
404
|
+
export declare function decodeCmsdStatic(cmsd: string): CmsdStatic;
|
|
406
405
|
//#endregion
|
|
407
406
|
//#region src/encodeCmsdDynamic.d.ts
|
|
408
407
|
/**
|
|
409
|
-
* Encode a list of CMSD Dynamic objects.
|
|
410
|
-
*
|
|
411
|
-
* @param value - The list of `SfItems` to encode.
|
|
412
|
-
*
|
|
413
|
-
* @returns The encoded CMSD string.
|
|
414
|
-
*
|
|
415
|
-
* @public
|
|
416
|
-
*/
|
|
417
|
-
declare function encodeCmsdDynamic(value: SfItem[]): string;
|
|
408
|
+
* Encode a list of CMSD Dynamic objects.
|
|
409
|
+
*
|
|
410
|
+
* @param value - The list of `SfItems` to encode.
|
|
411
|
+
*
|
|
412
|
+
* @returns The encoded CMSD string.
|
|
413
|
+
*
|
|
414
|
+
* @public
|
|
415
|
+
*/
|
|
416
|
+
export declare function encodeCmsdDynamic(value: SfItem[]): string;
|
|
418
417
|
/**
|
|
419
|
-
* Encode a single CMSD Dynamic object.
|
|
420
|
-
*
|
|
421
|
-
* @param value - The server name
|
|
422
|
-
* @param cmsd - The CMSD object to encode.
|
|
423
|
-
*
|
|
424
|
-
* @returns The encoded CMSD string.
|
|
425
|
-
*
|
|
426
|
-
* @public
|
|
427
|
-
*/
|
|
428
|
-
declare function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;
|
|
418
|
+
* Encode a single CMSD Dynamic object.
|
|
419
|
+
*
|
|
420
|
+
* @param value - The server name
|
|
421
|
+
* @param cmsd - The CMSD object to encode.
|
|
422
|
+
*
|
|
423
|
+
* @returns The encoded CMSD string.
|
|
424
|
+
*
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
export declare function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;
|
|
429
428
|
//#endregion
|
|
430
429
|
//#region src/encodeCmsdStatic.d.ts
|
|
431
430
|
/**
|
|
432
|
-
* Encode a CMSD Static object.
|
|
433
|
-
*
|
|
434
|
-
* @param cmsd - The CMSD object to encode.
|
|
435
|
-
* @param options - Encoding options
|
|
436
|
-
*
|
|
437
|
-
* @returns The encoded CMSD string.
|
|
438
|
-
*
|
|
439
|
-
* @public
|
|
440
|
-
*/
|
|
441
|
-
declare function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string;
|
|
431
|
+
* Encode a CMSD Static object.
|
|
432
|
+
*
|
|
433
|
+
* @param cmsd - The CMSD object to encode.
|
|
434
|
+
* @param options - Encoding options
|
|
435
|
+
*
|
|
436
|
+
* @returns The encoded CMSD string.
|
|
437
|
+
*
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
export declare function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string;
|
|
442
441
|
//#endregion
|
|
443
442
|
//#region src/isCmsdCustomKey.d.ts
|
|
444
443
|
/**
|
|
445
|
-
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
446
|
-
* characters from `a-z 0-9 . -`, with a hyphen that is neither the first
|
|
447
|
-
* nor the last character. These are the CMSD custom-key rules restricted
|
|
448
|
-
* to names that survive RFC 8941 key serialization.
|
|
449
|
-
*
|
|
450
|
-
* @param key - The key to check.
|
|
451
|
-
*
|
|
452
|
-
* @returns `true` if the key is a custom key, `false` otherwise.
|
|
453
|
-
*
|
|
454
|
-
* @public
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* {@includeCode ../test/isCmsdCustomKey.test.ts#example}
|
|
458
|
-
*/
|
|
459
|
-
declare function isCmsdCustomKey(key: string): boolean;
|
|
444
|
+
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
445
|
+
* characters from `a-z 0-9 . -`, with a hyphen that is neither the first
|
|
446
|
+
* nor the last character. These are the CMSD custom-key rules restricted
|
|
447
|
+
* to names that survive RFC 8941 key serialization.
|
|
448
|
+
*
|
|
449
|
+
* @param key - The key to check.
|
|
450
|
+
*
|
|
451
|
+
* @returns `true` if the key is a custom key, `false` otherwise.
|
|
452
|
+
*
|
|
453
|
+
* @public
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* {@includeCode ../test/isCmsdCustomKey.test.ts#example}
|
|
457
|
+
*/
|
|
458
|
+
export declare function isCmsdCustomKey(key: string): boolean;
|
|
460
459
|
//#endregion
|
|
461
|
-
export {
|
|
460
|
+
export type { CmsdCustomKey, CmsdDynamic, CmsdDynamicParams, CmsdEncodeOptions, CmsdStatic, CmsdValue };
|
|
462
461
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdCustomKey.ts","../src/CmsdObjectType.ts","../src/CmsdStreamType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdValue.ts","../src/CmsdDynamicParams.ts","../src/CmsdDynamic.ts","../src/CmsdEncodeOptions.ts","../src/CmsdHeaderField.ts","../src/CmsdStatic.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/encodeCmsdStatic.ts","../src/isCmsdCustomKey.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdCustomKey.ts","../src/CmsdObjectType.ts","../src/CmsdStreamType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdValue.ts","../src/CmsdDynamicParams.ts","../src/CmsdDynamic.ts","../src/CmsdEncodeOptions.ts","../src/CmsdHeaderField.ts","../src/CmsdStatic.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/encodeCmsdStatic.ts","../src/isCmsdCustomKey.ts"],"mappings":";;;;;;;;;qBAKa;;;;;;;;qBCAA;;;;;;;;qBCAA;;;;;;;;;;;;;;;;;;;KCWD,gBAAgB;;;;;;;;;;;qBCNf,uBAAwC;;;;YAKzC,iBAAiB;;;;;;;;;;;qBCLhB,uBAAwC;;;;YAKzC,iBAAiB;;;;;;;;;;;qBCLhB,4BAAkD;;;;YAKnD,sBAAsB;;;;;;;;KCLtB,YAAY,iBAAiB,sBAAsB,sDAAsD;;;;;;;;;;KCAzG;;;;;GAKH,OAAA,gBAAgB;;;;;;;;;;EAWxB;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;;;;EAUA;;;;;;;;;EAUA;;;;;;;;;;EAWA;;;;;;;;;;;KCpEW;;;;EAIX;;;;EAKA,QAAQ;;;;;;;;;KCbG;;;;;;EAMX;;;;;;;;;;;;qBCCY;;;;WAIZ,eAA8B;;;;;;WAO9B,gBAAgC;;;;;YAMrB,kBAAkB,eAAe;;;;;;;;;;KChBjC;;;;;GAMH,OAAA,gBAAgB;;;;;;;;;;EAWxB;;;;;;;;;;EAWA;;;;;;;;;;EAWA;;;;;;;;;EAUA;;;;;;;;;EAUA;;;;;;;;;;EAWA;;;;;;;;;;;;;;;EAgBA;;;;;;;;;;;;;;;;;;;EAoBA,KAAK;;;;;;;;;;;;;;;EAgBL,KAAK;;;;;;;;EASL,KAAK;;;;;;;;;EAUL;;;;;;;;;EAUA;;;;;;;;;;;;;wBCxJe,kBAAkB,eAAe;;;;;;;;;;;;wBCAjC,iBAAiB,eAAe;;;;;;;;;;;;wBCAhC,kBAAkB,OAAO;;;;;;;;;;;wBAYzB,kBAAkB,eAAe,MAAM;;;;;;;;;;;;;wBCTvC,iBAAiB,MAAM,YAAY,UAAU;;;;;;;;;;;;;;;;;;wBCI7C,gBAAgB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CmObjectType, CmStreamType, CmStreamingFormat, isTokenField, isValid } from "@svta/cml-cta";
|
|
2
2
|
import { SfItem, SfToken, decodeSfDict, decodeSfList, encodeSfDict, encodeSfList, symbolToStr } from "@svta/cml-structured-field-values";
|
|
3
|
-
|
|
4
3
|
//#region src/CMSD_DYNAMIC.ts
|
|
5
4
|
/**
|
|
6
5
|
* CMSD dynamic header name.
|
|
@@ -8,7 +7,6 @@ import { SfItem, SfToken, decodeSfDict, decodeSfList, encodeSfDict, encodeSfList
|
|
|
8
7
|
* @public
|
|
9
8
|
*/
|
|
10
9
|
const CMSD_DYNAMIC = "CMSD-Dynamic";
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
11
|
//#region src/CMSD_STATIC.ts
|
|
14
12
|
/**
|
|
@@ -17,7 +15,6 @@ const CMSD_DYNAMIC = "CMSD-Dynamic";
|
|
|
17
15
|
* @public
|
|
18
16
|
*/
|
|
19
17
|
const CMSD_STATIC = "CMSD-Static";
|
|
20
|
-
|
|
21
18
|
//#endregion
|
|
22
19
|
//#region src/CMSD_V1.ts
|
|
23
20
|
/**
|
|
@@ -26,7 +23,6 @@ const CMSD_STATIC = "CMSD-Static";
|
|
|
26
23
|
* @public
|
|
27
24
|
*/
|
|
28
25
|
const CMSD_V1 = 1;
|
|
29
|
-
|
|
30
26
|
//#endregion
|
|
31
27
|
//#region src/CmsdHeaderField.ts
|
|
32
28
|
/**
|
|
@@ -38,10 +34,17 @@ const CMSD_V1 = 1;
|
|
|
38
34
|
* @public
|
|
39
35
|
*/
|
|
40
36
|
const CmsdHeaderField = {
|
|
37
|
+
/**
|
|
38
|
+
* Keys whose values persist over multiple requests for the object.
|
|
39
|
+
*/
|
|
41
40
|
STATIC: CMSD_STATIC,
|
|
41
|
+
/**
|
|
42
|
+
* Keys whose values apply only to the next transmission hop. Typically a
|
|
43
|
+
* new CMSD-Dynamic header instance will be added by each intermediary
|
|
44
|
+
* participating in the delivery.
|
|
45
|
+
*/
|
|
42
46
|
DYNAMIC: CMSD_DYNAMIC
|
|
43
47
|
};
|
|
44
|
-
|
|
45
48
|
//#endregion
|
|
46
49
|
//#region src/CmsdObjectType.ts
|
|
47
50
|
/**
|
|
@@ -53,7 +56,6 @@ const CmsdHeaderField = {
|
|
|
53
56
|
* @public
|
|
54
57
|
*/
|
|
55
58
|
const CmsdObjectType = CmObjectType;
|
|
56
|
-
|
|
57
59
|
//#endregion
|
|
58
60
|
//#region src/CmsdStreamingFormat.ts
|
|
59
61
|
/**
|
|
@@ -65,7 +67,6 @@ const CmsdObjectType = CmObjectType;
|
|
|
65
67
|
* @public
|
|
66
68
|
*/
|
|
67
69
|
const CmsdStreamingFormat = CmStreamingFormat;
|
|
68
|
-
|
|
69
70
|
//#endregion
|
|
70
71
|
//#region src/CmsdStreamType.ts
|
|
71
72
|
/**
|
|
@@ -77,7 +78,6 @@ const CmsdStreamingFormat = CmStreamingFormat;
|
|
|
77
78
|
* @public
|
|
78
79
|
*/
|
|
79
80
|
const CmsdStreamType = CmStreamType;
|
|
80
|
-
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/decodeCmsdDynamic.ts
|
|
83
83
|
/**
|
|
@@ -93,7 +93,6 @@ function decodeCmsdDynamic(cmsd) {
|
|
|
93
93
|
if (!cmsd) return [];
|
|
94
94
|
return decodeSfList(cmsd);
|
|
95
95
|
}
|
|
96
|
-
|
|
97
96
|
//#endregion
|
|
98
97
|
//#region src/decodeCmsdStatic.ts
|
|
99
98
|
/**
|
|
@@ -113,7 +112,6 @@ function decodeCmsdStatic(cmsd) {
|
|
|
113
112
|
return acc;
|
|
114
113
|
}, {});
|
|
115
114
|
}
|
|
116
|
-
|
|
117
115
|
//#endregion
|
|
118
116
|
//#region src/encodeCmsdDynamic.ts
|
|
119
117
|
function encodeCmsdDynamic(value, cmsd) {
|
|
@@ -124,7 +122,6 @@ function encodeCmsdDynamic(value, cmsd) {
|
|
|
124
122
|
}
|
|
125
123
|
return encodeSfList(value, { whitespace: false });
|
|
126
124
|
}
|
|
127
|
-
|
|
128
125
|
//#endregion
|
|
129
126
|
//#region src/utils/processCmsd.ts
|
|
130
127
|
function processCmsd(obj, options) {
|
|
@@ -141,7 +138,6 @@ function processCmsd(obj, options) {
|
|
|
141
138
|
});
|
|
142
139
|
return results;
|
|
143
140
|
}
|
|
144
|
-
|
|
145
141
|
//#endregion
|
|
146
142
|
//#region src/encodeCmsdStatic.ts
|
|
147
143
|
/**
|
|
@@ -158,7 +154,6 @@ function encodeCmsdStatic(cmsd, options) {
|
|
|
158
154
|
if (!cmsd) return "";
|
|
159
155
|
return encodeSfDict(processCmsd(cmsd, options), { whitespace: false });
|
|
160
156
|
}
|
|
161
|
-
|
|
162
157
|
//#endregion
|
|
163
158
|
//#region src/isCmsdCustomKey.ts
|
|
164
159
|
const CUSTOM_KEY_REGEX = /^[a-z][a-z0-9.-]*$/;
|
|
@@ -181,7 +176,7 @@ function isCmsdCustomKey(key) {
|
|
|
181
176
|
const separator = key.indexOf("-", 1);
|
|
182
177
|
return separator > 0 && separator < key.length - 1 && CUSTOM_KEY_REGEX.test(key);
|
|
183
178
|
}
|
|
184
|
-
|
|
185
179
|
//#endregion
|
|
186
180
|
export { CMSD_DYNAMIC, CMSD_STATIC, CMSD_V1, CmsdHeaderField, CmsdObjectType, CmsdStreamType, CmsdStreamingFormat, decodeCmsdDynamic, decodeCmsdStatic, encodeCmsdDynamic, encodeCmsdStatic, isCmsdCustomKey };
|
|
181
|
+
|
|
187
182
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/CMSD_DYNAMIC.ts","../src/CMSD_STATIC.ts","../src/CMSD_V1.ts","../src/CmsdHeaderField.ts","../src/CmsdObjectType.ts","../src/CmsdStreamingFormat.ts","../src/CmsdStreamType.ts","../src/decodeCmsdDynamic.ts","../src/decodeCmsdStatic.ts","../src/encodeCmsdDynamic.ts","../src/utils/processCmsd.ts","../src/encodeCmsdStatic.ts","../src/isCmsdCustomKey.ts"],"sourcesContent":["/**\n * CMSD dynamic header name.\n *\n * @public\n */\nexport const CMSD_DYNAMIC = 'CMSD-Dynamic'\n","/**\n * CMSD static header name.\n *\n * @public\n */\nexport const CMSD_STATIC = 'CMSD-Static'\n","/**\n * CMSD Version 1\n *\n * @public\n */\nexport const CMSD_V1 = 1\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CMSD_DYNAMIC } from './CMSD_DYNAMIC.ts'\nimport { CMSD_STATIC } from './CMSD_STATIC.ts'\n\n/**\n * CMSD header fields.\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdHeaderField = {\n\t/**\n\t * Keys whose values persist over multiple requests for the object.\n\t */\n\tSTATIC: CMSD_STATIC as typeof CMSD_STATIC,\n\n\t/**\n\t * Keys whose values apply only to the next transmission hop. Typically a\n\t * new CMSD-Dynamic header instance will be added by each intermediary\n\t * participating in the delivery.\n\t */\n\tDYNAMIC: CMSD_DYNAMIC as typeof CMSD_DYNAMIC,\n} as const\n\n/**\n * @public\n */\nexport type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;\n","import { CmObjectType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Object Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdObjectType = CmObjectType as typeof CmObjectType\n\n/**\n * @public\n */\nexport type CmsdObjectType = CmObjectType;\n","import { CmStreamingFormat } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Streaming Format\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamingFormat = CmStreamingFormat as typeof CmStreamingFormat\n\n/**\n * @public\n */\nexport type CmsdStreamingFormat = CmStreamingFormat;\n","import { CmStreamType } from '@svta/cml-cta'\n\n/**\n * Common Media Server Data Stream Type\n *\n *\n * @enum\n *\n * @public\n */\nexport const CmsdStreamType = CmStreamType as typeof CmStreamType\n\n/**\n * @public\n */\nexport type CmsdStreamType = CmStreamType;\n","import { decodeSfList } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Decode a CMSD dynamic string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdDynamic(cmsd: string): CmsdDynamic[] {\n\tif (!cmsd) {\n\t\treturn []\n\t}\n\n\tconst sfDict = decodeSfList(cmsd)\n\n\treturn sfDict as CmsdDynamic[]\n}\n","import { decodeSfDict, symbolToStr } from '@svta/cml-structured-field-values'\nimport type { CmsdStatic } from './CmsdStatic.ts'\n\n/**\n * Decode a CMSD Static dict string to an object.\n *\n * @param cmsd - The CMSD string to decode.\n *\n * @returns The decoded CMSD object.\n *\n * @public\n */\nexport function decodeCmsdStatic(cmsd: string): CmsdStatic {\n\tif (!cmsd) {\n\t\treturn {}\n\t}\n\n\treturn Object\n\t\t.entries(decodeSfDict(cmsd))\n\t\t.reduce((acc, [key, item]) => {\n\t\t\tconst { value }: any = item\n\t\t\tacc[key as any] = (typeof value === 'symbol' ? symbolToStr(value) : value) as any\n\t\t\treturn acc\n\t\t}, {} as CmsdStatic)\n}\n","import { encodeSfList, SfItem } from '@svta/cml-structured-field-values'\nimport type { CmsdDynamic } from './CmsdDynamic.ts'\n\n/**\n * Encode a list of CMSD Dynamic objects.\n *\n * @param value - The list of `SfItems` to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: SfItem[]): string;\n\n/**\n * Encode a single CMSD Dynamic object.\n *\n * @param value - The server name\n * @param cmsd - The CMSD object to encode.\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdDynamic(value: string, cmsd: CmsdDynamic): string;\n\nexport function encodeCmsdDynamic(value: string | SfItem[], cmsd?: CmsdDynamic): string {\n\tif (!value) {\n\t\treturn ''\n\t}\n\n\tif (typeof value === 'string') {\n\t\tif (!cmsd) {\n\t\t\treturn ''\n\t\t}\n\n\t\tvalue = [new SfItem(value, cmsd as any)]\n\t}\n\n\treturn encodeSfList(value, { whitespace: false })\n}\n","import type { CmValue } from '@svta/cml-cta'\nimport { isTokenField, isValid } from '@svta/cml-cta'\nimport { SfToken } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from '../CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from '../CmsdStatic.ts'\n\nexport function processCmsd(obj: CmsdStatic, options?: CmsdEncodeOptions): CmsdStatic {\n\tconst results: CmsdStatic = {}\n\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn results\n\t}\n\n\tconst keys = Object.keys(obj) as (keyof CmsdStatic)[]\n\tconst useSymbol = options?.useSymbol !== false\n\n\tkeys.forEach(key => {\n\t\tlet value = obj[key] as CmValue\n\n\t\t// Version should only be reported if not equal to 1.\n\t\tif (key === 'v' && value === 1) {\n\t\t\treturn\n\t\t}\n\n\t\t// ignore invalid values\n\t\tif (!isValid(value)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (isTokenField(key) && typeof value === 'string') {\n\t\t\tvalue = useSymbol ? Symbol.for(value) : new SfToken(value)\n\t\t}\n\n\t\tresults[key as any] = value as any\n\t})\n\n\treturn results\n}\n","import { encodeSfDict } from '@svta/cml-structured-field-values'\nimport type { CmsdEncodeOptions } from './CmsdEncodeOptions.ts'\nimport type { CmsdStatic } from './CmsdStatic.ts'\nimport { processCmsd } from './utils/processCmsd.ts'\n\n/**\n * Encode a CMSD Static object.\n *\n * @param cmsd - The CMSD object to encode.\n * @param options - Encoding options\n *\n * @returns The encoded CMSD string.\n *\n * @public\n */\nexport function encodeCmsdStatic(cmsd: CmsdStatic, options?: CmsdEncodeOptions): string {\n\tif (!cmsd) {\n\t\treturn ''\n\t}\n\n\treturn encodeSfDict(processCmsd(cmsd, options), { whitespace: false })\n}\n","// The CMSD custom-key charset restricted to RFC 8941 key serialization\n// (serializeKey): a lowercase first letter, then `a-z 0-9 . -`.\nconst CUSTOM_KEY_REGEX = /^[a-z][a-z0-9.-]*$/\n\n/**\n * Check if a key is a valid custom key: a lowercase first letter, then\n * characters from `a-z 0-9 . -`, with a hyphen that is neither the first\n * nor the last character. These are the CMSD custom-key rules restricted\n * to names that survive RFC 8941 key serialization.\n *\n * @param key - The key to check.\n *\n * @returns `true` if the key is a custom key, `false` otherwise.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/isCmsdCustomKey.test.ts#example}\n */\nexport function isCmsdCustomKey(key: string): boolean {\n\t// The separator is checked outside the regex to keep matching linear (CodeQL js/polynomial-redos).\n\tconst separator = key.indexOf('-', 1)\n\treturn separator > 0 && separator < key.length - 1 && CUSTOM_KEY_REGEX.test(key)\n}\n"],"mappings":";;;;;;;;AAKA,MAAa,eAAe;;;;;;;;ACA5B,MAAa,cAAc;;;;;;;;ACA3B,MAAa,UAAU;;;;;;;;;;;ACOvB,MAAa,kBAAkB;;;;CAI9B,QAAQ;;;;;;CAOR,SAAS;AACV;;;;;;;;;;;ACdA,MAAa,iBAAiB;;;;;;;;;;;ACA9B,MAAa,sBAAsB;;;;;;;;;;;ACAnC,MAAa,iBAAiB;;;;;;;;;;;;ACE9B,SAAgB,kBAAkB,MAA6B;CAC9D,IAAI,CAAC,MACJ,OAAO,CAAC;CAKT,OAFe,aAAa,IAEhB;AACb;;;;;;;;;;;;ACRA,SAAgB,iBAAiB,MAA0B;CAC1D,IAAI,CAAC,MACJ,OAAO,CAAC;CAGT,OAAO,OACL,QAAQ,aAAa,IAAI,CAAC,CAAC,CAC3B,QAAQ,KAAK,CAAC,KAAK,UAAU;EAC7B,MAAM,EAAE,UAAe;EACvB,IAAI,OAAe,OAAO,UAAU,WAAW,YAAY,KAAK,IAAI;EACpE,OAAO;CACR,GAAG,CAAC,CAAe;AACrB;;;ACEA,SAAgB,kBAAkB,OAA0B,MAA4B;CACvF,IAAI,CAAC,OACJ,OAAO;CAGR,IAAI,OAAO,UAAU,UAAU;EAC9B,IAAI,CAAC,MACJ,OAAO;EAGR,QAAQ,CAAC,IAAI,OAAO,OAAO,IAAW,CAAC;CACxC;CAEA,OAAO,aAAa,OAAO,EAAE,YAAY,MAAM,CAAC;AACjD;;;AClCA,SAAgB,YAAY,KAAiB,SAAyC;CACrF,MAAM,UAAsB,CAAC;CAE7B,IAAI,OAAO,QAAQ,OAAO,QAAQ,UACjC,OAAO;CAGR,MAAM,OAAO,OAAO,KAAK,GAAG;CAC5B,MAAM,YAAY,SAAS,cAAc;CAEzC,KAAK,SAAQ,QAAO;EACnB,IAAI,QAAQ,IAAI;EAGhB,IAAI,QAAQ,OAAO,UAAU,GAC5B;EAID,IAAI,CAAC,QAAQ,KAAK,GACjB;EAGD,IAAI,aAAa,GAAG,KAAK,OAAO,UAAU,UACzC,QAAQ,YAAY,OAAO,IAAI,KAAK,IAAI,IAAI,QAAQ,KAAK;EAG1D,QAAQ,OAAc;CACvB,CAAC;CAED,OAAO;AACR;;;;;;;;;;;;;ACtBA,SAAgB,iBAAiB,MAAkB,SAAqC;CACvF,IAAI,CAAC,MACJ,OAAO;CAGR,OAAO,aAAa,YAAY,MAAM,OAAO,GAAG,EAAE,YAAY,MAAM,CAAC;AACtE;;;ACnBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;AAiBzB,SAAgB,gBAAgB,KAAsB;CAErD,MAAM,YAAY,IAAI,QAAQ,KAAK,CAAC;CACpC,OAAO,YAAY,KAAK,YAAY,IAAI,SAAS,KAAK,iBAAiB,KAAK,GAAG;AAChF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svta/cml-cmsd",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Common Media Server Data (CMSD) encoding and decoding",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@svta/cml-cta": "1.0.
|
|
56
|
-
"@svta/cml-structured-field-values": "1.1.
|
|
57
|
-
"@svta/cml-utils": "1.6.
|
|
55
|
+
"@svta/cml-cta": "^1.0.10",
|
|
56
|
+
"@svta/cml-structured-field-values": "^1.1.7",
|
|
57
|
+
"@svta/cml-utils": "^1.6.2"
|
|
58
58
|
}
|
|
59
59
|
}
|