angelia-gateway 0.3.20 → 0.3.22

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.
Files changed (137) hide show
  1. package/README.md +12 -3
  2. package/dist/build.json +3 -3
  3. package/dist/cli/cli.js +5 -0
  4. package/dist/daemon/daemon.js +26 -2
  5. package/dist/daemon/node-fix.js +46 -0
  6. package/dist/daemon/service.js +30 -9
  7. package/dist/daemon/update.js +26 -0
  8. package/install.sh +8 -7
  9. package/node_modules/music-metadata/README.md +35 -32
  10. package/node_modules/music-metadata/lib/ParserFactory.d.ts +1 -1
  11. package/node_modules/music-metadata/lib/ParserFactory.js +17 -13
  12. package/node_modules/music-metadata/lib/aiff/AiffParser.js +19 -12
  13. package/node_modules/music-metadata/lib/aiff/AiffToken.d.ts +1 -1
  14. package/node_modules/music-metadata/lib/aiff/AiffToken.js +2 -1
  15. package/node_modules/music-metadata/lib/apev2/APEv2Parser.d.ts +4 -3
  16. package/node_modules/music-metadata/lib/apev2/APEv2Parser.js +59 -16
  17. package/node_modules/music-metadata/lib/apev2/APEv2TagMapper.js +1 -0
  18. package/node_modules/music-metadata/lib/apev2/APEv2Token.d.ts +1 -1
  19. package/node_modules/music-metadata/lib/apev2/APEv2Token.js +1 -1
  20. package/node_modules/music-metadata/lib/asf/AsfGuid.js +56 -50
  21. package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -1
  22. package/node_modules/music-metadata/lib/asf/AsfObject.js +3 -2
  23. package/node_modules/music-metadata/lib/asf/AsfParser.js +15 -7
  24. package/node_modules/music-metadata/lib/asf/AsfTagMapper.d.ts +3 -2
  25. package/node_modules/music-metadata/lib/asf/AsfTagMapper.js +21 -4
  26. package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
  27. package/node_modules/music-metadata/lib/common/CombinedTagMapper.d.ts +2 -2
  28. package/node_modules/music-metadata/lib/common/CombinedTagMapper.js +6 -6
  29. package/node_modules/music-metadata/lib/common/FourCC.js +3 -2
  30. package/node_modules/music-metadata/lib/common/GenericTagMapper.d.ts +1 -1
  31. package/node_modules/music-metadata/lib/common/GenericTagTypes.js +1 -1
  32. package/node_modules/music-metadata/lib/common/MetadataCollector.d.ts +3 -1
  33. package/node_modules/music-metadata/lib/common/MetadataCollector.js +28 -9
  34. package/node_modules/music-metadata/lib/common/Util.js +25 -17
  35. package/node_modules/music-metadata/lib/core.d.ts +4 -4
  36. package/node_modules/music-metadata/lib/core.js +18 -11
  37. package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.js +29 -16
  38. package/node_modules/music-metadata/lib/dsf/DsfChunk.d.ts +1 -1
  39. package/node_modules/music-metadata/lib/dsf/DsfParser.js +3 -5
  40. package/node_modules/music-metadata/lib/ebml/EbmlIterator.d.ts +1 -1
  41. package/node_modules/music-metadata/lib/ebml/EbmlIterator.js +35 -6
  42. package/node_modules/music-metadata/lib/ebml/types.d.ts +1 -1
  43. package/node_modules/music-metadata/lib/ebml/types.js +1 -1
  44. package/node_modules/music-metadata/lib/flac/FlacParser.d.ts +1 -1
  45. package/node_modules/music-metadata/lib/flac/FlacParser.js +6 -5
  46. package/node_modules/music-metadata/lib/flac/FlacToken.d.ts +1 -1
  47. package/node_modules/music-metadata/lib/flac/FlacToken.js +1 -1
  48. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.d.ts +1 -1
  49. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +212 -42
  50. package/node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js +5 -5
  51. package/node_modules/music-metadata/lib/id3v2/FrameHeader.d.ts +1 -1
  52. package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +8 -5
  53. package/node_modules/music-metadata/lib/id3v2/FrameParser.d.ts +2 -1
  54. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +54 -23
  55. package/node_modules/music-metadata/lib/id3v2/ID3v22TagMapper.d.ts +1 -1
  56. package/node_modules/music-metadata/lib/id3v2/ID3v22TagMapper.js +1 -1
  57. package/node_modules/music-metadata/lib/id3v2/ID3v24TagMapper.js +3 -3
  58. package/node_modules/music-metadata/lib/id3v2/ID3v2ChapterToken.js +2 -2
  59. package/node_modules/music-metadata/lib/id3v2/ID3v2Parser.d.ts +1 -1
  60. package/node_modules/music-metadata/lib/id3v2/ID3v2Parser.js +32 -16
  61. package/node_modules/music-metadata/lib/id3v2/ID3v2Token.d.ts +2 -2
  62. package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +2 -3
  63. package/node_modules/music-metadata/lib/index.js +6 -3
  64. package/node_modules/music-metadata/lib/lrc/LyricsParser.js +3 -5
  65. package/node_modules/music-metadata/lib/matroska/MatroskaDtd.js +7 -3
  66. package/node_modules/music-metadata/lib/matroska/MatroskaParser.js +22 -11
  67. package/node_modules/music-metadata/lib/matroska/types.d.ts +2 -2
  68. package/node_modules/music-metadata/lib/mp4/Atom.d.ts +4 -3
  69. package/node_modules/music-metadata/lib/mp4/Atom.js +44 -11
  70. package/node_modules/music-metadata/lib/mp4/AtomToken.d.ts +1 -1
  71. package/node_modules/music-metadata/lib/mp4/AtomToken.js +30 -8
  72. package/node_modules/music-metadata/lib/mp4/MP4Parser.d.ts +2 -0
  73. package/node_modules/music-metadata/lib/mp4/MP4Parser.js +79 -54
  74. package/node_modules/music-metadata/lib/mp4/MP4TagMapper.d.ts +2 -2
  75. package/node_modules/music-metadata/lib/mpeg/MpegLoader.js +1 -1
  76. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +41 -19
  77. package/node_modules/music-metadata/lib/mpeg/ReplayGainDataFormat.d.ts +2 -2
  78. package/node_modules/music-metadata/lib/mpeg/ReplayGainDataFormat.js +1 -1
  79. package/node_modules/music-metadata/lib/mpeg/XingTag.d.ts +1 -1
  80. package/node_modules/music-metadata/lib/musepack/MusepackParser.js +2 -2
  81. package/node_modules/music-metadata/lib/musepack/sv7/BitReader.js +1 -1
  82. package/node_modules/music-metadata/lib/musepack/sv7/MpcSv7Parser.js +4 -3
  83. package/node_modules/music-metadata/lib/musepack/sv7/StreamVersion7.js +3 -3
  84. package/node_modules/music-metadata/lib/musepack/sv8/MpcSv8Parser.js +7 -5
  85. package/node_modules/music-metadata/lib/musepack/sv8/StreamVersion8.js +2 -2
  86. package/node_modules/music-metadata/lib/ogg/OggParser.js +23 -13
  87. package/node_modules/music-metadata/lib/ogg/OggToken.d.ts +2 -0
  88. package/node_modules/music-metadata/lib/ogg/OggToken.js +1 -1
  89. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.d.ts +2 -2
  90. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.js +2 -2
  91. package/node_modules/music-metadata/lib/ogg/opus/OpusStream.d.ts +2 -2
  92. package/node_modules/music-metadata/lib/ogg/opus/OpusStream.js +8 -4
  93. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +2 -2
  94. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +2 -1
  95. package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.d.ts +2 -2
  96. package/node_modules/music-metadata/lib/ogg/vorbis/Vorbis.d.ts +1 -1
  97. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js +1 -1
  98. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.d.ts +4 -3
  99. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js +16 -9
  100. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisTagMapper.js +4 -0
  101. package/node_modules/music-metadata/lib/riff/RiffChunk.d.ts +3 -1
  102. package/node_modules/music-metadata/lib/riff/RiffChunk.js +3 -2
  103. package/node_modules/music-metadata/lib/riff/RiffInfoTagMap.d.ts +1 -1
  104. package/node_modules/music-metadata/lib/type.d.ts +3 -3
  105. package/node_modules/music-metadata/lib/type.js +1 -1
  106. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +1 -1
  107. package/node_modules/music-metadata/lib/wav/WaveChunk.js +3 -2
  108. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +6 -2
  109. package/node_modules/music-metadata/lib/wav/WaveParser.js +75 -22
  110. package/node_modules/music-metadata/lib/wavpack/WavPackParser.js +22 -13
  111. package/node_modules/music-metadata/lib/wavpack/WavPackToken.js +3 -2
  112. package/node_modules/music-metadata/package.json +3 -2
  113. package/node_modules/zod/package.json +1 -1
  114. package/node_modules/zod/src/v4/classic/schemas.ts +2 -1
  115. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  116. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  117. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +19 -0
  118. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  119. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  120. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  121. package/node_modules/zod/src/v4/core/util.ts +13 -0
  122. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  123. package/node_modules/zod/v4/classic/schemas.d.cts +3 -1
  124. package/node_modules/zod/v4/classic/schemas.d.ts +3 -1
  125. package/node_modules/zod/v4/core/compile.cjs +8 -0
  126. package/node_modules/zod/v4/core/compile.js +8 -0
  127. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  128. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  129. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  130. package/node_modules/zod/v4/core/schemas.js +30 -0
  131. package/node_modules/zod/v4/core/util.cjs +15 -0
  132. package/node_modules/zod/v4/core/util.d.cts +2 -0
  133. package/node_modules/zod/v4/core/util.d.ts +2 -0
  134. package/node_modules/zod/v4/core/util.js +14 -0
  135. package/node_modules/zod/v4/core/versions.cjs +1 -1
  136. package/node_modules/zod/v4/core/versions.js +1 -1
  137. package/package.json +3 -3
package/README.md CHANGED
@@ -31,7 +31,7 @@ Angelia runs no model of its own. It carries messages, files and approvals betwe
31
31
  <tr><td><b>One chat, one folder</b></td><td>Each topic gets its own folder and memory, each chat its own session: the house, money, a side project. Instruction files, settings, MCP servers and hooks work exactly as in your terminal.</td></tr>
32
32
  <tr><td><b>You approve risky steps</b></td><td>Before a command the profile does not allow on its own, the chat shows it and waits for your <code>yes</code>. No answer means no.</td></tr>
33
33
  <tr><td><b>Voice, photos and files</b></td><td>Send a voice note, a photo or a PDF; get files and voice notes back. Speech is turned into text and back on your machine.</td></tr>
34
- <tr><td><b>New chat, new assistant</b></td><td>Mention the bot in a new group and it sets up its own folder, then asks what the group is for.</td></tr>
34
+ <tr><td><b>New chat, new assistant</b></td><td>Mention the bot in a new group (or just write there, with <code>onboard.mention: any</code>) and it sets up its own folder, then asks what the group is for.</td></tr>
35
35
  <tr><td><b>Scheduled check-ins</b></td><td>A morning summary, a weekly report. Your operating system runs the timer; the answer lands in the chat.</td></tr>
36
36
  <tr><td><b>Safe by default</b></td><td>Every profile is compiled with deny rules for your credentials and the other profiles' folders, and one whose rules were loosened is not started. Releases are signed, and the installer checks them.</td></tr>
37
37
  <tr><td><b>No new bill</b></td><td>No second model, no Angelia server, no telemetry. API keys are kept out of the agent's environment, so no chat can move you to per-token billing.</td></tr>
@@ -51,9 +51,18 @@ https://github.com/user-attachments/assets/2532dfea-d4f9-4d07-830d-d1fa084e0690
51
51
 
52
52
  The installer checks Node, fetches the newest release, **verifies its signature** (release keys `SHA256:74hZgwt/ABiUQz6C9A1r7hpHZtCRq1KfC1KvvCR1ys0` and, for releases the release workflow signs, `SHA256:+9Y9DX+JEDqt5Kxkfr83lQ/cKdo1E2pPgQT10ssc5Lw`), installs it and starts the setup wizard. The wizard asks for a bot token and which CLI to use, makes your first profile, and pairs the chat when you send the bot a message.
53
53
 
54
+ Or with npm, the same package the installer builds:
55
+
56
+ ```bash
57
+ npm install -g --ignore-scripts angelia-gateway
58
+ angelia init
59
+ ```
60
+
61
+ npm only warns (EBADENGINE) about a Node without the fix and installs anyway, so check `node --version` against the versions below first. npm does not check the release signature the way the installer does; from 0.3.21 on, each release on npm is published by the release workflow with npm provenance (`npm audit signatures` checks it).
62
+
54
63
  You need:
55
64
 
56
- - **Node 22 or newer** and **git** (it comes with the Xcode command line tools).
65
+ - **Node 22.23.4+, 24.22.1+ or 26.12.1+** and **git** (it comes with the Xcode command line tools).
57
66
  - **A supported coding agent CLI**, installed and signed in to your own account. See [Backends](#backends).
58
67
  - **A Telegram bot.** Open [@BotFather](https://t.me/BotFather), send `/newbot` and keep the token ready. It is stored on your disk, never in a chat.
59
68
  - Optional: `brew install openai-whisper ffmpeg` for voice notes, and `brew install tmux` (3.7+) to run a Claude Code profile in its full screen, so the chat also shows up in the Claude app.
@@ -113,7 +122,7 @@ routes:
113
122
  telegram: { token_env: TELEGRAM_BOT_TOKEN }
114
123
  ```
115
124
 
116
- The wizard writes this file for you, in `~/.angelia/workspace/routing.yaml`. With onboarding on, a new chat adds its own profile and route the first time you mention the bot there.
125
+ The wizard writes this file for you, in `~/.angelia/workspace/routing.yaml`. With onboarding on, a new chat adds its own profile and route the first time you mention the bot there; with `onboard.mention: any`, your first message there is enough.
117
126
 
118
127
  ---
119
128
 
package/dist/build.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "commit": "3b35047f516338052aabd4e239b4eb75cf69fb91",
2
+ "commit": "a0cb9cf5574c28c6f27c5d5f06801a549335e9b8",
3
3
  "dirty": false,
4
- "built": "2026-10-10T19:05:00.125Z",
5
- "tag": "v0.3.20"
4
+ "built": "2026-10-27T08:48:05.050Z",
5
+ "tag": "v0.3.22"
6
6
  }
package/dist/cli/cli.js CHANGED
@@ -15,6 +15,7 @@ import { checkArgs, usageLines } from './cli-args.js';
15
15
  import { parseSessionKey } from '../core/types.js';
16
16
  import { readFileSync } from 'node:fs';
17
17
  import { packageRoot, readBuild } from '../daemon/update.js';
18
+ import { nodeFixProblem } from '../daemon/node-fix.js';
18
19
  const [cmd, ...rest] = process.argv.slice(2);
19
20
  /** Asked for: exit 0. Reached by an unknown command: exit 2, so a typo in a script fails loudly. */
20
21
  function usage(code = 2) {
@@ -60,6 +61,10 @@ try {
60
61
  const overridden = selfOverrideWarning();
61
62
  if (overridden)
62
63
  warnings.push(overridden);
64
+ // The Node running this check, which is the one `angelia daemon` from this shell would run on.
65
+ const open = nodeFixProblem(process.versions.node, process.execPath);
66
+ if (open)
67
+ warnings.push(open);
63
68
  // Read only: a table nobody accepted yet is the daemon's to record at its next start.
64
69
  try {
65
70
  const { pending } = effectiveTable(cfg, STATE_DIR);
@@ -2,7 +2,7 @@ import { isDaemonPid, pidAlive } from './pid.js';
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import { chmodSync, existsSync, readFileSync, renameSync, writeFileSync, mkdirSync, unlinkSync, appendFileSync, statSync } from 'node:fs';
4
4
  import { workspaceDir } from '../instance/instance.js';
5
- import { join, resolve } from 'node:path';
5
+ import { isAbsolute, join, resolve } from 'node:path';
6
6
  import { homedir } from 'node:os';
7
7
  import { loadConfig, configWarnings } from '../instance/config/load.js';
8
8
  import { effectiveTable, writeAccepted } from '../instance/accepted.js';
@@ -24,6 +24,8 @@ import { launchChatRestart, takeRestartNote } from './restart.js';
24
24
  import { onboardChat } from '../instance/onboard.js';
25
25
  import { apiDeps } from './api/deps.js';
26
26
  import { switchBackend as switchProfileBackend } from '../instance/switch-backend.js';
27
+ import { nodeAdvice, nodeFixProblem } from './node-fix.js';
28
+ import { LABEL } from './service.js';
27
29
  export const STATE_DIR = process.env.ANGELIA_STATE_DIR ?? join(homedir(), '.angelia');
28
30
  /** `~/.angelia/env`: the bot token and the secrets capabilities name. See core/env.ts. */
29
31
  export function envFile(stateDir = STATE_DIR) {
@@ -85,6 +87,10 @@ export async function runDaemon(configPath) {
85
87
  logLine(`daemon.pid named pid ${old}, which is not a running angelia daemon (left by a crash?); replaced`);
86
88
  }
87
89
  writeFileSync(pidFile, String(process.pid));
90
+ // A warning, not a refusal: refusing would take every chat down, and the fix is the owner's to install.
91
+ const started = nodeStart(), open = nodeFixProblem(process.versions.node, process.execPath);
92
+ if (open)
93
+ logLine(`WARNING: ${open}. This process decodes what Telegram and WhatsApp send: ${nodeAdvice(started, started !== undefined)}.`);
88
94
  // Held in memory, never copied into process.env: everything this process starts inherits that.
89
95
  const secrets = envFile();
90
96
  // The daemon runs on the table the owner accepted (instance/accepted.ts): changes an agent could have
@@ -228,7 +234,7 @@ export async function runDaemon(configPath) {
228
234
  let telegram;
229
235
  const tgState = () => telegram?.state ?? 'off';
230
236
  let waState = 'off';
231
- const statusNow = () => ({ pid: process.pid, at: new Date().toISOString(), config: resolve(configPath), tg: tgState(), wa: waState, sessions: orch.status() });
237
+ const statusNow = () => ({ pid: process.pid, at: new Date().toISOString(), config: resolve(configPath), node: process.versions.node, nodePath: process.execPath, nodeStart: started, tg: tgState(), wa: waState, sessions: orch.status() });
232
238
  const api = new ApiServer(apiDeps(orch, cfg, statusNow, STATE_DIR), apiToken);
233
239
  const socket = join(STATE_DIR, API_SOCKET);
234
240
  await claimSocket(socket);
@@ -320,6 +326,22 @@ export async function runDaemon(configPath) {
320
326
  process.on('uncaughtException', (err) => logLine(`uncaught exception: ${err.message}`));
321
327
  await new Promise(() => { });
322
328
  }
329
+ /** The plist's node path when launchd started this daemon (launchd passes it as argv[0] and names the
330
+ * job in XPC_SERVICE_NAME, which its children inherit, so the parent must be launchd too): it decides whether a new Node reaches the daemon by a restart or needs the
331
+ * plist written again. Without the service there is no plist to point anywhere, so nothing. process.execPath
332
+ * is no use here: it is always the real binary, a versioned folder even when the plist names a link
333
+ * that follows upgrades, and `angelia restart` spawns that same binary. */
334
+ export function nodeStart(argv0 = process.argv0, service = process.ppid === 1 && process.env.XPC_SERVICE_NAME === LABEL) {
335
+ return service && isAbsolute(argv0) ? argv0 : undefined;
336
+ }
337
+ /** status's line about the daemon's Node, from what status.json recorded: fine, unknown, or what is wrong with it. */
338
+ export function nodeLine(s) {
339
+ if (typeof s.node !== 'string')
340
+ return "daemon's Node unknown (started before this version); angelia restart records it";
341
+ const path = typeof s.nodePath === 'string' ? s.nodePath : undefined;
342
+ const open = nodeFixProblem(s.node, path);
343
+ return open ? `warning: ${open}; ${nodeAdvice(typeof s.nodeStart === 'string' ? s.nodeStart : undefined, typeof s.nodeStart === 'string')}` : `node ${s.node}${path ? ` at ${path}` : ''} (has the CVE-2026-111497 fix)`;
344
+ }
323
345
  export function readStatus() {
324
346
  const p = join(STATE_DIR, 'status.json');
325
347
  if (!existsSync(p))
@@ -327,6 +349,8 @@ export function readStatus() {
327
349
  const s = JSON.parse(readFileSync(p, 'utf8'));
328
350
  const alive = pidAlive(Number(s.pid));
329
351
  const lines = [`daemon pid ${s.pid} ${alive ? 'alive' : 'DEAD'} · written ${s.at}`, `telegram: ${s.tg} · whatsapp: ${s.wa}`];
352
+ // The daemon's own Node, which launchd picks from the plist: not always the one this command runs on.
353
+ lines.push(nodeLine(s));
330
354
  for (const x of s.sessions ?? [])
331
355
  lines.push(` ${x.key} ${x.alive ? 'warm' : 'cold'} queued=${x.queued}`);
332
356
  return lines.join('\n');
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Node2Shell (CVE-2026-111497): an out-of-bounds write in Node's Brotli decoder, remote code execution
3
+ * from a response body. The daemon decodes untrusted HTTP all day (Telegram's API through fetch and
4
+ * grammy, WhatsApp media through Baileys), so the runtime under it matters as much as the code.
5
+ * Fixed in 22.23.4, 24.22.1 and 26.12.1; 23, 25 and older lines get no fix. npm's `engines` only
6
+ * warns (EBADENGINE), so the places that can say so check it themselves: update and the daemon's start
7
+ * log a warning, status and check-config print a line. Only install.sh refuses, at the first install;
8
+ * past it, a refusal would not take the daemon off its Node, and would keep Angelia's own fixes out.
9
+ */
10
+ /** The versions with the fix, as a person reads them. The same words as the README and install.sh. */
11
+ export const NODE_FIX = 'Node 22.23.4+, 24.22.1+ or 26.12.1+';
12
+ /**
13
+ * install.sh's rule, read the same way (a test runs both over one table). Accepted: exactly three
14
+ * dot-separated runs of digits (`^\d+\.\d+\.\d+$`), and then a major above 26, or 22, 24 or 26 at or
15
+ * past its fix. Everything else is refused before the numbers are compared: a prerelease of the fix
16
+ * (`26.12.1-rc.1`, which is not the release that carries it), a leading `v` or space, a short `27`,
17
+ * and what Number() would read as a large major (`Infinity`, `1e2.0.0`).
18
+ */
19
+ export function nodeHasFix(version = process.versions.node) {
20
+ if (!/^\d+\.\d+\.\d+$/.test(version))
21
+ return false;
22
+ const [a, b, c] = version.split('.').map(Number), f = { 22: [23, 4], 24: [22, 1], 26: [12, 1] }[a];
23
+ return a > 26 || (!!f && (b > f[0] || (b === f[0] && c >= f[1])));
24
+ }
25
+ /** What is wrong with this Node, or undefined when it has the fix. `path`, when given, says which binary. */
26
+ export function nodeFixProblem(version = process.versions.node, path) {
27
+ return nodeHasFix(version) ? undefined : `Node ${version || '(no version)'}${path ? ` at ${path}` : ''} is open to CVE-2026-111497 (Node2Shell, remote code execution through the Brotli decoder); ${NODE_FIX} has the fix`;
28
+ }
29
+ /**
30
+ * Whether a node path stays on one version, so a fixed Node installed later never lands there.
31
+ * stableNode() (service.ts) writes the PATH link into the plist when it resolves to the node that
32
+ * runs, and the real path otherwise: for nvm, fnm, asdf, Volta, Homebrew's Cellar or an unpacked
33
+ * tarball, a folder named after the version (fnm's per-shell links go away besides).
34
+ */
35
+ export function versionedNode(path) {
36
+ return /\/[^/]*\d+\.\d+\.\d+[^/]*\/|\/fnm_multishells\//.test(path);
37
+ }
38
+ /** What the owner does about a Node without the fix, when the daemon starts as `path`: a path that
39
+ * stays on its version needs the plist written again, or launchd keeps starting the old Node. */
40
+ export function nodeAdvice(path, service = true) {
41
+ if (path && versionedNode(path))
42
+ return `install a fixed Node, then angelia service install <routing.yaml> so the service starts it (${path} stays on this version)`;
43
+ // Under launchd a restart starts the plist's node; without it, restart reuses the Node it runs on.
44
+ return service ? 'install a fixed Node, then angelia restart' : 'install a fixed Node, then angelia restart from a terminal where it comes first on PATH';
45
+ }
46
+ //# sourceMappingURL=node-fix.js.map
@@ -164,16 +164,37 @@ export function serviceInstalled(home = homedir(), stateDir = STATE_DIR) {
164
164
  export function serviceLoaded() {
165
165
  return process.platform === 'darwin' && launchctl(['print', `${domain()}/${LABEL}`]).code === 0;
166
166
  }
167
- /** Stop the service's daemon and forget the job; it comes back only with serviceStart. */
168
- export function serviceStop() {
169
- if (serviceLoaded())
170
- launchctl(['bootout', `${domain()}/${LABEL}`]);
171
- }
172
- /** Load the job from the plist on disk (so a rewritten plist takes effect), which starts the daemon. */
173
- export function serviceStart(home = homedir()) {
174
- const r = launchctl(['bootstrap', domain(), plistPath(home)]);
175
- if (r.code !== 0 && !serviceLoaded())
167
+ function sleepSync(ms) {
168
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
169
+ }
170
+ /** Stop the service's daemon and forget the job; it comes back only with serviceStart.
171
+ * bootout returns while launchd is still removing a job whose daemon runs, and a bootstrap in that
172
+ * window fails (5: Input/output error), so wait until the job is gone: up to 25 s, past launchd's
173
+ * 20 s ExitTimeOut, after which it has killed the daemon. */
174
+ export function serviceStop(run = launchctl, sleep = sleepSync) {
175
+ const job = `${domain()}/${LABEL}`;
176
+ if (run(['print', job]).code !== 0)
177
+ return;
178
+ run(['bootout', job]);
179
+ for (let i = 0; i < 100; i++) {
180
+ if (run(['print', job]).code !== 0)
181
+ return;
182
+ sleep(250);
183
+ }
184
+ throw new Error(`launchd still holds ${LABEL} 25s after bootout, so a start now would fail. Try again in a moment.`);
185
+ }
186
+ /** Load the job from the plist on disk (so a rewritten plist takes effect), and start the daemon.
187
+ * RunAtLoad alone does not start it: measured on macOS 26.5, a job bootstrapped into a running
188
+ * login session is left "pended nondemand spawn = speculative" and runs only at the next login.
189
+ * kickstart starts it now; on a daemon already running it does nothing. */
190
+ export function serviceStart(home = homedir(), run = launchctl) {
191
+ const job = `${domain()}/${LABEL}`;
192
+ const r = run(['bootstrap', domain(), plistPath(home)]);
193
+ if (r.code !== 0 && run(['print', job]).code !== 0)
176
194
  throw new Error(`launchctl bootstrap failed: ${r.out || `exit ${r.code}`}`);
195
+ const k = run(['kickstart', job]);
196
+ if (k.code !== 0)
197
+ throw new Error(`launchctl kickstart failed: ${k.out || `exit ${k.code}`}`);
177
198
  }
178
199
  function readPid() {
179
200
  try {
@@ -5,6 +5,7 @@ import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { STATE_DIR } from './daemon.js';
7
7
  import { plistPath, plistProgram, serviceInstalled } from './service.js';
8
+ import { nodeAdvice, nodeFixProblem } from './node-fix.js';
8
9
  /**
9
10
  * `angelia update`: replace the installed package with the newest signed release of its source, and
10
11
  * say what changed. The instance is out of reach by construction: the source is cloned and built in
@@ -20,6 +21,8 @@ import { plistPath, plistProgram, serviceInstalled } from './service.js';
20
21
  * - no dependency runs an install script: `npm ci --ignore-scripts`, then this package's own build;
21
22
  * the tarball carries every dependency at its locked version, so the install resolves nothing.
22
23
  * `--head` installs the branch tip instead, unsigned, and says so: that is for development.
24
+ * A Node without the fix for CVE-2026-111497 (node-fix.ts) gets a warning, not a refusal: refusing
25
+ * would not take the daemon off its Node, and it would keep Angelia's own security fixes out.
23
26
  *
24
27
  * It never restarts anything. The running daemon keeps the code it loaded; the user restarts when
25
28
  * it suits them, from a chat (/restart) or a terminal.
@@ -61,6 +64,23 @@ export function serviceMismatch(updated, plist) {
61
64
  return undefined;
62
65
  return `The service does not run this copy: it starts ${runs}, and this update went to ${here}. Update that one with its own Node first on PATH: PATH=${dirname(prog.node)}:$PATH angelia update`;
63
66
  }
67
+ /**
68
+ * What is wrong with the Node the service starts (the plist's ProgramArguments[0]), or undefined when
69
+ * it has the fix. That one, not the Node this update runs on, is the one under the daemon: a shell
70
+ * can have a fixed Node first on PATH while launchd still starts an older one by its own path.
71
+ */
72
+ export function serviceNodeProblem(plist) {
73
+ const prog = plistProgram(plist);
74
+ if (!prog)
75
+ return undefined;
76
+ const r = spawnSync(prog.node, ['-p', 'process.versions.node'], { encoding: 'utf8', timeout: 10_000, killSignal: 'SIGKILL',
77
+ // This update's NODE_OPTIONS can carry flags an older Node does not know, and it would fail for that.
78
+ env: { ...process.env, NODE_OPTIONS: '' } });
79
+ if (r.status !== 0)
80
+ return `The service starts the Node ${prog.node}, which did not run (${r.error?.message ?? (r.stderr || `exit ${r.status}`).trim()}). Write the plist again: angelia service install <routing.yaml>`;
81
+ const open = nodeFixProblem(r.stdout.trim(), prog.node);
82
+ return open && `The service's ${open}: ${nodeAdvice(prog.node)}`;
83
+ }
64
84
  /** The installed package's root: dist/daemon/update.js lives two levels down. */
65
85
  export function packageRoot() {
66
86
  return dirname(dirname(dirname(fileURLToPath(import.meta.url))));
@@ -212,6 +232,9 @@ function run(cmd, args, cwd) {
212
232
  }
213
233
  export async function updateCommand(argv) {
214
234
  const check = argv.includes('--check'), head = argv.includes('--head'), force = argv.includes('--force');
235
+ const open = nodeFixProblem();
236
+ if (open)
237
+ console.log(`Warning: ${open}. Updating anyway: install a fixed Node too.`);
215
238
  const fromAt = argv.indexOf('--from');
216
239
  let source = fromAt >= 0 ? argv[fromAt + 1] : undefined;
217
240
  if (fromAt >= 0 && !source)
@@ -272,6 +295,9 @@ export async function updateCommand(argv) {
272
295
  const off = plist && serviceMismatch(join(globalRoot, name), plist);
273
296
  if (off)
274
297
  console.log(`Warning: ${off}`);
298
+ const node = plist && serviceNodeProblem(plist);
299
+ if (node)
300
+ console.log(`Warning: ${node}.`);
275
301
  }
276
302
  }
277
303
  finally {
package/install.sh CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/bin/sh
2
2
  # Angelia installer: curl -fsSL https://raw.githubusercontent.com/korengast/angelia/<release tag>/install.sh | sh
3
3
  #
4
- # Does three things and nothing else: checks Node 22+, installs the newest release the way
5
- # `angelia update` does (clone the tag, build, pack, npm i -g, no dependency install scripts), then
6
- # runs `angelia init` unless an instance already exists. It never clones into your home, never
7
- # builds in place, and never touches an existing instance.
4
+ # Does three things and nothing else: checks Node (22.23.4+, 24.22.1+ or 26.12.1+), installs the
5
+ # newest release the way `angelia update` does (clone the tag, build, pack, npm i -g, no dependency
6
+ # install scripts), then runs `angelia init` unless an instance already exists. It never clones into
7
+ # your home, never builds in place, and never touches an existing instance.
8
8
  #
9
9
  # The release it installs must be a tag signed by one of the release keys below (the owner's, and the
10
10
  # release workflow's, which lives only in the repository's `release` environment on GitHub), and the
@@ -89,10 +89,11 @@ stop_anim() {
89
89
  step() { if [ -n "$anim_pid" ]; then printf '%s' "$*" > "$tmp/step"; say "$*" >> "$tmp/said"; else say "$*"; fi; }
90
90
 
91
91
  command -v git >/dev/null 2>&1 || die "git is required (xcode-select --install on macOS)"
92
- command -v node >/dev/null 2>&1 || die "Node 22 or newer is required: https://nodejs.org"
92
+ command -v node >/dev/null 2>&1 || die "Node 22.23.4+, 24.22.1+ or 26.12.1+ is required: https://nodejs.org"
93
93
  command -v npm >/dev/null 2>&1 || die "npm is required (it ships with Node)"
94
- major=$(node -p 'process.versions.node.split(".")[0]')
95
- [ "$major" -ge 22 ] 2>/dev/null || die "Node 22 or newer is required; found $(node --version)"
94
+ # Node2Shell (CVE-2026-111497): Brotli RCE in the runtime, fixed in 22.23.4, 24.22.1, 26.12.1; 23 and 25 get no fix.
95
+ node -e 'const v=process.versions.node,[a,b,c]=v.split(".").map(Number),f={22:[23,4],24:[22,1],26:[12,1]}[a];process.exit(/^\d+\.\d+\.\d+$/.test(v)&&(a>26||f&&(b>f[0]||b===f[0]&&c>=f[1]))?0:1)' \
96
+ || die "Node 22.23.4+, 24.22.1+ or 26.12.1+ is required (CVE-2026-111497); found $(node --version)"
96
97
 
97
98
  tmp=$(mktemp -d "${TMPDIR:-/tmp}/angelia-install.XXXXXX")
98
99
  trap 'stop_anim; rm -rf "$tmp"' EXIT
@@ -84,7 +84,7 @@ Following tag header formats are supported:
84
84
  Following lyric formats are supported:
85
85
  - [LRC](https://en.wikipedia.org/wiki/LRC_(file_format))
86
86
  - Synchronized lyrics (SYLT)
87
- - Unsynchronized lyrics (USULT)
87
+ - Unsynchronized lyrics (USLT)
88
88
 
89
89
  Support for [MusicBrainz](https://musicbrainz.org/) tags as written by [Picard](https://picard.musicbrainz.org/).
90
90
  [ReplayGain](https://wiki.hydrogenaud.io/index.php?title=ReplayGain) tags are supported.
@@ -123,7 +123,7 @@ yarn add music-metadata
123
123
 
124
124
  **Node.js specific** functions to read an audio file or stream:
125
125
  1. **File Parsing**: Parse audio files directly from the filesystem using the [parseFile function](#parsefile-function)
126
- 1. **Stream Parsing**: Parse audio metadata from a Node.js [Readable stream](https://nodejs.org/api/stream.html#class-streamreadable) using the [parseStream function](#parsewebstream-function).
126
+ 1. **Stream Parsing**: Parse audio metadata from a Node.js [Readable stream](https://nodejs.org/api/stream.html#class-streamreadable) using the [parseStream function](#parsestream-function).
127
127
 
128
128
  **Cross-platform** functions available to read an audio file or stream:
129
129
 
@@ -136,8 +136,8 @@ There are multiple ways to parse (read) audio tracks:
136
136
  > [!NOTE]
137
137
  > Direct file access in Node.js is generally faster because it can 'jump' to various parts of the file without reading intermediate data.
138
138
 
139
- ### Node.js specific function
140
- These functions are tailored for Node.js environments and leverage Node.js-specific APIs,
139
+ ### Node.js specific functions
140
+ These functions use Node.js-specific APIs,
141
141
  making them incompatible with browser-based JavaScript engines.
142
142
 
143
143
  #### `parseFile` function
@@ -269,7 +269,7 @@ import { createReadStream } from 'fs';
269
269
 
270
270
  ### Cross-platform functions
271
271
  These functions are designed to be cross-platform,
272
- meaning it can be used in both Node.js and web browsers.
272
+ meaning they can be used in both Node.js and web browsers.
273
273
 
274
274
  #### `parseWebStream` function
275
275
 
@@ -295,14 +295,14 @@ parseWebStream(webStream: ReadableStream<Uint8Array>, fileInfo?: IFileInfo | str
295
295
  An object containing file-related information or a string representing the MIME-type of the audio stream.
296
296
  The fileInfo parameter can help the parser to correctly identify the audio format and may include:
297
297
 
298
- - `mimeType`: A string representing the [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) (e.g., `audio/mpeg`).
298
+ - `mimeType`: A string representing the [MIME-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) (e.g., `audio/mpeg`).
299
299
 
300
- If provided, it is assumed the streamed file content is to be the MIME-type.
301
- If not provided, the parser will attempt to determine the format based on the content of the stream.
300
+ If provided, it is assumed the streamed file content is to be the MIME-type.
301
+ If not provided, the parser will attempt to determine the format based on the content of the stream.
302
302
 
303
- - `size`: The total size of the audio stream in bytes (useful for streams with a known length).
303
+ - `size`: The total size of the audio stream in bytes (useful for streams with a known length).
304
304
 
305
- - `path`: A string representing the file path or filename, which can also assist in determining the format.
305
+ - `path`: A string representing the file path or filename, which can also assist in determining the format.
306
306
 
307
307
  - `options`: `IOptions` (optional)
308
308
 
@@ -351,19 +351,19 @@ The `response.body` provides a [`ReadableStream`](https://developer.mozilla.org/
351
351
  #### `parseBlob` function
352
352
 
353
353
  Parses metadata from an audio file represented as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
354
- This function is suitable for use in environments that support the ReadableStreamBYOBReader, which is **available in Node.js 20** and above.
354
+ This function reads slices of the Blob and supports both browser File objects and Node.js Blob objects.
355
355
 
356
356
  ##### Syntax
357
357
  ```ts
358
- parseBlob(blob: Blob, options?: IOptions = {}): Promise<IAudioMetadata>
358
+ parseBlob(blob: Blob, options?: IOptions): Promise<IAudioMetadata>
359
359
  ```
360
360
 
361
361
  ##### Parameters
362
362
 
363
363
  - `blob`: [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
364
364
 
365
- The Blob object containing the audio data to be parsed.
366
- This can be a file or any binary data. If the Blob is an instance of File, its name will be used as the file path in the metadata.
365
+ The Blob object containing the audio data to be parsed.
366
+ This can be a File selected by the user or a Blob containing audio data. The Blob size and MIME type are passed to the parser.
367
367
 
368
368
  - `options`: [IOptions](#ioptions-interface) (optional)
369
369
 
@@ -400,7 +400,7 @@ This function is particularly useful when you already have audio data in memory.
400
400
 
401
401
  ##### Syntax
402
402
  ```ts
403
- parseBuffer(buffer: Uint8Array, fileInfo?: IFileInfo | string, opts?: IOptions = {}): Promise<IAudioMetadata>
403
+ parseBuffer(uint8Array: Uint8Array, fileInfo?: IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>
404
404
  ```
405
405
 
406
406
  ##### Parameters
@@ -518,12 +518,13 @@ readMetadata();
518
518
 
519
519
  ### Handling Parse Errors
520
520
 
521
- `music-metadata` provides a robust and extensible error handling system with custom error classes that inherit from the standard JavaScript `Error`.
522
- All possible parsing errors are part of a union type `UnionOfParseErrors`, ensuring that every error scenario is accounted for in your code.
521
+ `music-metadata` exports custom error classes that extend JavaScript `Error`.
522
+ Parsing can also reject with other errors, such as filesystem, stream, or tokenizer errors.
523
+ Handle caught values as `unknown` in TypeScript and narrow them before accessing error properties.
523
524
 
524
525
  #### Union of Parse Errors
525
526
 
526
- All parsing errors extend from the base class `ParseError` and are included in the `UnionOfParseErrors` type:
527
+ The `UnionOfParseErrors` type groups the following library error classes; it does not describe every possible rejection:
527
528
  ```ts
528
529
  export type UnionOfParseErrors =
529
530
  | CouldNotDetermineFileTypeError
@@ -545,10 +546,10 @@ export type UnionOfParseErrors =
545
546
 
546
547
  #### `orderTags` function
547
548
 
548
- Utility to Converts the native tags to a dictionary index on the tag identifier
549
+ Converts an array of native tags to a dictionary keyed by tag identifier. Each value is an array of tag values.
549
550
 
550
551
  ```ts
551
- orderTags(nativeTags: ITag[]): [tagId: string]: any[]
552
+ orderTags(nativeTags: ITag[]): INativeTagDict
552
553
  ```
553
554
 
554
555
  ```js
@@ -571,7 +572,7 @@ import { inspect } from 'util';
571
572
  Can be used to convert the normalized rating value to the 0..5 stars, where 0 an undefined rating, 1 the star the lowest rating and 5 the highest rating.
572
573
 
573
574
  ```ts
574
- ratingToStars(rating: number): number
575
+ ratingToStars(rating: number | undefined): number
575
576
  ```
576
577
  #### `selectCover` function
577
578
 
@@ -613,7 +614,7 @@ Returns a list of supported MIME-types. This may include some MIME-types which a
613
614
  - Metadata not listed in the SeekHead may be skipped.
614
615
  - If the SeekHead is missing, this option has no effect.
615
616
 
616
- - `observer`: `(update: MetadataEvent) => void;`:
617
+ - `observer`: `(update: IMetadataEvent) => void`:
617
618
 
618
619
  Callback function triggered when common tags or format properties are updated during parsing.
619
620
  Allows real-time monitoring of metadata as it becomes available.
@@ -628,7 +629,7 @@ Returns a list of supported MIME-types. This may include some MIME-types which a
628
629
  This is particularly beneficial for streaming input, as it avoids the need to read the entire stream.
629
630
 
630
631
  > [!NOTE]
631
- > - The `duration` option is typically included in most cases, but setting it to true ensures that the entire file is parsed if necessary to get an accurate duration.
632
+ > - `format.duration` may be available without enabling `duration`. Set `duration: true` to allow additional scanning when needed; duration can still be unavailable.
632
633
  > - Using `mkvUseIndex` can improve performance in Matroska files, but be aware of potential side effects, such as missing metadata due to skipped elements.
633
634
 
634
635
 
@@ -637,8 +638,9 @@ Returns a list of supported MIME-types. This may include some MIME-types which a
637
638
  If the returned promise resolves, the metadata (TypeScript `IAudioMetadata` interface) contains:
638
639
  - [`metadata.format`](#metadataformat) Audio format information
639
640
  - [`metadata.common`](#metadatacommon) Is a generic (abstract) way of reading metadata information.
640
- - [`metadata.trackInfo`](#metadatatrackInfo) Is a generic (abstract) way of reading metadata information.
641
- - `metadata.native` List of native (original) tags found in the parsed audio file.
641
+ - [`metadata.format.trackInfo`](#metadataformattrackinfo) Describes individual audio and video tracks when available.
642
+ - `metadata.native` Maps each tag format to an array of native (original) tags found in the parsed audio file.
643
+ - `metadata.quality.warnings` Contains non-fatal parsing warnings, each with a `message` string.
642
644
 
643
645
  #### `metadata.format`
644
646
 
@@ -660,15 +662,16 @@ Audio format information. Defined in the TypeScript `IFormat` interface:
660
662
  - `format.trackGain?: number` Track gain in dB
661
663
  - `format.albumGain?: number` Album gain in dB
662
664
 
663
- #### `metadata.trackInfo`
665
+ #### `metadata.format.trackInfo`
664
666
 
665
- To support advanced containers like [Matroska](https://wikipedia.org/wiki/Matroska) or [MPEG-4](https://en.wikipedia.org/wiki/MPEG-4), which may contain multiple audio and video tracks, the **experimental**- `metadata.trackInfo` has been added,
667
+ Containers such as Matroska and MPEG-4 can contain multiple audio and video tracks.
668
+ The experimental `metadata.format.trackInfo` property describes these individual tracks.
666
669
 
667
- `metadata.trackInfo` is either `undefined` or has an **array** of [trackInfo](#trackinfo)
670
+ `metadata.format.trackInfo` is an array of [trackInfo](#trackinfo) objects, empty when no track information is available.
668
671
 
669
672
  ##### trackInfo
670
673
 
671
- Audio format information. Defined in the TypeScript `IFormat` interface:
674
+ Individual track information. Defined in the TypeScript `ITrackInfo` interface:
672
675
  - `trackInfo.type?: TrackType` Track type
673
676
  - `trackInfo.codecName?: string` Codec name
674
677
  - `trackInfo.codecSettings?: string` Codec settings
@@ -685,7 +688,7 @@ Audio format information. Defined in the TypeScript `IFormat` interface:
685
688
  - `audioTrack.samplingFrequency?: number`
686
689
  - `audioTrack.outputSamplingFrequency?: number`
687
690
  - `audioTrack.channels?: number`
688
- - `audioTrack.channelPositions?: Buffer`
691
+ - `audioTrack.channelPositions?: Uint8Array`
689
692
  - `audioTrack.bitDepth?: number`
690
693
 
691
694
  ##### `trackInfo.videoTrack`
@@ -698,7 +701,7 @@ Audio format information. Defined in the TypeScript `IFormat` interface:
698
701
  - `videoTrack.displayHeight?: number`
699
702
  - `videoTrack.displayUnit?: number`
700
703
  - `videoTrack.aspectRatioType?: number`
701
- - `videoTrack.colourSpace?: Buffer`
704
+ - `videoTrack.colourSpace?: Uint8Array`
702
705
  - `videoTrack.gammaValue?: number`
703
706
 
704
707
  #### `metadata.common`
@@ -737,7 +740,7 @@ export interface IPicture {
737
740
  /**
738
741
  * Image data
739
742
  */
740
- data: Buffer;
743
+ data: Uint8Array;
741
744
  /**
742
745
  * Optional description
743
746
  */
@@ -1,7 +1,7 @@
1
1
  import { type MediaType } from 'media-typer';
2
+ import type { ITokenizer } from 'strtok3';
2
3
  import { type INativeMetadataCollector } from './common/MetadataCollector.js';
3
4
  import { type IAudioMetadata, type IOptions, type ParserType } from './type.js';
4
- import type { ITokenizer } from 'strtok3';
5
5
  export interface IParserLoader {
6
6
  /**
7
7
  * Returns a list of supported file extensions
@@ -1,24 +1,24 @@
1
- import { fileTypeFromBuffer } from 'file-type';
2
1
  import ContentType from 'content-type';
3
- import { parse as mimeTypeParse } from 'media-typer';
4
2
  import initDebug from 'debug';
5
- import { MetadataCollector } from './common/MetadataCollector.js';
6
- import { TrackType } from './type.js';
7
- import { mpegParserLoader } from './mpeg/MpegLoader.js';
8
- import { CouldNotDetermineFileTypeError, UnsupportedFileTypeError } from './ParseError.js';
3
+ import { fileTypeFromBuffer } from 'file-type';
4
+ import { parse as mimeTypeParse } from 'media-typer';
5
+ import { aiffParserLoader } from './aiff/AiffLoader.js';
9
6
  import { apeParserLoader } from './apev2/Apev2Loader.js';
10
7
  import { asfParserLoader } from './asf/AsfLoader.js';
8
+ import { MetadataCollector } from './common/MetadataCollector.js';
9
+ import { scanAppendingHeaders } from './core.js';
11
10
  import { dsdiffParserLoader } from './dsdiff/DsdiffLoader.js';
12
- import { aiffParserLoader } from './aiff/AiffLoader.js';
13
11
  import { dsfParserLoader } from './dsf/DsfLoader.js';
14
12
  import { flacParserLoader } from './flac/FlacLoader.js';
15
13
  import { matroskaParserLoader } from './matroska/MatroskaLoader.js';
16
14
  import { mp4ParserLoader } from './mp4/Mp4Loader.js';
15
+ import { mpegParserLoader } from './mpeg/MpegLoader.js';
17
16
  import { musepackParserLoader } from './musepack/MusepackLoader.js';
18
17
  import { oggParserLoader } from './ogg/OggLoader.js';
19
- import { wavpackParserLoader } from './wavpack/WavPackLoader.js';
18
+ import { CouldNotDetermineFileTypeError, UnsupportedFileTypeError } from './ParseError.js';
19
+ import { TrackType } from './type.js';
20
20
  import { riffParserLoader } from './wav/WaveLoader.js';
21
- import { scanAppendingHeaders } from './core.js';
21
+ import { wavpackParserLoader } from './wavpack/WavPackLoader.js';
22
22
  const debug = initDebug('music-metadata:parser:factory');
23
23
  export function parseHttpContentType(contentType) {
24
24
  const type = ContentType.parse(contentType);
@@ -47,7 +47,9 @@ export class ParserFactory {
47
47
  musepackParserLoader,
48
48
  dsfParserLoader,
49
49
  dsdiffParserLoader
50
- ].forEach(parser => { this.registerParser(parser); });
50
+ ].forEach(parser => {
51
+ this.registerParser(parser);
52
+ });
51
53
  }
52
54
  registerParser(parser) {
53
55
  this.parsers.push(parser);
@@ -73,7 +75,7 @@ export class ParserFactory {
73
75
  debug('Guess parser on content...');
74
76
  await tokenizer.peekBuffer(buf, { mayBeLess: true });
75
77
  const guessedType = await fileTypeFromBuffer(buf, { mpegOffsetTolerance: 10 });
76
- if (!guessedType || !guessedType.mime) {
78
+ if (!guessedType?.mime) {
77
79
  throw new CouldNotDetermineFileTypeError('Failed to determine audio format');
78
80
  }
79
81
  debug(`Guessed file type is mime=${guessedType.mime}, extension=${guessedType.ext}`);
@@ -105,15 +107,17 @@ export class ParserFactory {
105
107
  * @return Parser submodule name
106
108
  */
107
109
  findLoaderForExtension(filePath) {
108
- if (!filePath)
110
+ if (!filePath) {
109
111
  return;
112
+ }
110
113
  const extension = getExtension(filePath).toLocaleLowerCase() || filePath;
111
114
  return this.parsers.find(parser => parser.extensions.indexOf(extension) !== -1);
112
115
  }
113
116
  findLoaderForContentType(httpContentType) {
114
117
  let mime;
115
- if (!httpContentType)
118
+ if (!httpContentType) {
116
119
  return;
120
+ }
117
121
  try {
118
122
  mime = parseHttpContentType(httpContentType);
119
123
  }