@mux/cli 0.8.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +1216 -259
  3. package/bin/mux +31 -0
  4. package/package.json +35 -106
  5. package/bin/run +0 -6
  6. package/bin/run.cmd +0 -3
  7. package/lib/command-bases/asset-base.d.ts +0 -11
  8. package/lib/command-bases/asset-base.js +0 -41
  9. package/lib/command-bases/base.d.ts +0 -14
  10. package/lib/command-bases/base.js +0 -62
  11. package/lib/command-bases/live-base.d.ts +0 -11
  12. package/lib/command-bases/live-base.js +0 -31
  13. package/lib/commands/assets/create.d.ts +0 -10
  14. package/lib/commands/assets/create.js +0 -64
  15. package/lib/commands/assets/upload.d.ts +0 -20
  16. package/lib/commands/assets/upload.js +0 -148
  17. package/lib/commands/init.d.ts +0 -20
  18. package/lib/commands/init.js +0 -115
  19. package/lib/commands/live/complete.d.ts +0 -12
  20. package/lib/commands/live/complete.js +0 -54
  21. package/lib/commands/live/disable.d.ts +0 -13
  22. package/lib/commands/live/disable.js +0 -40
  23. package/lib/commands/live/enable.d.ts +0 -13
  24. package/lib/commands/live/enable.js +0 -40
  25. package/lib/commands/sign.d.ts +0 -11
  26. package/lib/commands/sign.js +0 -68
  27. package/lib/commands/spaces/sign.d.ts +0 -11
  28. package/lib/commands/spaces/sign.js +0 -79
  29. package/lib/config.d.ts +0 -10
  30. package/lib/config.js +0 -12
  31. package/lib/index.d.ts +0 -2
  32. package/lib/index.js +0 -7
  33. package/oclif.manifest.json +0 -1
  34. package/src/command-bases/asset-base.ts +0 -52
  35. package/src/command-bases/base.ts +0 -72
  36. package/src/command-bases/live-base.ts +0 -35
  37. package/src/commands/assets/create.ts +0 -74
  38. package/src/commands/assets/upload.ts +0 -192
  39. package/src/commands/init.ts +0 -150
  40. package/src/commands/live/complete.ts +0 -63
  41. package/src/commands/live/disable.ts +0 -47
  42. package/src/commands/live/enable.ts +0 -47
  43. package/src/commands/sign.ts +0 -76
  44. package/src/commands/spaces/sign.ts +0 -90
  45. package/src/config.ts +0 -13
  46. package/src/index.ts +0 -3
  47. package/yarn.lock +0 -7350
@@ -1,90 +0,0 @@
1
- import { flags } from '@oclif/command';
2
- // this is a load-bearing unused import due to oclif type issues
3
- import { IOptionFlag, IBooleanFlag } from '@oclif/parser/lib/flags';
4
- import * as JWT from 'jsonwebtoken';
5
- import * as chalk from 'chalk';
6
- import * as clipboard from 'clipboardy';
7
-
8
- import MuxBase from '../../command-bases/base';
9
-
10
- export default class SignSpace extends MuxBase {
11
- static description = 'Creates a new signed token for a Mux Space';
12
-
13
- static args = [
14
- {
15
- name: 'space-id',
16
- description: 'Space ID for which a token shall be generated.',
17
- required: true,
18
- },
19
- ];
20
-
21
- static flags: any = {
22
- raw: flags.boolean({
23
- char: 'r',
24
- description: "prints a raw JWT to stdout (default if not tty)",
25
- default: !process.stdin.isTTY,
26
- }),
27
- participantId: flags.string({
28
- char: 'p',
29
- description: 'Optional, user-specified participant ID.',
30
- }),
31
- role: flags.string({
32
- char: 'R',
33
- description: 'One of \'publisher\' or \'subscriber\'.',
34
- default: 'publisher',
35
- }),
36
- expiresIn: flags.string({
37
- char: 'e',
38
- description: 'How long the signature is valid for. If no unit is specified, milliseconds is assumed.',
39
- default: '7d',
40
- }),
41
- };
42
-
43
- async run() {
44
- const parsed = this.parse(SignSpace);
45
- const args = parsed.args;
46
- const flags = parsed.flags as any;
47
-
48
- const signingKeySecret = this.MuxConfig.signingKeySecret;
49
- if (!signingKeySecret) {
50
- throw new Error("No signing key found. Re-run `mux init` and generate one!");
51
- }
52
-
53
- // TODO: replace with mux-node-sdk signing when available
54
- const payload = {
55
- role: flags.role,
56
- participant_id: flags.participantId,
57
- kid: this.MuxConfig.signingKeyId,
58
- };
59
-
60
- const jwtOptions: JWT.SignOptions = {
61
- audience: 'rt',
62
- subject: args['space-id'],
63
- algorithm: 'RS256',
64
- noTimestamp: true,
65
- expiresIn: flags.expiresIn,
66
- };
67
-
68
- const key = Buffer.from(signingKeySecret, 'base64');
69
- const jwt = JWT.sign(payload, key, jwtOptions);
70
-
71
- if (flags.raw) {
72
- console.log(jwt);
73
- } else {
74
-
75
- this.log(
76
- chalk`
77
- 🔑 Your JWT for Mux Spaces
78
- {cyan ${jwt}}
79
- `
80
- )
81
-
82
- try {
83
- await clipboard.write(jwt);
84
- this.log(`👉 Copied your JWT to your system clipboard`);
85
- } catch {
86
- this.error('Unable to copy JWT automatically');
87
- }
88
- }
89
- }
90
- }
package/src/config.ts DELETED
@@ -1,13 +0,0 @@
1
- import * as RT from 'runtypes';
2
- export const MuxCliConfigV1 = RT.Record({
3
- configVersion: RT.Literal(1),
4
-
5
- tokenId: RT.String,
6
- tokenSecret: RT.String,
7
-
8
- signingKeyId: RT.String.Or(RT.Undefined),
9
- signingKeySecret: RT.String.Or(RT.Undefined),
10
-
11
- baseUrl: RT.String,
12
- });
13
- export type MuxCliConfigV1 = RT.Static<typeof MuxCliConfigV1>;
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export {run} from '@oclif/command';
2
-
3
- export { default as CommandBase } from './command-bases/base';