transloadit 4.8.0 → 4.8.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 (57) hide show
  1. package/README.md +92 -43
  2. package/dist/bearerToken.d.ts +1 -0
  3. package/dist/bearerToken.d.ts.map +1 -1
  4. package/dist/bearerToken.js +5 -3
  5. package/dist/bearerToken.js.map +1 -1
  6. package/dist/cli/commands/BaseCommand.d.ts +0 -1
  7. package/dist/cli/commands/BaseCommand.d.ts.map +1 -1
  8. package/dist/cli/commands/BaseCommand.js +7 -9
  9. package/dist/cli/commands/BaseCommand.js.map +1 -1
  10. package/dist/cli/commands/auth.d.ts.map +1 -1
  11. package/dist/cli/commands/auth.js +49 -29
  12. package/dist/cli/commands/auth.js.map +1 -1
  13. package/dist/cli/generateIntentDocs.d.ts.map +1 -1
  14. package/dist/cli/generateIntentDocs.js +9 -7
  15. package/dist/cli/generateIntentDocs.js.map +1 -1
  16. package/dist/cli/helpers.d.ts +19 -4
  17. package/dist/cli/helpers.d.ts.map +1 -1
  18. package/dist/cli/helpers.js +232 -10
  19. package/dist/cli/helpers.js.map +1 -1
  20. package/dist/cli/intentCommands.d.ts.map +1 -1
  21. package/dist/cli/intentCommands.js +11 -7
  22. package/dist/cli/intentCommands.js.map +1 -1
  23. package/dist/cli/intentRuntime.d.ts +17 -2
  24. package/dist/cli/intentRuntime.d.ts.map +1 -1
  25. package/dist/cli/intentRuntime.js +163 -33
  26. package/dist/cli/intentRuntime.js.map +1 -1
  27. package/dist/cli/semanticIntents/imageDescribe.d.ts +2 -1
  28. package/dist/cli/semanticIntents/imageDescribe.d.ts.map +1 -1
  29. package/dist/cli/semanticIntents/imageDescribe.js +5 -4
  30. package/dist/cli/semanticIntents/imageDescribe.js.map +1 -1
  31. package/dist/cli/semanticIntents/imageGenerate.d.ts +1 -0
  32. package/dist/cli/semanticIntents/imageGenerate.d.ts.map +1 -1
  33. package/dist/cli/semanticIntents/imageGenerate.js +4 -3
  34. package/dist/cli/semanticIntents/imageGenerate.js.map +1 -1
  35. package/dist/cli/semanticIntents/index.d.ts +1 -0
  36. package/dist/cli/semanticIntents/index.d.ts.map +1 -1
  37. package/dist/cli/semanticIntents/index.js.map +1 -1
  38. package/dist/cli/semanticIntents/markdownPdf.d.ts.map +1 -1
  39. package/dist/cli/semanticIntents/markdownPdf.js +2 -1
  40. package/dist/cli/semanticIntents/markdownPdf.js.map +1 -1
  41. package/dist/cli.d.ts +0 -1
  42. package/dist/cli.d.ts.map +1 -1
  43. package/dist/cli.js +3 -2
  44. package/dist/cli.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/bearerToken.ts +14 -3
  47. package/src/cli/commands/BaseCommand.ts +7 -9
  48. package/src/cli/commands/auth.ts +66 -32
  49. package/src/cli/generateIntentDocs.ts +10 -7
  50. package/src/cli/helpers.ts +278 -13
  51. package/src/cli/intentCommands.ts +11 -7
  52. package/src/cli/intentRuntime.ts +214 -33
  53. package/src/cli/semanticIntents/imageDescribe.ts +5 -4
  54. package/src/cli/semanticIntents/imageGenerate.ts +4 -3
  55. package/src/cli/semanticIntents/index.ts +1 -0
  56. package/src/cli/semanticIntents/markdownPdf.ts +2 -1
  57. package/src/cli.ts +3 -2
package/README.md CHANGED
@@ -51,22 +51,66 @@ This package includes a full-featured CLI for interacting with Transloadit from
51
51
 
52
52
  ### Quick Start
53
53
 
54
+ Pick one auth setup and then run the CLI.
55
+
56
+ Use shell env vars:
57
+
54
58
  ```bash
55
- # Set your credentials
56
59
  export TRANSLOADIT_KEY="YOUR_TRANSLOADIT_KEY"
57
60
  export TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
61
+ ```
58
62
 
59
- # See all available commands
63
+ Or create a reusable home credentials file:
64
+
65
+ ```bash
66
+ mkdir -p ~/.transloadit
67
+ cat > ~/.transloadit/credentials <<'EOF'
68
+ TRANSLOADIT_KEY="YOUR_TRANSLOADIT_KEY"
69
+ TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
70
+ EOF
71
+ chmod 600 ~/.transloadit/credentials
72
+ ```
73
+
74
+ Then see all available commands:
75
+
76
+ ```bash
60
77
  npx -y @transloadit/node --help
61
78
  ```
62
79
 
63
80
  The CLI binary is still called `transloadit`, so command examples below may use
64
81
  `npx transloadit ...`.
65
82
 
83
+ ### Credential Resolution
84
+
85
+ The CLI resolves authentication in this order:
86
+
87
+ 1. Shell environment variables such as `TRANSLOADIT_KEY`, `TRANSLOADIT_SECRET`, and `TRANSLOADIT_AUTH_TOKEN`
88
+ 2. The current working directory `.env`
89
+ 3. `~/.transloadit/credentials`
90
+
91
+ The home credentials file uses dotenv syntax. It is meant for user-level CLI use, so Intents and
92
+ other commands work from any directory on your machine without having to export credentials first.
93
+
94
+ Example `~/.transloadit/credentials`:
95
+
96
+ ```env
97
+ TRANSLOADIT_KEY="YOUR_TRANSLOADIT_KEY"
98
+ TRANSLOADIT_SECRET="YOUR_TRANSLOADIT_SECRET"
99
+ # Optional:
100
+ # TRANSLOADIT_ENDPOINT="https://api2.transloadit.com"
101
+ # TRANSLOADIT_AUTH_TOKEN="YOUR_BEARER_TOKEN"
102
+ ```
103
+
104
+ If you want to use a different path, set `TRANSLOADIT_CREDENTIALS_FILE=/abs/path/to/credentials.env`.
105
+
106
+ Most commands can authenticate with either `TRANSLOADIT_AUTH_TOKEN` or `TRANSLOADIT_KEY` +
107
+ `TRANSLOADIT_SECRET`. Commands that mint bearer tokens or generate signatures still require
108
+ `TRANSLOADIT_KEY` and `TRANSLOADIT_SECRET`.
109
+
66
110
  ### Minting Bearer Tokens (Hosted MCP)
67
111
 
68
112
  If you want to connect an agent to the Transloadit-hosted MCP endpoint, mint a short-lived bearer
69
- token via `POST /token`:
113
+ token via `POST /token`. This command also uses the same credential resolution order above:
70
114
 
71
115
  ```bash
72
116
  # Prints JSON to stdout (stderr may include npx/npm noise)
@@ -93,6 +137,8 @@ The full generated intent reference also lives in [`docs/intent-commands.md`](./
93
137
  #### At a glance
94
138
 
95
139
  Intent commands are the fastest path to common one-off tasks from the CLI.
140
+ Authentication is resolved in this order: shell environment, the current working directory `.env`, then `~/.transloadit/credentials`.
141
+ The home credentials file uses dotenv syntax and can include `TRANSLOADIT_KEY`, `TRANSLOADIT_SECRET`, `TRANSLOADIT_ENDPOINT`, and `TRANSLOADIT_AUTH_TOKEN`.
96
142
  Use `--print-urls` when you want temporary result URLs without downloading locally.
97
143
  All intent commands also support the global CLI flags `--json`, `--log-level`, `--endpoint`, and `--help`.
98
144
 
@@ -117,7 +163,7 @@ All intent commands also support the global CLI flags `--json`, `--log-level`, `
117
163
  | `file compress` | Compress files | file, dir, URL, base64 | file |
118
164
  | `file decompress` | Decompress archives | file, dir, URL, base64 | directory |
119
165
 
120
- > At least one of `--out` or `--print-urls` is required on every intent command.
166
+ > If you omit `--output`, the CLI writes next to a single local file input when it can, otherwise it falls back to the current working directory. Use `--print-urls` alone when you want URLs without downloading locally.
121
167
 
122
168
  #### Shared flags
123
169
 
@@ -129,14 +175,14 @@ These flags are available across many intent commands, so the per-command sectio
129
175
  | --- | --- | --- | --- | --- |
130
176
  | `--input, -i` | `path \| dir \| url \| -` | varies | `input.file` | Provide an input path, directory, URL, or - for stdin |
131
177
  | `--input-base64` | `base64 \| data URL` | no | `data:text/plain;base64,SGVsbG8=` | Provide base64-encoded input content directly |
132
- | `--out, -o` | `path` | yes* | `output.file` | Write the result to this path or directory |
178
+ | `--output, -o` | `path` | no | `output.file` | Write the result to this path or directory. If omitted, the CLI infers a local output path. |
133
179
  | `--print-urls` | `boolean` | no | `false` | Print temporary result URLs after completion |
134
180
 
135
181
  **Shared no-input output flags**
136
182
 
137
183
  | Flag | Type | Required | Example | Description |
138
184
  | --- | --- | --- | --- | --- |
139
- | `--out, -o` | `path` | yes* | `output.file` | Write the result to this path |
185
+ | `--output, -o` | `path` | no | `output.file` | Write the result to this path. If omitted, the CLI infers a local output path. |
140
186
  | `--print-urls` | `boolean` | no | `false` | Print temporary result URLs after completion |
141
187
 
142
188
  **Shared processing flags**
@@ -202,18 +248,18 @@ npx transloadit image generate [--input <path|dir|url|->] [options]
202
248
 
203
249
  ```bash
204
250
  # Generate an image from text
205
- transloadit image generate --prompt "A red bicycle in a studio" --out output.png
251
+ transloadit image generate --prompt "A red bicycle in a studio" --output output.png
206
252
  # Guide generation with one input image
207
- transloadit image generate --input subject.jpg --prompt "Place subject.jpg on a magazine cover" --out output.png
253
+ transloadit image generate --input subject.jpg --prompt "Place subject.jpg on a magazine cover" --output output.png
208
254
  # Guide generation with multiple input images
209
- transloadit image generate --input person1.jpg --input person2.jpg --input background.jpg --prompt "Place person1.jpg feeding person2.jpg in front of background.jpg" --out output.png
255
+ transloadit image generate --input person1.jpg --input person2.jpg --input background.jpg --prompt "Place person1.jpg feeding person2.jpg in front of background.jpg" --output output.png
210
256
  ```
211
257
 
212
258
  #### `preview generate`
213
259
 
214
260
  Generate a preview thumbnail
215
261
 
216
- Runs `/file/preview` on each input file and writes the result to `--out`.
262
+ Runs `/file/preview` on each input file and writes the result to `--output`.
217
263
 
218
264
  **Usage**
219
265
 
@@ -266,14 +312,14 @@ npx transloadit preview generate --input <path|dir|url|-> [options]
266
312
  **Examples**
267
313
 
268
314
  ```bash
269
- transloadit preview generate --input input.file --out output.file
315
+ transloadit preview generate --input input.file --output output.file
270
316
  ```
271
317
 
272
318
  #### `image remove-background`
273
319
 
274
320
  Remove the background from images
275
321
 
276
- Runs `/image/bgremove` on each input file and writes the result to `--out`.
322
+ Runs `/image/bgremove` on each input file and writes the result to `--output`.
277
323
 
278
324
  **Usage**
279
325
 
@@ -305,14 +351,14 @@ npx transloadit image remove-background --input <path|dir|url|-> [options]
305
351
  **Examples**
306
352
 
307
353
  ```bash
308
- transloadit image remove-background --input input.png --out output.png
354
+ transloadit image remove-background --input input.png --output output.png
309
355
  ```
310
356
 
311
357
  #### `image optimize`
312
358
 
313
359
  Optimize images without quality loss
314
360
 
315
- Runs `/image/optimize` on each input file and writes the result to `--out`.
361
+ Runs `/image/optimize` on each input file and writes the result to `--output`.
316
362
 
317
363
  **Usage**
318
364
 
@@ -345,14 +391,14 @@ npx transloadit image optimize --input <path|dir|url|-> [options]
345
391
  **Examples**
346
392
 
347
393
  ```bash
348
- transloadit image optimize --input input.png --out output.png
394
+ transloadit image optimize --input input.png --output output.png
349
395
  ```
350
396
 
351
397
  #### `image resize`
352
398
 
353
399
  Convert, resize, or watermark images
354
400
 
355
- Runs `/image/resize` on each input file and writes the result to `--out`.
401
+ Runs `/image/resize` on each input file and writes the result to `--output`.
356
402
 
357
403
  **Usage**
358
404
 
@@ -426,14 +472,14 @@ npx transloadit image resize --input <path|dir|url|-> [options]
426
472
  **Examples**
427
473
 
428
474
  ```bash
429
- transloadit image resize --input input.png --out output.png
475
+ transloadit image resize --input input.png --output output.png
430
476
  ```
431
477
 
432
478
  #### `document convert`
433
479
 
434
480
  Convert documents into different formats
435
481
 
436
- Runs `/document/convert` on each input file and writes the result to `--out`.
482
+ Runs `/document/convert` on each input file and writes the result to `--output`.
437
483
 
438
484
  **Usage**
439
485
 
@@ -470,14 +516,14 @@ npx transloadit document convert --input <path|dir|url|-> [options]
470
516
  **Examples**
471
517
 
472
518
  ```bash
473
- transloadit document convert --input input.pdf --format pdf --out output.pdf
519
+ transloadit document convert --input input.pdf --format pdf --output output.pdf
474
520
  ```
475
521
 
476
522
  #### `document optimize`
477
523
 
478
524
  Reduce PDF file size
479
525
 
480
- Runs `/document/optimize` on each input file and writes the result to `--out`.
526
+ Runs `/document/optimize` on each input file and writes the result to `--output`.
481
527
 
482
528
  **Usage**
483
529
 
@@ -512,14 +558,14 @@ npx transloadit document optimize --input <path|dir|url|-> [options]
512
558
  **Examples**
513
559
 
514
560
  ```bash
515
- transloadit document optimize --input input.pdf --out output.pdf
561
+ transloadit document optimize --input input.pdf --output output.pdf
516
562
  ```
517
563
 
518
564
  #### `document auto-rotate`
519
565
 
520
566
  Auto-rotate documents to the correct orientation
521
567
 
522
- Runs `/document/autorotate` on each input file and writes the result to `--out`.
568
+ Runs `/document/autorotate` on each input file and writes the result to `--output`.
523
569
 
524
570
  **Usage**
525
571
 
@@ -542,14 +588,14 @@ npx transloadit document auto-rotate --input <path|dir|url|-> [options]
542
588
  **Examples**
543
589
 
544
590
  ```bash
545
- transloadit document auto-rotate --input input.pdf --out output.pdf
591
+ transloadit document auto-rotate --input input.pdf --output output.pdf
546
592
  ```
547
593
 
548
594
  #### `document thumbs`
549
595
 
550
596
  Extract thumbnail images from documents
551
597
 
552
- Runs `/document/thumbs` on each input file and writes the results to `--out`.
598
+ Runs `/document/thumbs` on each input file and writes the results to `--output`.
553
599
 
554
600
  **Usage**
555
601
 
@@ -592,14 +638,14 @@ npx transloadit document thumbs --input <path|dir|url|-> [options]
592
638
  **Examples**
593
639
 
594
640
  ```bash
595
- transloadit document thumbs --input input.pdf --out output/
641
+ transloadit document thumbs --input input.pdf --output output/
596
642
  ```
597
643
 
598
644
  #### `audio waveform`
599
645
 
600
646
  Generate waveform images from audio
601
647
 
602
- Runs `/audio/waveform` on each input file and writes the result to `--out`.
648
+ Runs `/audio/waveform` on each input file and writes the result to `--output`.
603
649
 
604
650
  **Usage**
605
651
 
@@ -660,14 +706,14 @@ npx transloadit audio waveform --input <path|dir|url|-> [options]
660
706
  **Examples**
661
707
 
662
708
  ```bash
663
- transloadit audio waveform --input input.mp3 --out output.png
709
+ transloadit audio waveform --input input.mp3 --output output.png
664
710
  ```
665
711
 
666
712
  #### `text speak`
667
713
 
668
714
  Speak text
669
715
 
670
- Runs `/text/speak` on each input file and writes the result to `--out`.
716
+ Runs `/text/speak` on each input file and writes the result to `--output`.
671
717
 
672
718
  **Usage**
673
719
 
@@ -700,14 +746,14 @@ npx transloadit text speak [--input <path|dir|url|->] [options]
700
746
  **Examples**
701
747
 
702
748
  ```bash
703
- transloadit text speak --input input.pdf --provider aws --out output.mp3
749
+ transloadit text speak --input input.pdf --provider aws --output output.mp3
704
750
  ```
705
751
 
706
752
  #### `video thumbs`
707
753
 
708
754
  Extract thumbnails from videos
709
755
 
710
- Runs `/video/thumbs` on each input file and writes the results to `--out`.
756
+ Runs `/video/thumbs` on each input file and writes the results to `--output`.
711
757
 
712
758
  **Usage**
713
759
 
@@ -745,14 +791,14 @@ npx transloadit video thumbs --input <path|dir|url|-> [options]
745
791
  **Examples**
746
792
 
747
793
  ```bash
748
- transloadit video thumbs --input input.mp4 --out output/
794
+ transloadit video thumbs --input input.mp4 --output output/
749
795
  ```
750
796
 
751
797
  #### `video encode-hls`
752
798
 
753
799
  Run builtin/encode-hls-video@latest
754
800
 
755
- Runs the `builtin/encode-hls-video@latest` template and writes the outputs to `--out`.
801
+ Runs the `builtin/encode-hls-video@latest` template and writes the outputs to `--output`.
756
802
 
757
803
  **Usage**
758
804
 
@@ -775,14 +821,14 @@ npx transloadit video encode-hls --input <path|dir|url|-> [options]
775
821
  **Examples**
776
822
 
777
823
  ```bash
778
- transloadit video encode-hls --input input.mp4 --out output/
824
+ transloadit video encode-hls --input input.mp4 --output output/
779
825
  ```
780
826
 
781
827
  #### `image describe`
782
828
 
783
829
  Describe images as labels or publishable text fields
784
830
 
785
- Generates image labels through `/image/describe`, or structured altText/title/caption/description through `/ai/chat`, then writes the JSON result to `--out`.
831
+ Generates image labels through `/image/describe`, or structured altText/title/caption/description through `/ai/chat`, then writes the JSON result to `--output`.
786
832
 
787
833
  **Usage**
788
834
 
@@ -814,11 +860,11 @@ npx transloadit image describe --input <path|dir|url|-> [options]
814
860
 
815
861
  ```bash
816
862
  # Describe an image as labels
817
- transloadit image describe --input hero.jpg --out labels.json
863
+ transloadit image describe --input hero.jpg --output labels.json
818
864
  # Generate WordPress-ready fields
819
- transloadit image describe --input hero.jpg --for wordpress --out fields.json
865
+ transloadit image describe --input hero.jpg --for wordpress --output fields.json
820
866
  # Request a custom field set
821
- transloadit image describe --input hero.jpg --fields altText,title,caption --out fields.json
867
+ transloadit image describe --input hero.jpg --fields altText,title,caption --output fields.json
822
868
  ```
823
869
 
824
870
  #### `markdown pdf`
@@ -856,7 +902,7 @@ npx transloadit markdown pdf --input <path|dir|url|-> [options]
856
902
 
857
903
  ```bash
858
904
  # Render a Markdown file as a PDF file
859
- transloadit markdown pdf --input README.md --out README.pdf
905
+ transloadit markdown pdf --input README.md --output README.pdf
860
906
  # Print a temporary result URL without downloading locally
861
907
  transloadit markdown pdf --input README.md --print-urls
862
908
  ```
@@ -896,7 +942,7 @@ npx transloadit markdown docx --input <path|dir|url|-> [options]
896
942
 
897
943
  ```bash
898
944
  # Render a Markdown file as a DOCX file
899
- transloadit markdown docx --input README.md --out README.docx
945
+ transloadit markdown docx --input README.md --output README.docx
900
946
  # Print a temporary result URL without downloading locally
901
947
  transloadit markdown docx --input README.md --print-urls
902
948
  ```
@@ -905,7 +951,7 @@ transloadit markdown docx --input README.md --print-urls
905
951
 
906
952
  Compress files
907
953
 
908
- Runs `/file/compress` for the provided inputs and writes the result to `--out`.
954
+ Runs `/file/compress` for the provided inputs and writes the result to `--output`.
909
955
 
910
956
  **Usage**
911
957
 
@@ -940,14 +986,14 @@ npx transloadit file compress --input <path|dir|url|-> [options]
940
986
  **Examples**
941
987
 
942
988
  ```bash
943
- transloadit file compress --input input.file --out output.file
989
+ transloadit file compress --input input.file --output output.file
944
990
  ```
945
991
 
946
992
  #### `file decompress`
947
993
 
948
994
  Decompress archives
949
995
 
950
- Runs `/file/decompress` on each input file and writes the results to `--out`.
996
+ Runs `/file/decompress` on each input file and writes the results to `--output`.
951
997
 
952
998
  **Usage**
953
999
 
@@ -977,7 +1023,7 @@ npx transloadit file decompress --input <path|dir|url|-> [options]
977
1023
  **Examples**
978
1024
 
979
1025
  ```bash
980
- transloadit file decompress --input input.file --out output/
1026
+ transloadit file decompress --input input.file --output output/
981
1027
  ```
982
1028
 
983
1029
  <!-- GENERATED_INTENT_DOCS:END -->
@@ -1762,3 +1808,6 @@ See [CONTRIBUTING](./CONTRIBUTING.md).
1762
1808
 
1763
1809
 
1764
1810
 
1811
+
1812
+
1813
+
@@ -6,6 +6,7 @@ export type BearerTokenResponse = {
6
6
  scope?: string;
7
7
  };
8
8
  export type MintBearerTokenOptions = {
9
+ allowProcessEnvEndpointFallback?: boolean;
9
10
  endpoint?: string;
10
11
  aud?: BearerTokenAudience | string;
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bearerToken.d.ts","sourceRoot":"","sources":["../src/bearerToken.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,QAAQ,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAA;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GACpD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AA2FhC,wBAAsB,8BAA8B,CAClD,WAAW,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACpD,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,qBAAqB,CAAC,CAwFhC"}
1
+ {"version":3,"file":"bearerToken.d.ts","sourceRoot":"","sources":["../src/bearerToken.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,QAAQ,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAA;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GACpD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAkGhC,wBAAsB,8BAA8B,CAClD,WAAW,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EACpD,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,qBAAqB,CAAC,CA2FhC"}
@@ -15,8 +15,10 @@ const tokenSuccessSchema = z
15
15
  .passthrough();
16
16
  const buildBasicAuthHeaderValue = (credentials) => `Basic ${Buffer.from(`${credentials.authKey}:${credentials.authSecret}`, 'utf8').toString('base64')}`;
17
17
  const isLoopbackHost = (hostname) => hostname === 'localhost' || hostname === '::1' || hostname.startsWith('127.');
18
- const normalizeTokenBaseEndpoint = (raw) => {
19
- const baseRaw = (raw || process.env.TRANSLOADIT_ENDPOINT || 'https://api2.transloadit.com').trim();
18
+ const normalizeTokenBaseEndpoint = (raw, allowProcessEnvEndpointFallback = true) => {
19
+ const baseRaw = (raw ||
20
+ (allowProcessEnvEndpointFallback ? process.env.TRANSLOADIT_ENDPOINT : undefined) ||
21
+ 'https://api2.transloadit.com').trim();
20
22
  let url;
21
23
  try {
22
24
  url = new URL(baseRaw);
@@ -73,7 +75,7 @@ const normalizeScopeInput = (input) => {
73
75
  return out.length > 0 ? out.join(' ') : undefined;
74
76
  };
75
77
  export async function mintBearerTokenWithCredentials(credentials, options = {}) {
76
- const endpointResult = normalizeTokenBaseEndpoint(options.endpoint);
78
+ const endpointResult = normalizeTokenBaseEndpoint(options.endpoint, options.allowProcessEnvEndpointFallback);
77
79
  if (!endpointResult.ok) {
78
80
  return { ok: false, error: endpointResult.error };
79
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bearerToken.js","sourceRoot":"","sources":["../src/bearerToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA2BvB,MAAM,gBAAgB,GAAG,CAAC;KACvB,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC;KACD,WAAW,EAAE,CAAA;AAEhB,MAAM,kBAAkB,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;IAC1C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC;KACD,WAAW,EAAE,CAAA;AAEhB,MAAM,yBAAyB,GAAG,CAAC,WAAoD,EAAU,EAAE,CACjG,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG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EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACzC,CAAC;IAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAC1D,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO;gBAC7B,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE;gBAC1D,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK;SAC3B,CAAA;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,yBAAyB,GAAG,CAAC,MAAM,MAAM,OAAO,IAAI,GAAG,CAAC,UAAU,EAAE;KAC5E,CAAA;AACH,CAAC"}
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
  import { Command } from 'clipanion';
3
2
  import { Transloadit as TransloaditClient } from '../../Transloadit.ts';
4
3
  import type { IOutputCtl } from '../OutputCtl.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/BaseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGjD,uBAAe,WAAY,SAAQ,OAAO;IACxC,cAAc,qBAEZ;IAEF,IAAI,UAEF;IAEF,QAAQ,qBAGN;IAEF,SAAS,CAAC,MAAM,EAAG,UAAU,CAAA;IAC7B,SAAS,CAAC,MAAM,EAAG,iBAAiB,CAAA;IAEpC,SAAS,CAAC,WA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AAsB,sBAAuB,SAAQ,WAAW;IAC/C,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKrD,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CACtD"}
@@ -1,8 +1,6 @@
1
- import 'dotenv/config';
2
- import process from 'node:process';
3
1
  import { Command, Option } from 'clipanion';
4
2
  import { Transloadit as TransloaditClient } from "../../Transloadit.js";
5
- import { requireEnvCredentials } from "../helpers.js";
3
+ import { buildMissingAuthMessage, resolveCliConfig } from "../helpers.js";
6
4
  import OutputCtl, { LOG_LEVEL_DEFAULT, LOG_LEVEL_NAMES, parseLogLevel } from "../OutputCtl.js";
7
5
  class BaseCommand extends Command {
8
6
  logLevelOption = Option.String('-l,--log-level', {
@@ -12,7 +10,7 @@ class BaseCommand extends Command {
12
10
  description: 'Output in JSON format',
13
11
  });
14
12
  endpoint = Option.String('--endpoint', {
15
- description: 'API endpoint URL (default: https://api2.transloadit.com, or TRANSLOADIT_ENDPOINT env var)',
13
+ description: 'API endpoint URL (default: https://api2.transloadit.com, or TRANSLOADIT_ENDPOINT from the environment, .env, or ~/.transloadit/credentials)',
16
14
  });
17
15
  output;
18
16
  client;
@@ -24,14 +22,14 @@ class BaseCommand extends Command {
24
22
  });
25
23
  }
26
24
  setupClient() {
27
- const credsResult = requireEnvCredentials();
28
- if (!credsResult.ok) {
29
- this.output.error(credsResult.error);
25
+ const config = resolveCliConfig();
26
+ if (config.auth == null) {
27
+ this.output.error(config.loadError ?? buildMissingAuthMessage());
30
28
  return false;
31
29
  }
32
- const endpoint = this.endpoint || process.env.TRANSLOADIT_ENDPOINT;
30
+ const endpoint = this.endpoint || config.endpoint;
33
31
  this.client = new TransloaditClient({
34
- ...credsResult.credentials,
32
+ ...config.auth,
35
33
  ...(endpoint && { endpoint }),
36
34
  });
37
35
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseCommand.js","sourceRoot":"","sources":["../../../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