@gjermundgaraba/clankerauth-dev 0.5.0 → 0.5.1
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 +14 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +20 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,6 +30,20 @@ await issuer.close();
|
|
|
30
30
|
|
|
31
31
|
Each call listens on a random loopback port, creates a fresh SQLite database and secret in a temporary directory, provisions the owner, the resources and the client in-process through the server's administration module, and returns. Only the returned issuer is reached over HTTP. The client is first party: once the owner is signed in, an authorization request redirects straight to the callback with a code and no consent step. `close()` drains in-flight requests, closes the database and deletes the directory. Nothing is shared between calls and nothing survives them.
|
|
32
32
|
|
|
33
|
+
To develop an app behind forward auth, pass a `cookieDomain`:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const issuer = await startDisposableIssuer({
|
|
37
|
+
resources: [{ identifier: "http://app.notes.localhost:8080/api", name: "Notes", scopes: [] }],
|
|
38
|
+
client: { name: "Notes console", redirect: "http://localhost:5173/callback", resources: [] },
|
|
39
|
+
cookieDomain: "notes.localhost",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
issuer.url; // http://auth.notes.localhost:<port>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The issuer then serves `/forward-auth?resource=<identifier>`, `/forward-auth/continue` and `/forward-auth/logout`, and shares its forward cookie with every host under the domain, so serve the app on one, such as `app.notes.localhost`. Browsers and Node resolve `.localhost` names to loopback without a hosts-file entry. A signed-in owner's check answers `204` with an `Authorization` header to copy upstream; without a session, a page navigation (`Sec-Fetch-Mode: navigate`) is redirected through sign-in and any other request is `401`. Node's `fetch` always sends `Sec-Fetch-Mode: cors`, so a proxy written in Node must make the check with `node:http` to relay the browser's header. Without `cookieDomain` the issuer is `http://127.0.0.1:<port>` and these routes are not served.
|
|
46
|
+
|
|
33
47
|
Two optional test hooks help exercise integrations:
|
|
34
48
|
|
|
35
49
|
- `cimdTransport(input, init)` replaces outbound Client ID Metadata Document retrieval and returns a `Response` or `Promise<Response>`. Its arguments match `fetch`. Use it to serve fixture metadata for HTTPS client IDs without an external server. When omitted, the issuer uses its secure metadata transport.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export interface DisposableIssuerOptions {
|
|
2
2
|
resources: Array<{ identifier: string; name: string; scopes: string[] }>;
|
|
3
3
|
client: { name: string; redirect: string; resources: string[] };
|
|
4
|
+
/**
|
|
5
|
+
* Serve forward auth for apps under this domain, such as `notes.localhost`. The issuer is
|
|
6
|
+
* then `http://auth.<cookieDomain>:<port>` on the same loopback listener, and the forward
|
|
7
|
+
* cookie is shared with every host under the domain. Without it, the issuer is
|
|
8
|
+
* `http://127.0.0.1:<port>` and the forward-auth routes are not served.
|
|
9
|
+
*/
|
|
10
|
+
cookieDomain?: string;
|
|
4
11
|
/** Test hook replacing outbound CIMD metadata retrieval. Defaults to the secure transport. */
|
|
5
12
|
cimdTransport?: (input: RequestInfo | URL, init?: RequestInit) => Response | Promise<Response>;
|
|
6
13
|
/** Test hook observing incoming HTTP requests, including provisioning. No headers or bodies. */
|