Is it possible to NPM install an SDK in Bubble?

I’m wanting to use Mux for cloud hosting and am needing to utilize their SDK but cannot for the life of me figure out HOW to utilize this in Bubble. I’m thinking I need to create my own plugin but am unsure where to start as I need the Mux package up front.

Mux provides the NPM install as follows:

npm install @mux/mux-node --save

The NPM link is: @mux/mux-node - npm

Any help would be greatly appreciated!

Did you consider using API instead?

You can create a plugin if you want to use the node SDK. But what I think is that the sdk use the API…

@Jici, I’d love to accomplish what’s needed via an API, but the problem is I’m needing to generate a JWT for a signed URL scenario and have no idea how to do that without utilizing Node. Fairly new to the world of APIs/SDKs, so trying to stumble along until I find a solution. :wink:

@Jici, Here’s what I’m currently trying to solve for:

Oh, and thanks for replying so quickly. :slight_smile:

I understand.
I don’t know actually if there’s a plugin for creating JWT token and use it to call the API (that could be a good solution). But Mux seem to have done a great job to make all steps easy to handle using their node SDK. So I think that you should consider creating a plugin (server side).

@Jici, yeah, I’m loving their docs. :slight_smile: Unfortunately, I don’t know how to integrate their SDK into my plugin with a CLI install. Any thoughts?


I’ve already got a number of the API requests in my VideoJS Advanced + MUX (All Media) plugin but it currently only deals with public uploads and not signed URLs. I will however work on it this week and get the Signed URL’s with JWT incorporated into it.

If you can bare with me I’ll get this working.


I think a mix of API Call and Server side action is the best way to go. I’m already looking at it to see if this is something than can go fast to build

1 Like

Did you get that fixed? I have the solution for you. Please PM :wink:

yeh I got it!

Just figuring out the “exp” claim code

1 Like

Are you looking for something too complex? :stuck_out_tongue:
Do you want to share what you have done?

I’ve created a Server side action in the plugin called “Generate JSON web token (JWT)” and it uses the MUX node package to upload a signed video. It returns the JWT token that gets added to the end of the URL which MUX returns. It’s just that I want to find a way of setting the “exp” value in the code so we can control how long a URL is available for before it expires. The default is 7 days which I feel may be too long for some. Nice to have the option anyway :slight_smile:

This is the code I’ve currently got working… although that “exp” section doesn’t do it’s job.

function(properties, context) {
 // get data
    var playback_id = properties.playback_id;
    var signing_key = properties.signing_key;
    var private_key = properties.private_key;
    const { JWT } = require('@mux/mux-node');
    let baseOptions = {
        keyId: '' + signing_key + '',
        keySecret: '' + private_key + '',
        exp: 1619621340
    const token = JWT.sign(playback_id, { ...baseOptions, type: 'video'});
    return {token: token};
1 Like

Referring to this:
Secure video playback | Mux

Ok. The best example if from this doc

just change exp to be expiration, and this is a text and not a integer.
I’m using a setting like that actually:

function(properties, context) {

var Mux = require('@mux/mux-node');

var token = Mux.JWT.sign(properties.playback_id, { keyId: properties.signing_id, keySecret:properties.signing_private_key, expiration:properties.expiration})
return {
    key_token: token


Expiration: user need to provide something like 1h or 7d, but to avoid issue, you may set this field to be number, and a dropdown for hour or day for example.

But maybe there’s different option for expiration. But this is what I understand from doc

Like your doc is showing something different completely :stuck_out_tongue:

Ok I see what you’ve done there. Why did I not see that document before!!
Cool thanks for pointing that out, I can see how it’s done now.

1 Like

The doc is not very good to explain this on that page. The " Generate a JSON Web Token" part explain how to create the token if you do it yourself using a different library… but not how to create it if you use the node package. It’s very simple with the node package.

I’m having troubles testing this, it says the default is 7d
But how would you set the expiration for like 5mins? or even less. I believe it should accept a unix epoch time but I’m finding the signed URL’s, although they work fine, never seem to expire. Well at least not in the way I’m trying it. I’ve been attempting to pass in a value like ‘1619618873’ as generated from here for example ( Epoch Converter - Unix Timestamp Converter)

Have you been able to successfully test the expiration?

Got it… thank you for all the info there @Jici

Confirmed: 5m, 10m, 1h, 2d, 7d etc all work as expected.

1 Like