Skip to content

Commit d7ae6ad

Browse files
authored
feat(cli): mint bearer tokens (#330)
* feat(cli): mint bearer tokens * chore: update transloadit parity baseline * fix(cli): harden auth token * fix: keep transloadit parity + knip happy * refactor(cli): harden auth token + dedupe creds
1 parent 19dda72 commit d7ae6ad

9 files changed

Lines changed: 577 additions & 108 deletions

File tree

.changeset/auth-token-cli.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@transloadit/node': patch
3+
'transloadit': patch
4+
---
5+
6+
feat(cli): add `transloadit auth token` to mint bearer tokens for hosted MCP (with HTTPS/redirect safety guards)

docs/fingerprint/transloadit-baseline.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"packageDir": "/home/kvz/code/node-sdk/packages/transloadit",
33
"tarball": {
4-
"filename": "transloadit-4.7.1.tgz",
5-
"sizeBytes": 1239686,
6-
"sha256": "e0e4926af34a37737feb90f3536be69f1111e38e4525b056e2c72ec4456d0a6b"
4+
"filename": "transloadit-4.7.2.tgz",
5+
"sizeBytes": 1244695,
6+
"sha256": "42d5f0f20b27a3c3a761b43f68b61b4acf5b0c800f723928803f3949246ebfe9"
77
},
88
"packageJson": {
99
"name": "transloadit",
10-
"version": "4.7.1",
10+
"version": "4.7.2",
1111
"main": "./dist/Transloadit.js",
1212
"exports": {
1313
".": "./dist/Transloadit.js",
@@ -128,8 +128,8 @@
128128
},
129129
{
130130
"path": "dist/cli/commands/auth.js",
131-
"sizeBytes": 10190,
132-
"sha256": "882912a557268b70fba276804fecab686e259bb78c167c175c3e1e67cceea3b6"
131+
"sizeBytes": 15785,
132+
"sha256": "3fcef85fa789d41e4620eec82555eb94ca52ae70367d519272103fd6019a7661"
133133
},
134134
{
135135
"path": "dist/alphalib/types/robots/azure-import.js",
@@ -153,8 +153,8 @@
153153
},
154154
{
155155
"path": "dist/cli/commands/BaseCommand.js",
156-
"sizeBytes": 1895,
157-
"sha256": "1141a59a8ec2f47f6e5d4257b81e44fad8f50d693d1d22d6a0d6a2a08b5f8792"
156+
"sizeBytes": 1883,
157+
"sha256": "af4d62f394df456f5137627e8c4f241344fbe7c7796e427bc6ec493de5984762"
158158
},
159159
{
160160
"path": "dist/alphalib/types/bill.js",
@@ -328,8 +328,8 @@
328328
},
329329
{
330330
"path": "dist/cli/helpers.js",
331-
"sizeBytes": 2277,
332-
"sha256": "f503e1fa45e284955f3e10316ceebe417de30abba13d9cde3e5047be89b77bcc"
331+
"sizeBytes": 2625,
332+
"sha256": "8555420c31526195f54151c481bd00d2a1fcf67dacbad3f988a4c6538fa67f21"
333333
},
334334
{
335335
"path": "dist/alphalib/types/robots/html-convert.js",
@@ -388,8 +388,8 @@
388388
},
389389
{
390390
"path": "dist/cli/commands/index.js",
391-
"sizeBytes": 2099,
392-
"sha256": "26ffd3f1d1bf5f9e6ea350cebcb6593fa748bcbc814ee60dcfc7313a97fe54f0"
391+
"sizeBytes": 2145,
392+
"sha256": "b44764be9d6a803669bbc1a937f553566ce91993ed283c7f6d5ef65cbff6b263"
393393
},
394394
{
395395
"path": "dist/inputFiles.js",
@@ -684,7 +684,7 @@
684684
{
685685
"path": "package.json",
686686
"sizeBytes": 2730,
687-
"sha256": "061fbd4b1e3fbbc7ded678f2d27b9ac3e0dbcc903b5e70c31c61166a6a24764e"
687+
"sha256": "818a4a0e1e9d5020e29d5cafcbc584a380fbb264508518835bab2e017f5fd101"
688688
},
689689
{
690690
"path": "dist/alphalib/types/robots/_index.d.ts.map",
@@ -898,13 +898,13 @@
898898
},
899899
{
900900
"path": "dist/cli/commands/auth.d.ts.map",
901-
"sizeBytes": 749,
902-
"sha256": "f31c0a86129f7fa44aed415e85e46a04935801f03140c8d73c57897d2ee609f7"
901+
"sizeBytes": 996,
902+
"sha256": "478ac46eb7ddbe624235a21c0a0a059cdefa91381281198ad51f7bd21c8f1b09"
903903
},
904904
{
905905
"path": "dist/cli/commands/auth.js.map",
906-
"sizeBytes": 9151,
907-
"sha256": "92fb82422a8e746658deb008d95d656a2cb87e86a761ff5dc0776cbda96c7cca"
906+
"sizeBytes": 14501,
907+
"sha256": "891418720d6f855eea37a07ca197c55a9d8d010c905f6c7bdda9ee7f4f9d6332"
908908
},
909909
{
910910
"path": "dist/alphalib/types/robots/azure-import.d.ts.map",
@@ -948,13 +948,13 @@
948948
},
949949
{
950950
"path": "dist/cli/commands/BaseCommand.d.ts.map",
951-
"sizeBytes": 853,
952-
"sha256": "22f956bf0d909d109be49926c456031c783bafccc688056d1911b7440cdf77c3"
951+
"sizeBytes": 854,
952+
"sha256": "7795327eb88bff243fbadaa473286c7d6c4bb24e4d0b11d7d7ff314dc9460112"
953953
},
954954
{
955955
"path": "dist/cli/commands/BaseCommand.js.map",
956-
"sizeBytes": 1740,
957-
"sha256": "14ec91bb62f94bc02328d085cf1d6b7541f3e17d10703c39f85df40969cd84eb"
956+
"sizeBytes": 1771,
957+
"sha256": "ea85d352f6620d0688afa1bb3c82f2c9c09b3bec6c06bfcc29d6d9f14f12578a"
958958
},
959959
{
960960
"path": "dist/alphalib/types/bill.d.ts.map",
@@ -1298,13 +1298,13 @@
12981298
},
12991299
{
13001300
"path": "dist/cli/helpers.d.ts.map",
1301-
"sizeBytes": 1009,
1302-
"sha256": "82e3c44365f968ff76a7424812b2e21fc82a69205c50611242c9fb97990e90f3"
1301+
"sizeBytes": 1177,
1302+
"sha256": "0f65f407f35fe35bc23481feaf7146d051d3946557ae80008228844d563e41d5"
13031303
},
13041304
{
13051305
"path": "dist/cli/helpers.js.map",
1306-
"sizeBytes": 2826,
1307-
"sha256": "6729657286fe0467eab3544fda8f702a9e06a9da8cbedf0083276608ff805c52"
1306+
"sizeBytes": 3067,
1307+
"sha256": "d644704a139a2ac26a8c7a2ba27b7eee939aecd8506d437ed616cc764eabe8c2"
13081308
},
13091309
{
13101310
"path": "dist/alphalib/types/robots/html-convert.d.ts.map",
@@ -1419,12 +1419,12 @@
14191419
{
14201420
"path": "dist/cli/commands/index.d.ts.map",
14211421
"sizeBytes": 198,
1422-
"sha256": "7f72c6762c95dac3b7e6cd256abab44c210c471e40a0558ad20020cf15fdd983"
1422+
"sha256": "3f955192e7d7832d6fd0c8ee0244b153e42c947686425750c7c8c58d6657f2a7"
14231423
},
14241424
{
14251425
"path": "dist/cli/commands/index.js.map",
1426-
"sizeBytes": 1889,
1427-
"sha256": "47f1867c39793eebbafb7229433aff4b573e408690ffdeb11457533a71dd54aa"
1426+
"sizeBytes": 1940,
1427+
"sha256": "1cad8333ee5fd6c34071a6d8528a7b55399be0626baf1754e28453d714836868"
14281428
},
14291429
{
14301430
"path": "dist/inputFiles.d.ts.map",
@@ -2008,8 +2008,8 @@
20082008
},
20092009
{
20102010
"path": "README.md",
2011-
"sizeBytes": 35551,
2012-
"sha256": "442743aa79f063ee5da4e50601debb28b492377b3359aa4c2596f4adefbd372a"
2011+
"sizeBytes": 35827,
2012+
"sha256": "4eeaaee318cb9336246280c4f3247c27de0df83d6738863123f5c9eac9429908"
20132013
},
20142014
{
20152015
"path": "dist/alphalib/types/robots/_index.d.ts",
@@ -2223,13 +2223,13 @@
22232223
},
22242224
{
22252225
"path": "dist/cli/commands/auth.d.ts",
2226-
"sizeBytes": 936,
2227-
"sha256": "20a1d35fb55fad8af33fb6decede3cbf2cd621007fe443d2866e9975bbe23b20"
2226+
"sizeBytes": 1406,
2227+
"sha256": "885d57814cc0ac4f6554576811748beee3902a8ef63b70746a76c22aff2b0acc"
22282228
},
22292229
{
22302230
"path": "src/cli/commands/auth.ts",
2231-
"sizeBytes": 10626,
2232-
"sha256": "b5f4d2404f455ad2e3354cd963a3468bb2d57a1808ce715f715cea1ad87b2245"
2231+
"sizeBytes": 16193,
2232+
"sha256": "42ebd9ee94e5a21001f456c47d9f722f73df6b7b06f5ce82fab857e93b77f70c"
22332233
},
22342234
{
22352235
"path": "dist/alphalib/types/robots/azure-import.d.ts",
@@ -2278,8 +2278,8 @@
22782278
},
22792279
{
22802280
"path": "src/cli/commands/BaseCommand.ts",
2281-
"sizeBytes": 2146,
2282-
"sha256": "d0cab4ebb72ce5d555be82bf3de4ba1f09dd223b71702bc53527928cf1c7ac91"
2281+
"sizeBytes": 2101,
2282+
"sha256": "8716f8a22898d35c025986a31a9234b43a8eaed09f7120b8f6424ff8d045fd50"
22832283
},
22842284
{
22852285
"path": "dist/alphalib/types/bill.d.ts",
@@ -2623,13 +2623,13 @@
26232623
},
26242624
{
26252625
"path": "dist/cli/helpers.d.ts",
2626-
"sizeBytes": 898,
2627-
"sha256": "d225c538d7cd4d73e88045729fc6f59b66de8af9304b039cdd496e1487860eb6"
2626+
"sizeBytes": 1073,
2627+
"sha256": "aeed9d1c1186c561cd846c905bac2d9738e88c80e5527c125f47ad6b332d10ee"
26282628
},
26292629
{
26302630
"path": "src/cli/helpers.ts",
2631-
"sizeBytes": 2799,
2632-
"sha256": "0d43593eb6e5d985287d67fec8e758d8fcc903fd1ce86cc2a9b8152b66998059"
2631+
"sizeBytes": 3340,
2632+
"sha256": "9741aa20b83f837889d248d5b095e6ec2336186bc5ab2b6caa23174950562919"
26332633
},
26342634
{
26352635
"path": "dist/alphalib/types/robots/html-convert.d.ts",
@@ -2748,8 +2748,8 @@
27482748
},
27492749
{
27502750
"path": "src/cli/commands/index.ts",
2751-
"sizeBytes": 2001,
2752-
"sha256": "762f6b157cbb43839b496850ec5918c4e0efb94e88be3c45e06171e3771a7e8f"
2751+
"sizeBytes": 2044,
2752+
"sha256": "b6752fa800c6a91e662b75a0c0973f0ba513f263d4a96d5e46a0d3e1f1a9f828"
27532753
},
27542754
{
27552755
"path": "dist/inputFiles.d.ts",

docs/fingerprint/transloadit-baseline.package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "transloadit",
3-
"version": "4.7.1",
3+
"version": "4.7.2",
44
"description": "Node.js SDK for Transloadit",
55
"homepage": "https://github.com/transloadit/node-sdk/tree/main/packages/node",
66
"bugs": {

packages/node/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ export TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
5757
npx transloadit --help
5858
```
5959

60+
### Minting Bearer Tokens (Hosted MCP)
61+
62+
If you want to connect an agent to the Transloadit-hosted MCP endpoint, mint a short-lived bearer
63+
token via `POST /token`:
64+
65+
```bash
66+
# Prints JSON to stdout (stderr may include npx/npm noise)
67+
npx -y transloadit auth token --aud mcp
68+
```
69+
6070
### Processing Media
6171

6272
Create Assemblies to process files using Assembly Instructions (steps) or Templates:

packages/node/src/cli/commands/BaseCommand.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'dotenv/config'
22
import process from 'node:process'
33
import { Command, Option } from 'clipanion'
44
import { Transloadit as TransloaditClient } from '../../Transloadit.ts'
5-
import { getEnvCredentials } from '../helpers.ts'
5+
import { requireEnvCredentials } from '../helpers.ts'
66
import type { IOutputCtl } from '../OutputCtl.ts'
77
import OutputCtl, { LOG_LEVEL_DEFAULT, LOG_LEVEL_NAMES, parseLogLevel } from '../OutputCtl.ts'
88

@@ -32,17 +32,18 @@ abstract class BaseCommand extends Command {
3232
}
3333

3434
protected setupClient(): boolean {
35-
const creds = getEnvCredentials()
36-
if (!creds) {
37-
this.output.error(
38-
'Please provide API authentication in the environment variables TRANSLOADIT_KEY and TRANSLOADIT_SECRET',
39-
)
35+
const credsResult = requireEnvCredentials()
36+
if (!credsResult.ok) {
37+
this.output.error(credsResult.error)
4038
return false
4139
}
4240

4341
const endpoint = this.endpoint || process.env.TRANSLOADIT_ENDPOINT
4442

45-
this.client = new TransloaditClient({ ...creds, ...(endpoint && { endpoint }) })
43+
this.client = new TransloaditClient({
44+
...credsResult.credentials,
45+
...(endpoint && { endpoint }),
46+
})
4647
return true
4748
}
4849

0 commit comments

Comments
 (0)