opencode-muse-auth 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -36,7 +36,9 @@ automatically to `muse-*` model ids):
36
36
  - **Login** — Meta device-code exchange (RFC 8628) inside `/connect`, then
37
37
  mints the stable account-bound inference key via the Model API. The key is
38
38
  cached locally (`~/.config/opencode/muse-code-sub.json`, owner-only
39
- permissions where supported) and never printed.
39
+ permissions where supported) and never printed. The cache stores exactly
40
+ `apiKey`, `accountId`, and `email` — the OAuth access token from the
41
+ login flow is kept in memory only and never written to disk.
40
42
  - **Runtime** — an auth `loader` injects the cached key on every startup.
41
43
  The mint endpoint is aggressively rate-limited, so the plugin never
42
44
  re-mints on its own; re-run `/connect` only if access is revoked (401).
package/dist/auth.d.ts CHANGED
@@ -17,6 +17,12 @@ export interface MintedCredential {
17
17
  accountId: string;
18
18
  email?: string;
19
19
  }
20
+ /** The only fields ever written to the credential cache. */
21
+ export interface CachedCredential {
22
+ apiKey: string;
23
+ accountId: string;
24
+ email?: string;
25
+ }
20
26
  export declare function readCache(path?: string): Promise<string>;
21
27
  export declare function writeCache(credentials: MintedCredential, path?: string): Promise<void>;
22
28
  export declare function deviceAuthorize(): Promise<DeviceAuthorization>;
package/dist/auth.js CHANGED
@@ -26,8 +26,13 @@ export async function readCache(path = CACHE_PATH) {
26
26
  }
27
27
  }
28
28
  export async function writeCache(credentials, path = CACHE_PATH) {
29
+ // Retention minimization: persist only what inference needs. The OAuth
30
+ // access token has unknown broader scope and nothing reads it back, so it
31
+ // must never touch disk — sanitize at the sink, whatever callers pass in.
32
+ const { apiKey, accountId, email } = credentials;
33
+ const cached = { apiKey, accountId, ...(email ? { email } : {}) };
29
34
  await mkdir(dirname(path), { recursive: true });
30
- await writeFile(path, JSON.stringify(credentials, null, 2));
35
+ await writeFile(path, JSON.stringify(cached, null, 2));
31
36
  try {
32
37
  await chmod(path, 0o600);
33
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-muse-auth",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Muse Spark in opencode billed to the Muse Code monthly subscription (Meta device login, no API key)",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -34,6 +34,7 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "build": "tsc",
37
+ "pretest": "npm run build",
37
38
  "test": "node --test --test-concurrency=1 \"tests/*.test.ts\"",
38
39
  "prepublishOnly": "npm run build"
39
40
  },