Skip to content

Commit ee69568

Browse files
Merge pull request #8119 from efb4f5ff-1298-471a-8973-3d47447115dc/hotfix-release-v0.23.10
Hotfix release - v0.23.10
2 parents 48522ce + 5047d86 commit ee69568

File tree

9 files changed

+107
-35
lines changed

9 files changed

+107
-35
lines changed

.github/workflows/updateSite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
git checkout master
5353
- name: Update index.php
5454
run: |
55-
sed -in 's/${{ steps.previous.outputs.result }}/${{ steps.current.outputs.result }}/' src/index.php
55+
sed -i 's/${{ steps.previous.outputs.result }}/${{ steps.current.outputs.result }}/g' src/index.php
5656
- name: Commit Files
5757
uses: stefanzweifel/git-auto-commit-action@v6
5858
with:

_scripts/sigFrameConfig.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const { hash } = require('crypto')
2+
const { join } = require('path')
3+
const { readFileSync } = require('fs')
4+
5+
const path = join(__dirname, '../src/renderer/sigFrameScript.js')
6+
const rawScript = readFileSync(path, 'utf8')
7+
8+
const script = rawScript
9+
10+
module.exports.sigFrameTemplateParameters = {
11+
sigFrameSrc: `data:text/html,${encodeURIComponent(`<!doctype html><script>${script}</script>`)}`,
12+
sigFrameCspHash: `sha256-${hash('sha256', script, 'base64')}`
13+
}

_scripts/webpack.renderer.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
SHAKA_LOCALES_PREBUNDLED,
1313
SHAKA_LOCALES_TO_BE_BUNDLED
1414
} = require('./getShakaLocales')
15+
const { sigFrameTemplateParameters } = require('./sigFrameConfig')
1516

1617
const isDevMode = process.env.NODE_ENV === 'development'
1718

@@ -132,9 +133,9 @@ const config = {
132133
'process.env.SHAKA_LOCALES_PREBUNDLED': JSON.stringify(SHAKA_LOCALES_PREBUNDLED)
133134
}),
134135
new HtmlWebpackPlugin({
135-
excludeChunks: ['processTaskWorker'],
136136
filename: 'index.html',
137-
template: path.resolve(__dirname, '../src/index.ejs')
137+
template: path.resolve(__dirname, '../src/index.ejs'),
138+
templateParameters: sigFrameTemplateParameters
138139
}),
139140
new VueLoaderPlugin(),
140141
new MiniCssExtractPlugin({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "freetube",
33
"productName": "FreeTube",
44
"description": "A private YouTube client",
5-
"version": "0.23.9",
5+
"version": "0.23.10",
66
"license": "AGPL-3.0-or-later",
77
"main": "./dist/main.js",
88
"private": true,
@@ -74,7 +74,7 @@
7474
"vue-observe-visibility": "^1.0.0",
7575
"vue-router": "^3.6.5",
7676
"vuex": "^3.6.2",
77-
"youtubei.js": "^15.1.1"
77+
"youtubei.js": "^16.0.0"
7878
},
7979
"devDependencies": {
8080
"@babel/core": "^7.26.7",

src/index.ejs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313

1414
<body>
1515
<div id="app"></div>
16+
<% if (process.env.SUPPORTS_LOCAL_API) { %>
17+
<iframe
18+
id="sigFrame"
19+
src="<%= sigFrameSrc %>"
20+
csp="default-src 'none'; script-src '<%= sigFrameCspHash %>' 'unsafe-eval'"
21+
sandbox="allow-scripts"
22+
height="1"
23+
width="1"
24+
style="display: none; pointer-events: none"
25+
tabindex="-1"
26+
></iframe>
27+
<% } %>
1628
<% if (!process.env.IS_ELECTRON) { %>
1729
<script>
1830
// This is the service worker with the Advanced caching

src/renderer/helpers/api/invidious.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ export async function generateInvidiousDashManifestLocally(formats) {
837837
// create a dummy player, as deciphering requires making requests to YouTube,
838838
// which we want to avoid when Invidious is selected as the backend
839839
const player = new Player()
840-
player.decipher = (url) => url
840+
player.decipher = async (url) => url
841841

842842
let urlTransformer
843843

src/renderer/helpers/api/local.js

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClientType, Innertube, Misc, Mixins, Parser, UniversalCache, Utils, YT, YTNodes } from 'youtubei.js'
1+
import { ClientType, Innertube, Misc, Mixins, Parser, Platform, UniversalCache, Utils, YT, YTNodes } from 'youtubei.js'
22
import Autolinker from 'autolinker'
33
import { IpcChannels, SEARCH_CHAR_LIMIT } from '../../../constants'
44

@@ -20,6 +20,50 @@ const TRACKING_PARAM_NAMES = [
2020
'utm_content',
2121
]
2222

23+
if (process.env.SUPPORTS_LOCAL_API) {
24+
Platform.shim.eval = (data, env) => {
25+
return new Promise((resolve) => {
26+
const properties = []
27+
28+
if (env.n) {
29+
properties.push(`n: exportedVars.nFunction("${env.n}")`)
30+
}
31+
32+
if (env.sig) {
33+
properties.push(`sig: exportedVars.sigFunction("${env.sig}")`)
34+
}
35+
36+
// Triggers permission errors if we don't remove it (added by YouTube.js), as sessionStorage isn't accessible in sandboxed cross-origin iframes
37+
const modifiedOutput = data.output.replace('const window = Object.assign({}, globalThis);', '')
38+
39+
const code = `${modifiedOutput}\nreturn {${properties.join(', ')}}`
40+
41+
// Generate a unique ID, as there may be multiple eval calls going on at the same time (e.g. DASH manifest generation)
42+
const messageId = process.env.IS_ELECTRON || crypto.randomUUID
43+
? crypto.randomUUID()
44+
: `${Date.now()}-${Math.floor(Math.random() * 10000)}`
45+
46+
const iframe = document.getElementById('sigFrame')
47+
48+
/** @param {MessageEvent} event */
49+
const listener = (event) => {
50+
if (event.source === iframe.contentWindow && typeof event.data === 'string') {
51+
const data = JSON.parse(event.data)
52+
53+
if (data.id === messageId) {
54+
window.removeEventListener('message', listener)
55+
56+
resolve(data.result)
57+
}
58+
}
59+
}
60+
61+
window.addEventListener('message', listener)
62+
iframe.contentWindow.postMessage(JSON.stringify({ id: messageId, code }), '*')
63+
})
64+
}
65+
}
66+
2367
/**
2468
* Creates a lightweight Innertube instance, which is faster to create or
2569
* an instance that can decode the streaming URLs, which is slower to create
@@ -344,12 +388,12 @@ export async function getLocalVideoInfo(id) {
344388
}
345389

346390
if (info.streaming_data) {
347-
decipherFormats(info.streaming_data.formats, webInnertube.session.player)
391+
await decipherFormats(info.streaming_data.formats, webInnertube.session.player)
348392

349393
const firstFormat = info.streaming_data.adaptive_formats[0]
350394

351395
if (firstFormat.url || firstFormat.signature_cipher || firstFormat.cipher) {
352-
decipherFormats(info.streaming_data.adaptive_formats, webInnertube.session.player)
396+
await decipherFormats(info.streaming_data.adaptive_formats, webInnertube.session.player)
353397
}
354398

355399
if (info.streaming_data.dash_manifest_url) {
@@ -405,11 +449,11 @@ export async function getLocalComments(id) {
405449
* @param {Misc.Format[]} formats
406450
* @param {import('youtubei.js').Player} player
407451
*/
408-
function decipherFormats(formats, player) {
452+
async function decipherFormats(formats, player) {
409453
for (const format of formats) {
410454
// toDash deciphers the format again, so if we overwrite the original URL,
411455
// it breaks because the n param would get deciphered twice and then be incorrect
412-
format.freeTubeUrl = format.decipher(player)
456+
format.freeTubeUrl = await format.decipher(player)
413457
}
414458
}
415459

src/renderer/sigFrameScript.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This is injected into the sigFrame iframe
2+
// See index.ejs and webpack.renderer.config.js
3+
window.addEventListener('message', (event) => {
4+
const data = JSON.parse(event.data)
5+
6+
window.parent.postMessage(JSON.stringify({
7+
id: data.id,
8+
// eslint-disable-next-line no-new-func
9+
result: new Function(data.code)()
10+
}), '*')
11+
})

yarn.lock

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,10 +2126,10 @@ acorn-jsx@^5.3.2:
21262126
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
21272127
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
21282128

2129-
acorn@^8.14.0, acorn@^8.5.0, acorn@^8.8.0, acorn@^8.8.2, acorn@^8.9.0:
2130-
version "8.14.0"
2131-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0"
2132-
integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==
2129+
acorn@^8.14.0, acorn@^8.5.0, acorn@^8.8.2, acorn@^8.9.0:
2130+
version "8.15.0"
2131+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816"
2132+
integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==
21332133

21342134
agent-base@6, agent-base@^6.0.2:
21352135
version "6.0.2"
@@ -5903,13 +5903,6 @@ jest-worker@^29.7.0:
59035903
merge-stream "^2.0.0"
59045904
supports-color "^8.0.0"
59055905

5906-
jintr@^3.3.1:
5907-
version "3.3.1"
5908-
resolved "https://registry.yarnpkg.com/jintr/-/jintr-3.3.1.tgz#b88355af0c66603130b12d54721b8ab1d3be0b98"
5909-
integrity sha512-nnOzyhf0SLpbWuZ270Omwbj5LcXUkTcZkVnK8/veJXtSZOiATM5gMZMdmzN75FmTyj+NVgrGaPdH12zIJ24oIA==
5910-
dependencies:
5911-
acorn "^8.8.0"
5912-
59135906
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
59145907
version "4.0.0"
59155908
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -6401,6 +6394,11 @@ merge2@^1.3.0, merge2@^1.4.1:
64016394
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
64026395
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
64036396

6397+
meriyah@^6.1.4:
6398+
version "6.1.4"
6399+
resolved "https://registry.yarnpkg.com/meriyah/-/meriyah-6.1.4.tgz#2d49a8934fbcd9205c20564579c3560d9b1e077b"
6400+
integrity sha512-Sz8FzjzI0kN13GK/6MVEsVzMZEPvOhnmmI1lU5+/1cGOiK3QUahntrNNtdVeihrO7t9JpoH75iMNXg6R6uWflQ==
6401+
64046402
methods@~1.1.2:
64056403
version "1.1.2"
64066404
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
@@ -8904,7 +8902,7 @@ ts-api-utils@^1.3.0:
89048902
resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1"
89058903
integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==
89068904

8907-
tslib@^2.0.0, tslib@^2.0.3, tslib@^2.3.1, tslib@^2.5.0, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.8.1:
8905+
tslib@^2.0.0, tslib@^2.0.3, tslib@^2.3.1, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.8.1:
89088906
version "2.8.1"
89098907
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
89108908
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==
@@ -9056,11 +9054,6 @@ undici-types@~5.26.4:
90569054
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
90579055
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
90589056

9059-
undici@^6.21.3:
9060-
version "6.21.3"
9061-
resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.3.tgz#185752ad92c3d0efe7a7d1f6854a50f83b552d7a"
9062-
integrity sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==
9063-
90649057
unicode-canonical-property-names-ecmascript@^2.0.0:
90659058
version "2.0.0"
90669059
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
@@ -9652,12 +9645,10 @@ yocto-queue@^1.0.0:
96529645
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.2.1.tgz#36d7c4739f775b3cbc28e6136e21aa057adec418"
96539646
integrity sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==
96549647

9655-
youtubei.js@^15.1.1:
9656-
version "15.1.1"
9657-
resolved "https://registry.yarnpkg.com/youtubei.js/-/youtubei.js-15.1.1.tgz#a5cfbfb24e7e3d4233ec9f245b2a8ade0ad28128"
9658-
integrity sha512-fuEDj9Ky6cAQg93BrRVCbr+GTYNZQAIFZrx/a3oDRuGc3Mf5bS0dQfoYwwgjtSV7sgAKQEEdGtzRdBzOc8g72Q==
9648+
youtubei.js@^16.0.0:
9649+
version "16.0.0"
9650+
resolved "https://registry.yarnpkg.com/youtubei.js/-/youtubei.js-16.0.0.tgz#b88537c4d89468216c50058cd295ce3c1da8adf2"
9651+
integrity sha512-aMx+ulnrxzsgVsxTr7gbBVnIjti2NQUlMwCoo1/MzICCJS3iMLOPUFdo7bSpwskL6ljzQ/LxmmB4WQC3FtkBlA==
96599652
dependencies:
96609653
"@bufbuild/protobuf" "^2.0.0"
9661-
jintr "^3.3.1"
9662-
tslib "^2.5.0"
9663-
undici "^6.21.3"
9654+
meriyah "^6.1.4"

0 commit comments

Comments
 (0)