@ccmsg/cli 0.2.0 → 0.2.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/package.json +1 -1
- package/src/auth/auth.ts +11 -5
- package/src/transport/ws.ts +7 -1
package/package.json
CHANGED
package/src/auth/auth.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
WebAuthnError,
|
|
36
36
|
} from "./webauthn.ts";
|
|
37
37
|
import { CborError } from "./cbor.ts";
|
|
38
|
+
import { ENTRY_PATH } from "../transport/index.ts";
|
|
38
39
|
|
|
39
40
|
/** How long an access token is accepted, and how long a refresh token is.
|
|
40
41
|
*
|
|
@@ -963,15 +964,20 @@ export function hostOf(endpoint: Endpoint): string {
|
|
|
963
964
|
return new URL(endpoint).hostname;
|
|
964
965
|
}
|
|
965
966
|
|
|
966
|
-
/** Where the page that runs the registration is served from
|
|
967
|
-
*
|
|
968
|
-
*
|
|
967
|
+
/** Where the page that runs the registration is served from.
|
|
968
|
+
*
|
|
969
|
+
* The endpoint over HTTP, with the WebSocket's own path segment taken off: an
|
|
970
|
+
* endpoint is the address of a door (`wss://h/personal/ws`), and the web UI is
|
|
971
|
+
* what is served where that door is (`https://h/personal/`). Leaving the
|
|
972
|
+
* segment on would send the person to the WebSocket rather than to the page
|
|
973
|
+
* (DR-0001 §2.2). An endpoint that names no path is an instance whose UI is at
|
|
974
|
+
* the root. */
|
|
969
975
|
export function webOrigin(endpoint: Endpoint): string {
|
|
970
976
|
const url = new URL(endpoint);
|
|
971
977
|
url.protocol = url.protocol === "wss:" ? "https:" : "http:";
|
|
972
|
-
const origin = url.origin;
|
|
973
978
|
const path = url.pathname.replace(/\/$/, "");
|
|
974
|
-
|
|
979
|
+
const prefix = path.endsWith(ENTRY_PATH) ? path.slice(0, -ENTRY_PATH.length) : path;
|
|
980
|
+
return `${url.origin}${prefix}`;
|
|
975
981
|
}
|
|
976
982
|
|
|
977
983
|
/** Whether a relying party id is the host or a domain the host sits under.
|
package/src/transport/ws.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface WsOptions {
|
|
|
51
51
|
* is either buffered whole by Bun or dropped whole — and the queue absorbs
|
|
52
52
|
* that difference here (§3.1). */
|
|
53
53
|
export function serveWs(options: WsOptions): Listener {
|
|
54
|
-
const path = options.path ??
|
|
54
|
+
const path = options.path ?? ENTRY_PATH;
|
|
55
55
|
const entry = options.entry ?? OPEN;
|
|
56
56
|
// The per-connection state is made in `open`, where the socket to write to
|
|
57
57
|
// exists, so the upgrade carries nothing and the socket keeps no data of its
|
|
@@ -158,6 +158,12 @@ export function serveWs(options: WsOptions): Listener {
|
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/** Where a person's WebSocket is answered, on whatever prefix a proxy puts the
|
|
162
|
+
* instance under. Named here because it is one door, and more than one place
|
|
163
|
+
* has to know what it is called: the entry match below, and the registration
|
|
164
|
+
* URL, which is the same address without it (DR-0001 §2.2). */
|
|
165
|
+
export const ENTRY_PATH = "/ws";
|
|
166
|
+
|
|
161
167
|
/** Whether a request's path is this listener's entry.
|
|
162
168
|
*
|
|
163
169
|
* Matched at the end rather than whole, so a proxy that puts the instance under
|