@kanonak-protocol/cli 5.5.0 → 5.7.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.
@@ -18,8 +18,9 @@ import type { FetchLike } from './IssuanceClient.js';
18
18
  /** The discovery capability the flow needs (satisfied by {@link OAuthDiscovery}). */
19
19
  export interface EnrollmentMetadataSource {
20
20
  discover(host: string): Promise<OAuthServerMetadata | null>;
21
- /** Resolve a Kanonak publisher to its authority issuer URL(s) via kanonak.json. */
22
- discoverKanonakAuthorities(host: string): Promise<string[] | null>;
21
+ /** Resolve a publisher to its authority issuer URL(s) via the always-public
22
+ * RFC 9728 `oauth-protected-resource` document. */
23
+ discoverProtectedResource(host: string): Promise<string[] | null>;
23
24
  }
24
25
  /** Just enough of {@link CredentialStore} to reuse a stored OAuth client_id. */
25
26
  export interface CredentialLookup {
@@ -0,0 +1,21 @@
1
+ import { CredentialResolver } from '@kanonak-protocol/sdk';
2
+ import type { AuthenticatedFetchFn } from '@kanonak-protocol/sdk';
3
+ /**
4
+ * A fetch transport that authenticates GATED reads with the device session.
5
+ *
6
+ * Per host, it resolves the publisher → authority → device session
7
+ * (CredentialResolver) and presents the session token as `Authorization: Bearer`.
8
+ * A public publisher resolves to no credential and the request goes out
9
+ * anonymously. This is what makes `install` / `connect` read a gated publisher's
10
+ * `kanonak.json` / `kanonak.lock` / package sources — without it, those requests
11
+ * hit the gate unauthenticated.
12
+ *
13
+ * Crucially it uses `redirect: 'manual'`: a gated endpoint 302-redirects an
14
+ * unauthenticated request (e.g. to a login), and Node's default auto-following
15
+ * turns that into a redirect LOOP. Not following means a gated 302 surfaces as a
16
+ * clean non-OK response the caller reports, instead of spinning.
17
+ *
18
+ * The resolved credential is cached per host so one `connect`/`install` doesn't
19
+ * re-mint a session for every package in the closure.
20
+ */
21
+ export declare function createSessionFetch(resolver?: CredentialResolver): AuthenticatedFetchFn;
@@ -14,8 +14,9 @@ export interface ConnectResult {
14
14
  */
15
15
  export interface ConnectDeps {
16
16
  fetchFn?: AuthenticatedFetchFn;
17
+ /** Resolve a publisher to its authority via RFC 9728 oauth-protected-resource. */
17
18
  discovery?: {
18
- discoverKanonakAuthorities(host: string): Promise<string[] | null>;
19
+ discoverProtectedResource(host: string): Promise<string[] | null>;
19
20
  };
20
21
  configResolver?: {
21
22
  getConfig(host: string): Promise<PublisherConfig>;
@@ -42,13 +43,17 @@ export interface ConnectDeps {
42
43
  log?: (message: string) => void;
43
44
  }
44
45
  /**
45
- * The `connect` orchestrator core (issue #9): given a publisher domain, discover
46
- * it (kanonak.json authorization_servers + featured_packages), enroll this
47
- * device if the publisher is gated and not already enrolled with its authority,
48
- * then install the featured packages and their pinned closures from the served
49
- * kanonak.lock. Pure of process/stdout concerns returns a {@link ConnectResult}
50
- * and reports progress through `deps.log` — so the CLI and VS Code wrap it the
51
- * same way. A public publisher (no authorization_servers) never enrolls.
46
+ * The `connect` orchestrator core (issue #9): given a publisher domain, learn
47
+ * whether it is gated from the always-public RFC 9728 `oauth-protected-resource`
48
+ * document, enroll this device if it is gated and not already enrolled, then
49
+ * read the publisher's `kanonak.json` (its `featured_packages`) and install them
50
+ * and their pinned closures from the served `kanonak.lock`.
51
+ *
52
+ * For a gated publisher the `kanonak.json`/`kanonak.lock` are themselves behind
53
+ * auth, so those reads go through the device session minted from the enrolled
54
+ * cert. A public publisher (no `oauth-protected-resource`) never enrolls and
55
+ * reads everything anonymously. Pure of process/stdout concerns — returns a
56
+ * {@link ConnectResult} and reports via `deps.log`.
52
57
  */
53
58
  export declare function connect(publisher: string, options: {
54
59
  install?: boolean;