Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'digest') only when loading the file through OBS #8

Open
nicholasudell opened this issue Jan 14, 2025 · 1 comment
Assignees

Comments

@nicholasudell
Copy link

Using the following code to connect to my streamerbot client:

test.js:

const client = new StreamerbotClient({
    port: port,
    password: password,
    onError: (e) => {
        log('Streamerbot error, make sure the server is running.');
        log(e);
    },
    onConnect: (data) => {
        log("Streamerbot connected.");
    },
    onDisconnect: (data) => {
        log("Streamerbot disconnected.");
    }
});

in a web page consisting of:

<html>
    <head>
        <link rel="stylesheet" href="./Score.css"></link>
    </head>
    <body>
        
        <div id="errors"></div>
        <script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
        <script type="text/javascript" src="./test.js"></script>
    </body>
</html>

Saved on my local machine and added via Browser Source in OBS using the "Local File" switch, gives me this sequence coming through the logs:

Connecting to streamer bot
Streamerbot error, make sure the server is running.
TypeError: TypeError: Cannot read properties of undefined (reading 'digest')
Streamerbot Disconnected

If I open this web page in a browser (using Firefox latest), everything connects fine, and I instead get:

Connecting to streamer bot
Streamerbot connected.

I would expect this to work the same when opened in a browser as when run as a local file in OBS.

I have previously written widgets that are run as local files in OBS that use javascript web sockets to connect to streamer bot without using the client, and those have connected successfully. I had hoped to use the streamerbot client to streamline this, but at the moment, this does not work.

@Whipstickgostop
Copy link
Member

Whipstickgostop commented Jan 15, 2025

This seems to be an issue with the Web Crypto API not being made fully available in OBS Studio's embedded Chrome, specifically when referencing a file directly via HTML.

For now, if you remove the password option from the client config, your code should work fine, as the error only occurs during authentication.

I will look into alternatives but I'm not sure that I'm so keen to add a full JavaScript hashing implementation as a dependency for this edge case, in lieu of sticking with SubtleCrypto 🤔

Current workarounds:

  • Connect without authentication
    • The Streamer.bot WebSocket Server can still have auth enabled, but with the Enable for all Requests box unchecked, and anything you need should still be available, even if connecting without a password.
  • Host the file and access it via a URL
    • Fairly trivial to do nowadays via GitHub, Cloudflare, etc.

@Whipstickgostop Whipstickgostop self-assigned this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants