From fecafb967f1efc0a000dc61373d9ebe5de6c7fb8 Mon Sep 17 00:00:00 2001 From: reidlab Date: Sun, 14 Jun 2026 22:07:53 -0700 Subject: [PATCH] fix token grabbing --- src/appleMusicApi/token.ts | 6 +++--- tsconfig.json | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/appleMusicApi/token.ts b/src/appleMusicApi/token.ts index dc02c3c..d1f2dee 100644 --- a/src/appleMusicApi/token.ts +++ b/src/appleMusicApi/token.ts @@ -9,7 +9,7 @@ export async function getToken(baseUrl: string): Promise { const indexResponse = await request(baseUrl); const indexBody = await indexResponse.body.text(); - const jsRegex = /\/assets\/index-legacy[~-][^/]+\.js/; + const jsRegex = /\/assets\/index(?:-legacy)?[~-][^/]+\.js/; const jsPath = indexBody.match(jsRegex)?.[0]; if (!jsPath) { @@ -20,8 +20,8 @@ export async function getToken(baseUrl: string): Promise { const jsBody = await jsResponse.body.text(); // the token is actually a base64-encoded JWT - // `eyJh` === `{"a`, which is the beginning of a JWT (a is the start of alg) - const tokenRegex = /eyJh([^"]*)/; + // `eyJh` === `{"`, which is the beginning of a JWT. foolproof? no + const tokenRegex = /eyJ([^"]*)/; const token = jsBody.match(tokenRegex)?.[0]; if (!token) { diff --git a/tsconfig.json b/tsconfig.json index 0ec6828..7d269aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,9 @@ "skipLibCheck": true, "sourceMap": true, "resolveJsonModule": true, - "baseUrl": "src", + "paths": { + "*": ["./src/*"] + }, "outDir": "dist" }, "include": ["**/*"],