@screenshotscout/cli 0.3.0 → 0.4.0

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.
package/README.md CHANGED
@@ -55,7 +55,7 @@ $env:SCREENSHOTSCOUT_ACCESS_KEY = "YOUR_ACCESS_KEY"
55
55
  $env:SCREENSHOTSCOUT_SECRET_KEY = "YOUR_SECRET_KEY"
56
56
  ```
57
57
 
58
- `SCREENSHOTSCOUT_ACCESS_KEY` is required. `SCREENSHOTSCOUT_SECRET_KEY` is optional; omit its assignment for unsigned requests. When the secret key is configured, generated capture URLs and captures sent with `--method get` are signed automatically, while the secret key stays local.
58
+ `SCREENSHOTSCOUT_ACCESS_KEY` is required. `SCREENSHOTSCOUT_SECRET_KEY` is optional; omit its assignment for unsigned requests. When the secret key is configured, generated capture URLs and captures are signed automatically, while the secret key stays local.
59
59
 
60
60
  ## Commands
61
61
 
@@ -77,7 +77,7 @@ screenshotscout capture "https://example.com" \
77
77
  --output screenshot.webp
78
78
  ```
79
79
 
80
- `capture` accepts `--method get` or `--method post`. You can omit `--method` unless you need to select one explicitly, such as `--method get` for signed requests.
80
+ `capture` accepts `--method get` or `--method post`. Without `--method`, it uses POST, or GET when `SCREENSHOTSCOUT_SECRET_KEY` is set. POST requests can't be signed, so `--method post` fails while the secret key is set.
81
81
 
82
82
  ```sh
83
83
  screenshotscout capture "https://example.com" --method post --format webp --output screenshot.webp
@@ -225,7 +225,7 @@ More inline-flag, options-file, POSIX shell, PowerShell, and CI examples are in
225
225
 
226
226
  - Run `screenshotscout --help` or `screenshotscout <command> --help` to check command syntax and current capture-option value shapes.
227
227
  - If the CLI reports that an access key is required, set `SCREENSHOTSCOUT_ACCESS_KEY` in the same process environment that runs the command.
228
- - If the API reports `signature_required`, set the matching `SCREENSHOTSCOUT_SECRET_KEY` and add `--method get`. See [Signed requests](https://screenshotscout.com/docs/signed-requests).
228
+ - If the API reports `signature_required`, set the matching `SCREENSHOTSCOUT_SECRET_KEY`. See [Signed requests](https://screenshotscout.com/docs/signed-requests).
229
229
  - If an option is rejected with exit status `2`, check whether it uses CLI `kebab-case`, whether a boolean uses bare or inline syntax, and whether a singleton flag was repeated.
230
230
  - If an options file is rejected, confirm that it is a JSON object using exact API `snake_case` names and JSON value types.
231
231
  - If a file write fails, confirm that its parent directory exists and is writable.
package/dist/capture.js CHANGED
@@ -1,20 +1,11 @@
1
- import { CliUsageError } from "./cli-usage-error.js";
2
1
  import { parseCaptureCommandInput } from "./input.js";
3
2
  import { writeCaptureResult } from "./result.js";
4
- import { captureWithScreenshotScoutClient, createScreenshotScoutClient, isSecretKeyConfigured, } from "./sdk.js";
5
- const SIGNED_POST_MESSAGE = "SCREENSHOTSCOUT_SECRET_KEY is set, and POST requests can't be signed. Add --method get, or unset SCREENSHOTSCOUT_SECRET_KEY to send an unsigned POST request.";
3
+ import { captureWithScreenshotScoutClient, createScreenshotScoutClient, } from "./sdk.js";
6
4
  /** Run one capture command as a direct input -> SDK -> result adapter. */
7
5
  export async function runCaptureCommand(args, dependencies = {}) {
8
6
  const input = dependencies.inputReader === undefined
9
7
  ? await parseCaptureCommandInput(args)
10
8
  : await parseCaptureCommandInput(args, dependencies.inputReader);
11
- const secretKeyConfigured = dependencies.client === undefined
12
- ? isSecretKeyConfigured()
13
- : dependencies.secretKeyConfigured === true;
14
- // Only GET requests can be signed, and an omitted --method means POST
15
- if (secretKeyConfigured && input.method !== "get") {
16
- throw new CliUsageError(SIGNED_POST_MESSAGE);
17
- }
18
9
  const client = dependencies.client ?? createScreenshotScoutClient();
19
10
  const response = await captureWithScreenshotScoutClient(client, input.targetUrl, input.captureOptions, input.method);
20
11
  if (dependencies.resultIo === undefined) {
package/dist/help.js CHANGED
@@ -26,7 +26,7 @@ export function captureCommandHelp() {
26
26
 
27
27
  CLI controls:
28
28
  --options <path|-> Read a snake_case JSON options object from a file or standard input.
29
- --method <get|post> Select the request method (default post). Signed captures need get.
29
+ --method <get|post> Select the request method (default post, or get when SCREENSHOTSCOUT_SECRET_KEY is set).
30
30
  -o, --output <path|-> Write the response to a file or standard output.
31
31
  --help Show this help.
32
32
 
package/dist/sdk.js CHANGED
@@ -1,21 +1,11 @@
1
1
  import { CaptureHttpMethod, ScreenshotScoutClient, } from "@screenshotscout/sdk";
2
- const DEFAULT_CLIENT_FACTORY = (options) => new ScreenshotScoutClient(options);
3
- /** Construct the official SDK client from the two approved environment names. */
4
- export function createScreenshotScoutClient(environment = process.env, clientFactory = DEFAULT_CLIENT_FACTORY) {
5
- const accessKey = environment.SCREENSHOTSCOUT_ACCESS_KEY;
6
- const secretKey = environment.SCREENSHOTSCOUT_SECRET_KEY;
7
- const options = {
8
- // Missing and invalid values deliberately reach the SDK's own validation.
9
- accessKey: accessKey,
10
- ...(secretKey === undefined ? {} : { secretKey }),
11
- };
12
- return clientFactory(options);
13
- }
14
- /** Whether the environment gives the client a secret key, as createScreenshotScoutClient passes it. */
15
- export function isSecretKeyConfigured(environment = process.env) {
16
- return environment.SCREENSHOTSCOUT_SECRET_KEY !== undefined;
2
+ // The SDK reads SCREENSHOTSCOUT_ACCESS_KEY and SCREENSHOTSCOUT_SECRET_KEY itself.
3
+ const DEFAULT_CLIENT_FACTORY = () => new ScreenshotScoutClient();
4
+ /** Construct the official SDK client, which takes its keys from the environment. */
5
+ export function createScreenshotScoutClient(clientFactory = DEFAULT_CLIENT_FACTORY) {
6
+ return clientFactory();
17
7
  }
18
- /** Make one capture call with only an explicitly selected request method. */
8
+ /** Make one capture call with only an explicitly selected request method; the SDK picks the default. */
19
9
  export function captureWithScreenshotScoutClient(client, targetUrl, captureOptions, method) {
20
10
  if (method === undefined) {
21
11
  return client.capture(targetUrl, captureOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screenshotscout/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Official command-line interface for the Screenshot Scout screenshot API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -49,7 +49,7 @@
49
49
  "node": ">=22"
50
50
  },
51
51
  "dependencies": {
52
- "@screenshotscout/sdk": "0.4.0"
52
+ "@screenshotscout/sdk": "0.5.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@eslint/js": "10.0.1",