@@ -3,19 +3,18 @@ import { readFile } from 'fs/promises'
33import { join } from 'path'
44
55/**
6- * Generates a poToken (proof of origin token) using `bgutils-js`.
6+ * Generates a content-bound poToken (proof of origin token) using `bgutils-js`.
77 * The script to generate it is `src/botGuardScript.js`
88 *
99 * This is intentionally split out into it's own thing, with it's own temporary in-memory session,
1010 * as the BotGuard stuff accesses the global `document` and `window` objects and also requires making some requests.
1111 * So we definitely don't want it running in the same places as the rest of the FreeTube code with the user data.
1212 * @param {string } videoId
13- * @param {string } visitorData
1413 * @param {string } context
1514 * @param {string|undefined } proxyUrl
16- * @returns {Promise<{ contentPoToken: string, sessionPoToken: string } > }
15+ * @returns {Promise<string> }
1716 */
18- export async function generatePoToken ( videoId , visitorData , context , proxyUrl ) {
17+ export async function generatePoToken ( videoId , context , proxyUrl ) {
1918 const sessionUuid = crypto . randomUUID ( )
2019
2120 const theSession = session . fromPartition ( `potoken-${ sessionUuid } ` , { cache : false } )
@@ -96,7 +95,7 @@ export async function generatePoToken(videoId, visitorData, context, proxyUrl) {
9695 }
9796 } )
9897
99- const script = await getScript ( videoId , visitorData , context )
98+ const script = await getScript ( videoId , context )
10099
101100 const response = await webContentsView . webContents . executeJavaScript ( script )
102101
@@ -110,10 +109,9 @@ let cachedScript
110109
111110/**
112111 * @param {string } videoId
113- * @param {string } visitorData
114112 * @param {string } context
115113 */
116- async function getScript ( videoId , visitorData , context ) {
114+ async function getScript ( videoId , context ) {
117115 if ( ! cachedScript ) {
118116 const pathToScript = process . env . NODE_ENV === 'development'
119117 ? join ( __dirname , '../../dist/botGuardScript.js' )
@@ -129,5 +127,5 @@ async function getScript(videoId, visitorData, context) {
129127 cachedScript = content . replace ( match [ 0 ] , `;${ functionName } (FT_PARAMS)` )
130128 }
131129
132- return cachedScript . replace ( 'FT_PARAMS' , `"${ videoId } "," ${ visitorData } ", ${ context } ` )
130+ return cachedScript . replace ( 'FT_PARAMS' , `"${ videoId } ",${ context } ` )
133131}
0 commit comments