@godspeedai/cognate-provider-auth 0.8.0 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/EGM.md +33 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@godspeedai/cognate-provider-auth",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Ephemeral credential-source and usage authorization boundary for model providers.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/EGM.md ADDED
@@ -0,0 +1,33 @@
1
+ # provider-auth / src — credential leases and the subscription gate
2
+
3
+ ## Overview
4
+
5
+ The single module `src/index.ts` defines the credential boundary every provider adapter leases from: a `CredentialSource` that yields a short-lived `CredentialLease` of HTTP headers, two factories that build sources from secret accessors, a helper that resolves a source into plain headers, and a local policy gate for plan-backed subscription use. Nothing in the module performs I/O; every effect is either the caller's accessor function or the caller's own HTTP client.
6
+
7
+ ## Interface
8
+
9
+ - `CredentialLease` — read-only `headers` plus optional `expiresAt`, `identityRef`, `grantedScopes` `[packages/provider-auth/src/index.ts:CredentialLease]`
10
+ - `CredentialSource` — `acquire(signal?: AbortSignal): Promise<CredentialLease>` `[packages/provider-auth/src/index.ts:CredentialSource]`
11
+ - `UsageMode` — the union `"interactive" | "authorized_automation"` `[packages/provider-auth/src/index.ts:UsageMode]`
12
+ - `SubscriptionGrant` — `identityRef`, `scopes`, and host-recorded `automationApproved` `[packages/provider-auth/src/index.ts:SubscriptionGrant]`
13
+ - `assertSubscriptionUse(grant, mode)` — throws unless the grant carries the scope `chatgpt.tokens.use.direct`, and throws for `authorized_automation` without approval `[packages/provider-auth/src/index.ts:assertSubscriptionUse]`
14
+ - `apiKeySource(apiKey, header?)` — source whose `acquire` awaits the accessor; `header` defaults to `"authorization"` `[packages/provider-auth/src/index.ts:apiKeySource]`
15
+ - `bearerSource(accessToken)` — `apiKeySource` with the default authorization header `[packages/provider-auth/src/index.ts:bearerSource]`
16
+ - `credentialHeaders(source?, signal?)` — resolves a source into a copy of its headers, or `{}` when no source is given `[packages/provider-auth/src/index.ts:credentialHeaders]`
17
+
18
+ ## Invariants
19
+
20
+ - The `authorization` header value is prefixed `Bearer `; any other header name carries the secret verbatim `[packages/provider-auth/src/index.ts:apiKeySource]`
21
+ - An empty secret fails closed with `Error("Credential unavailable")` instead of sending a blank header `[packages/provider-auth/src/index.ts:apiKeySource]`
22
+ - `automationApproved` is consent recorded by the host, never derived from token presence `[packages/provider-auth/src/index.ts:SubscriptionGrant]`
23
+ - The scope check runs before the automation check, so a missing scope is reported as unauthorized plan use `[packages/provider-auth/src/index.ts:assertSubscriptionUse]`
24
+ - `credentialHeaders` spreads the lease headers into a new object, so callers cannot mutate the lease `[packages/provider-auth/src/index.ts:credentialHeaders]`
25
+
26
+ ## Side Effects
27
+
28
+ - Awaits the caller-supplied accessor on every `acquire()`; no token cache or refresh scheduling exists here `[packages/provider-auth/src/index.ts:apiKeySource]`
29
+ - Forwards the supplied `AbortSignal` into `CredentialSource.acquire` but implements no cancellation of its own `[packages/provider-auth/src/index.ts:credentialHeaders]`
30
+
31
+ ## Verification
32
+
33
+ - Run: `cd packages/provider-auth && bun test`