@shiqianjiang/ceru-plugin-sdk 0.3.0 → 0.3.1
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/CHANGELOG.md +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/music.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -111,6 +111,8 @@ export type ResolveResult = {
|
|
|
111
111
|
ok: true;
|
|
112
112
|
url: string;
|
|
113
113
|
expiresAt?: number;
|
|
114
|
+
/** Headers the Host must attach while fetching this exact media URL. */
|
|
115
|
+
requestHeaders?: Record<string, string>;
|
|
114
116
|
} | {
|
|
115
117
|
ok: false;
|
|
116
118
|
error: MusicFault;
|
package/dist/music.js
CHANGED
|
@@ -61,6 +61,18 @@ export function assertResolveResult(value) {
|
|
|
61
61
|
throw new Error('Invalid playback protocol');
|
|
62
62
|
if (value.expiresAt !== undefined && !milliseconds(value.expiresAt))
|
|
63
63
|
throw new Error('Invalid playback expiry');
|
|
64
|
+
if (value.requestHeaders !== undefined) {
|
|
65
|
+
if (!record(value.requestHeaders) || Object.keys(value.requestHeaders).length > 32)
|
|
66
|
+
throw new Error('Invalid playback request headers');
|
|
67
|
+
for (const [name, headerValue] of Object.entries(value.requestHeaders)) {
|
|
68
|
+
if (!/^[!#$%&'*+.^_`|~0-9A-Za-z-]{1,128}$/.test(name) ||
|
|
69
|
+
/^(host|connection|content-length|transfer-encoding|proxy-.*|upgrade)$/i.test(name) ||
|
|
70
|
+
typeof headerValue !== 'string' ||
|
|
71
|
+
headerValue.length > 8192 ||
|
|
72
|
+
/[\r\n]/.test(headerValue))
|
|
73
|
+
throw new Error('Invalid playback request header');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
78
|
if (!record(value.error) || !text(value.error.code, 128) || !text(value.error.message, 65536))
|