JWT
JWT - Signed URL token generation helpers
Example:
const Mux = require('@mux/mux-node');
const token = Mux.JWT.sign('some-playback-id', { keyId: 'your key id', keySecret: 'your key secret' })
Static Method Summary
Static Public Methods | ||
public static |
Decodes an existing token. |
|
public static |
Creates a new token to be used with a signed playback ID |
Static Public Methods
public static decode(token: string): Object source
Decodes an existing token.
Note: This does not cryptographically verify the token signature, it simply decodes the values.
Params:
Name | Type | Attribute | Description |
token | string | The token you'd like to decode. |
Example:
const Mux = require('@mux/mux-node');
const token = Mux.JWT.sign('some-playback-id', { keyId: 'your key id', keySecret: 'your key secret' });
const decoded = Mux.JWT.decode(token);
// decoded will be the raw decoded JWT, so you'll see keys like `aud`, `exp`, etc.
public static sign(playbackId: string, options: Object): string source
Creates a new token to be used with a signed playback ID
Params:
Name | Type | Attribute | Description |
playbackId | string | The Playback ID (of type 'signed') that you'd like to generate a token for. |
|
options | Object | Configuration options to use when creating the token |
|
options.keyId | string |
|
The signing key ID to use. If not specified, process.env.MUX_SIGNING_KEY is attempted |
options.keySecret | string |
|
The signing key secret. If not specified, process.env.MUX_PRIVATE_KEY is used. |
options.type | string |
|
Type of token this will be. Valid types are |
options.expiration | string |
|
Length of time for the token to be valid. |
options.params | Object |
|
Any additional query params you'd use with a public url. For example, with a thumbnail this would be values such as |
Example:
const Mux = require('@mux/mux-node');
const token = Mux.JWT.sign('some-playback-id', { keyId: 'your key id', keySecret: 'your key secret' });
// Now you can use the token in a url: `https://stream.mux.com/some-playback-id.m3u8?token=${token}`