@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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # SDK 变更记录
2
2
 
3
+ ## 0.3.1
4
+
5
+ - 播放解析结果新增 `requestHeaders`,供 Host 在获取对应临时媒体地址时附加防盗链、认证或客户端请求头;请求头只保留在 Host 主进程,并按完整 URL 与到期时间隔离。
6
+
3
7
  ## 0.3.0
4
8
 
5
9
  - 正式声明 Web Surface 的 title、presentation 和 lifecycle;界面与业务由插件实现,宿主仅提供容器。
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))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shiqianjiang/ceru-plugin-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Typed authoring contracts for Ceru Music v2 single-file plugins",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",