@aalis/util-media-signature 0.0.0-stage → 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ace Nyan <ace@acenyan.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ /** 可发送的附件类型。 */
2
+ export type MediaKind = 'image' | 'audio' | 'video';
3
+ /** 文件头认出的媒体格式:所属类型与格式名(如 PNG、M4A、MKV)。 */
4
+ export interface MediaFormat {
5
+ kind: MediaKind;
6
+ format: string;
7
+ }
8
+ /**
9
+ * 认定格式要读的文件头长度:与 file(1) 在前 4 KiB 里找 Matroska DocType 的范围一致,也容得下 ftyp 盒的
10
+ * 兼容品牌表;其余签名都在前 20 字节内。
11
+ */
12
+ export declare const MEDIA_HEAD_BYTES = 4096;
13
+ /** 按文件头认定媒体格式;不是签名表里任何一种格式时返回 null。 */
14
+ export declare function detectMediaFormat(head: Uint8Array): MediaFormat | null;
15
+ /**
16
+ * 核对文件头是否为所请求 kind 的受支持格式。相符返回 null;不符返回给模型的拒发说明:
17
+ * 不是任何受支持的媒体格式时说明不能按该类型发送,是别类媒体时说出检测到的格式与该用的 kind。
18
+ */
19
+ export declare function checkMediaHead(head: Uint8Array, kind: MediaKind): string | null;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,gBAAgB;AAChB,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEpD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAoDrC,uCAAuC;AACvC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAGtE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAY/E"}
package/dist/index.js ADDED
@@ -0,0 +1,160 @@
1
+ // ============================================================
2
+ // @aalis/util-media-signature — 按文件头认定媒体格式
3
+ //
4
+ // 存储根里除了媒体,还有配置、令牌、记忆库、日志;只凭 kind 与路径发送,
5
+ // 这些文件会被当成图片发出去。发送附件的一方先读文件开头的字节,按下表的
6
+ // 格式签名认定格式,再决定放行、换一种方式发送还是拒发。
7
+ // 签名依据各格式的规范,并与 file(1) 的 magic 库对照(SILK 不在该库里)。
8
+ // 纯函数、无依赖,只用 Uint8Array。
9
+ // ============================================================
10
+ /**
11
+ * 认定格式要读的文件头长度:与 file(1) 在前 4 KiB 里找 Matroska DocType 的范围一致,也容得下 ftyp 盒的
12
+ * 兼容品牌表;其余签名都在前 20 字节内。
13
+ */
14
+ export const MEDIA_HEAD_BYTES = 4096;
15
+ const KIND_LABEL = { image: '图片', audio: '音频', video: '视频' };
16
+ /** BMP 偏移 14 处 DIB 头长度的合法取值(file(1) 认的各版本);只有 'BM' 两字节太弱,文本也可能以它开头。 */
17
+ const BMP_DIB_HEADER_SIZES = new Set([12, 16, 24, 40, 48, 52, 56, 64, 108, 124]);
18
+ /** AMR 文件存储格式的魔数:单声道窄带、宽带与各自的多声道版本(RFC 4867 §5)。 */
19
+ const AMR_MAGICS = ['#!AMR\n', '#!AMR-WB\n', '#!AMR_MC1.0\n', '#!AMR-WB_MC1.0\n'];
20
+ const AVIF_BRANDS = new Set(['avif', 'avis']);
21
+ /** HEIF 的图片与图片序列品牌(ISO/IEC 23008-12):HEVC 编码的 heic 系与通用的 mif1、msf1。 */
22
+ const HEIF_BRANDS = new Set(['heic', 'heix', 'heim', 'heis', 'hevc', 'hevx', 'hevm', 'hevs', 'mif1', 'msf1']);
23
+ const M4A_BRANDS = new Set(['M4A ', 'M4B ', 'M4P ']);
24
+ const SIGNATURES = [
25
+ { kind: 'image', format: 'PNG', matches: h => hasBytes(h, 0, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]) },
26
+ // SOI 标记 FFD8 之后紧跟下一个标记的 FF
27
+ { kind: 'image', format: 'JPEG', matches: h => hasBytes(h, 0, [0xff, 0xd8, 0xff]) },
28
+ { kind: 'image', format: 'GIF', matches: h => hasAscii(h, 0, 'GIF87a') || hasAscii(h, 0, 'GIF89a') },
29
+ { kind: 'image', format: 'WebP', matches: h => isRiff(h, 'WEBP') },
30
+ {
31
+ kind: 'image',
32
+ format: 'BMP',
33
+ matches: h => hasAscii(h, 0, 'BM') && h.length >= 18 && BMP_DIB_HEADER_SIZES.has(readUint32LE(h, 14)),
34
+ },
35
+ { kind: 'image', format: 'AVIF', matches: h => isoMediaFormat(h) === 'AVIF' },
36
+ { kind: 'image', format: 'HEIC', matches: h => isoMediaFormat(h) === 'HEIC' },
37
+ { kind: 'audio', format: 'MP3', matches: h => isId3v2(h) || isMp3Frame(h) },
38
+ { kind: 'audio', format: 'WAV', matches: h => isRiff(h, 'WAVE') },
39
+ // 页头捕获模式 'OggS' 加结构版本 0(RFC 3533)
40
+ { kind: 'audio', format: 'OGG', matches: h => hasBytes(h, 0, [0x4f, 0x67, 0x67, 0x53, 0x00]) },
41
+ { kind: 'audio', format: 'FLAC', matches: h => hasAscii(h, 0, 'fLaC') },
42
+ { kind: 'audio', format: 'AMR', matches: h => AMR_MAGICS.some(m => hasAscii(h, 0, m)) },
43
+ // QQ 语音的 SILK 前面可能多一个 0x02
44
+ {
45
+ kind: 'audio',
46
+ format: 'SILK',
47
+ matches: h => hasAscii(h, 0, '#!SILK_V3') || (h[0] === 0x02 && hasAscii(h, 1, '#!SILK_V3')),
48
+ },
49
+ { kind: 'audio', format: 'M4A', matches: h => isoMediaFormat(h) === 'M4A' },
50
+ { kind: 'video', format: 'MP4', matches: h => isoMediaFormat(h) === 'MP4' },
51
+ { kind: 'video', format: 'MOV', matches: h => isoMediaFormat(h) === 'MOV' },
52
+ { kind: 'video', format: 'WebM', matches: h => ebmlDocType(h) === 'webm' },
53
+ { kind: 'video', format: 'MKV', matches: h => ebmlDocType(h) === 'matroska' },
54
+ { kind: 'video', format: 'AVI', matches: h => isRiff(h, 'AVI ') },
55
+ ];
56
+ /** 按文件头认定媒体格式;不是签名表里任何一种格式时返回 null。 */
57
+ export function detectMediaFormat(head) {
58
+ const detected = SIGNATURES.find(s => s.matches(head));
59
+ return detected ? { kind: detected.kind, format: detected.format } : null;
60
+ }
61
+ /**
62
+ * 核对文件头是否为所请求 kind 的受支持格式。相符返回 null;不符返回给模型的拒发说明:
63
+ * 不是任何受支持的媒体格式时说明不能按该类型发送,是别类媒体时说出检测到的格式与该用的 kind。
64
+ */
65
+ export function checkMediaHead(head, kind) {
66
+ const detected = detectMediaFormat(head);
67
+ if (!detected) {
68
+ const supported = SIGNATURES.filter(s => s.kind === kind)
69
+ .map(s => s.format)
70
+ .join('、');
71
+ return `文件不是受支持的${KIND_LABEL[kind]}格式(${supported}),不能按 ${kind} 发送`;
72
+ }
73
+ if (detected.kind !== kind) {
74
+ return `文件是 ${detected.format} ${KIND_LABEL[detected.kind]},不能按 ${kind} 发送;请改用 kind=${detected.kind} 重新发送`;
75
+ }
76
+ return null;
77
+ }
78
+ /**
79
+ * ISO 基础媒体文件(ISO/IEC 14496-12)按 ftyp 盒的品牌分类。AVIF 与 HEIF 在主品牌与兼容品牌里都找:
80
+ * AVIF 文件的主品牌也可能写 mif1,avif 只列在兼容品牌里。M4A 与 MOV 只看主品牌:iTunes 的 M4V 视频
81
+ * 会把 'M4A ' 列进兼容品牌。其余品牌(isom、mp41、mp42、3gp 系等)都归 MP4 家族的视频容器。
82
+ */
83
+ function isoMediaFormat(h) {
84
+ if (h.length < 12 || !hasAscii(h, 4, 'ftyp'))
85
+ return null;
86
+ const major = ascii(h, 8, 4);
87
+ const boxEnd = Math.min(readUint32BE(h, 0), h.length);
88
+ const brands = [major];
89
+ for (let offset = 16; offset + 4 <= boxEnd; offset += 4)
90
+ brands.push(ascii(h, offset, 4));
91
+ if (brands.some(b => AVIF_BRANDS.has(b)))
92
+ return 'AVIF';
93
+ if (brands.some(b => HEIF_BRANDS.has(b)))
94
+ return 'HEIC';
95
+ if (M4A_BRANDS.has(major))
96
+ return 'M4A';
97
+ if (major === 'qt ')
98
+ return 'MOV';
99
+ return 'MP4';
100
+ }
101
+ /**
102
+ * Matroska 与 WebM 同为 EBML 容器(魔数 1A45DFA3),靠 DocType 元素(ID 0x4282)区分:
103
+ * 与 file(1) 一样在文件头里找到它,跳过一字节长度后比对。
104
+ */
105
+ function ebmlDocType(h) {
106
+ if (!hasBytes(h, 0, [0x1a, 0x45, 0xdf, 0xa3]))
107
+ return null;
108
+ for (let i = 4; i + 1 < h.length; i++) {
109
+ if (h[i] !== 0x42 || h[i + 1] !== 0x82)
110
+ continue;
111
+ if (hasAscii(h, i + 3, 'webm'))
112
+ return 'webm';
113
+ if (hasAscii(h, i + 3, 'matroska'))
114
+ return 'matroska';
115
+ return null;
116
+ }
117
+ return null;
118
+ }
119
+ /** ID3v2 标签:'ID3' 后接主版本号(现有 2、3、4 三版)与不为 FF 的修订号。 */
120
+ function isId3v2(h) {
121
+ return hasAscii(h, 0, 'ID3') && h.length >= 5 && h[3] >= 2 && h[3] <= 4 && h[4] !== 0xff;
122
+ }
123
+ /** MPEG 音频帧头:11 位同步,版本不为保留值 01,层为 Layer III(01),码率索引不为 1111,采样率索引不为 11。 */
124
+ function isMp3Frame(h) {
125
+ if (h.length < 3 || h[0] !== 0xff || (h[1] & 0xe0) !== 0xe0)
126
+ return false;
127
+ const version = (h[1] >> 3) & 0x03;
128
+ const layer = (h[1] >> 1) & 0x03;
129
+ const bitrateIndex = h[2] >> 4;
130
+ const sampleRateIndex = (h[2] >> 2) & 0x03;
131
+ return version !== 0x01 && layer === 0x01 && bitrateIndex !== 0x0f && sampleRateIndex !== 0x03;
132
+ }
133
+ /** RIFF 容器:'RIFF' 加 4 字节长度,偏移 8 处是形式类型(WAVE、AVI 、WEBP)。 */
134
+ function isRiff(h, formType) {
135
+ return hasAscii(h, 0, 'RIFF') && hasAscii(h, 8, formType);
136
+ }
137
+ function hasBytes(h, offset, bytes) {
138
+ if (h.length < offset + bytes.length)
139
+ return false;
140
+ return bytes.every((b, i) => h[offset + i] === b);
141
+ }
142
+ function hasAscii(h, offset, text) {
143
+ if (h.length < offset + text.length)
144
+ return false;
145
+ for (let i = 0; i < text.length; i++) {
146
+ if (h[offset + i] !== text.charCodeAt(i))
147
+ return false;
148
+ }
149
+ return true;
150
+ }
151
+ function ascii(h, offset, length) {
152
+ return String.fromCharCode(...h.subarray(offset, offset + length));
153
+ }
154
+ function readUint32BE(h, offset) {
155
+ return ((h[offset] << 24) | (h[offset + 1] << 16) | (h[offset + 2] << 8) | h[offset + 3]) >>> 0;
156
+ }
157
+ function readUint32LE(h, offset) {
158
+ return (h[offset] | (h[offset + 1] << 8) | (h[offset + 2] << 16) | (h[offset + 3] << 24)) >>> 0;
159
+ }
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,2CAA2C;AAC3C,EAAE;AACF,yCAAyC;AACzC,sCAAsC;AACtC,8BAA8B;AAC9B,iDAAiD;AACjD,yBAAyB;AACzB,+DAA+D;AAW/D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,MAAM,UAAU,GAA8B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAExF,uEAAuE;AACvE,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACjF,oDAAoD;AACpD,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;AAClF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9C,uEAAuE;AACvE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9G,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAQr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AC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAClG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@aalis/util-media-signature",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/AalisLabs/Aalis.git",
8
+ "directory": "packages/util-media-signature"
9
+ },
10
+ "author": "Ace Nyan <ace@acenyan.com>",
11
+ "bugs": {
12
+ "url": "https://github.com/AalisLabs/Aalis/issues"
13
+ },
14
+ "homepage": "https://github.com/AalisLabs/Aalis#readme",
15
+ "description": "媒体文件头签名:按文件开头的字节认定图片、音频、视频格式,纯函数无依赖",
16
+ "type": "module",
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "devDependencies": {
23
+ "typescript": "^5.7.0"
24
+ },
25
+ "keywords": [
26
+ "aalis",
27
+ "aalis-util"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "dev": "tsc --watch"
32
+ }
6
33
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.