@heroku/sdk 0.10.0 → 0.11.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
@@ -16,7 +16,7 @@ The simplest entry point is the `HerokuSDK` class. It exposes both the Platform
16
16
  import { HerokuSDK } from '@heroku/sdk'
17
17
  import { appExtensions } from '@heroku/sdk/extensions/platform'
18
18
 
19
- // Reads token from HEROKU_API_KEY or ~/.netrc
19
+ // Zero-arg reads the token from HEROKU_API_KEY (see Authentication below)
20
20
  const sdk = new HerokuSDK({ extensions: [appExtensions] })
21
21
 
22
22
  // Upstream route (auto-generated from the API spec)
@@ -49,6 +49,40 @@ You can also pass options directly:
49
49
  const sdk = new HerokuSDK({ clientOptions: { token: 'your-api-token' } })
50
50
  ```
51
51
 
52
+ ### Authentication
53
+
54
+ The SDK core is transport-agnostic: it reads no local files or keychains itself,
55
+ so it also runs in the browser. Token resolution is handled by
56
+ `@heroku/heroku-fetch`, which has a single default and otherwise defers to
57
+ whatever you pass in:
58
+
59
+ 1. **`HEROKU_API_KEY` (the default)** — with no explicit token, heroku-fetch's
60
+ default provider reads `HEROKU_API_KEY` from the environment, so a zero-arg
61
+ `new HerokuSDK()` is authenticated whenever that variable is set.
62
+ 2. **An explicit `token` (opt in to anything else)** — pass `clientOptions.token`
63
+ (or a per-service `clientOptionsByService`) and the SDK uses it instead of the
64
+ `HEROKU_API_KEY` default. This is how you authenticate from any other
65
+ credential source — for example a token stored by `heroku login`, which the
66
+ Heroku CLI resolves and injects itself (see the note below).
67
+
68
+ > **Note:** To authenticate as a logged-in Heroku CLI user, resolve the stored
69
+ > token in your (Node) application with
70
+ > [`@heroku/heroku-credential-manager`](https://github.com/heroku/heroku-credential-manager)
71
+ > and pass it in:
72
+ >
73
+ > ```ts
74
+ > import { getAuth } from '@heroku/heroku-credential-manager'
75
+ > import { HerokuSDK } from '@heroku/sdk'
76
+ >
77
+ > // account: your Heroku login email; host: the API host (usually api.heroku.com)
78
+ > const { token } = await getAuth(account, 'api.heroku.com')
79
+ > const sdk = new HerokuSDK({ clientOptions: { token } })
80
+ > ```
81
+ >
82
+ > This keeps keychain/filesystem access in the Node consumer (CLI, MCP server,
83
+ > VS Code extension) rather than in the SDK core, so the SDK stays usable in the
84
+ > browser.
85
+
52
86
  Common client options apply to every service. In particular, a common `baseUrl`
53
87
  overrides every service's default host, including Metrics and Repositories. Use
54
88
  shallow per-service overrides when only specific services should use a host or
@@ -6,7 +6,7 @@ export function createMetricsClient(options = {}) {
6
6
  // Metrics is a distinct host that heroku-fetch does not model as a first-class
7
7
  // service, so we use `service: 'custom'` with an explicit base URL. Auth (bearer
8
8
  // token) is resolved by heroku-fetch exactly as for platform/data — same
9
- // HEROKU_API_KEY / netrc source, shared across services on one SDK instance.
9
+ // HEROKU_API_KEY / explicit-token source, shared across services on one SDK instance.
10
10
  //
11
11
  // Unlike platform/data, `service: 'custom'` sends no default Accept header, so we
12
12
  // set `application/vnd.heroku+json; version=3` explicitly to match what meetas
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Heroku SDK",
5
5
  "author": "Heroku",
6
6
  "type": "module",
@@ -154,7 +154,7 @@
154
154
  "vitest": "^4.1.4"
155
155
  },
156
156
  "dependencies": {
157
- "@heroku/heroku-fetch": "^0.1.4",
157
+ "@heroku/heroku-fetch": "^0.2.0",
158
158
  "@heroku/types": "^5.0.0",
159
159
  "debug": "^4.4.0"
160
160
  }