omakit 0.1.4 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omakit",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The safe place to find out: everything knowable about an Omarchy Quattro plugin submission before you post it, on your own machine. Agent-first, read-only, posts nothing, zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Maarten Tolhuijs",
@@ -106,9 +106,22 @@ export function token() {
106
106
  return credential().value
107
107
  }
108
108
 
109
- async function get(url, { accept = "application/vnd.github+json" } = {}) {
110
- const headers = { accept, "user-agent": USER_AGENT }
111
- const auth = token()
109
+ /** The one host the borrowed gh credential may be sent to. */
110
+ export const CREDENTIAL_HOST = "api.github.com"
111
+
112
+ async function get(url, { accept } = {}) {
113
+ const { host } = new URL(url)
114
+ // The credential is GitHub's and goes to GitHub's API and nowhere else.
115
+ // Measured before this held: `omakit upgrade` and `doctor` sent the gh
116
+ // token as a bearer to registry.npmjs.org, which answered 401, so both
117
+ // reported "the npm registry did not answer" on every machine with a gh
118
+ // login, and a GitHub credential had left GitHub.
119
+ const authenticated = host === CREDENTIAL_HOST
120
+ const headers = {
121
+ accept: accept || (authenticated ? "application/vnd.github+json" : "application/json"),
122
+ "user-agent": USER_AGENT,
123
+ }
124
+ const auth = authenticated ? token() : null
112
125
  if (auth) headers.authorization = `Bearer ${auth}`
113
126
  let response
114
127
  try {