@chatroomcp/chatroom 0.1.5 → 0.1.6
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/dist/plugins/cloud/api-client.d.ts +0 -11
- package/dist/plugins/cloud/api-client.js +0 -21
- package/dist/plugins/cloud/controller.d.ts +0 -2
- package/dist/plugins/cloud/controller.js +0 -17
- package/dist/plugins/cloud/tunnel-client.js +12 -5
- package/dist/plugins/web/http/cloud-api-router.js +0 -13
- package/dist/web/assets/index-B7jL3mhD.css +1 -0
- package/dist/web/assets/index-L4-YdZVN.js +26 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-B4927Tpd.css +0 -1
- package/dist/web/assets/index-KAI80R3I.js +0 -26
|
@@ -3,10 +3,6 @@ import { type CloudEntitlement, type CloudLeaseState, type CloudServiceId } from
|
|
|
3
3
|
declare const recoveryCredentialSchema: z.ZodObject<{
|
|
4
4
|
recoveryKey: z.ZodString;
|
|
5
5
|
}, z.core.$strict>;
|
|
6
|
-
declare const registrationSchema: z.ZodObject<{
|
|
7
|
-
installationId: z.ZodString;
|
|
8
|
-
registered: z.ZodLiteral<true>;
|
|
9
|
-
}, z.core.$strict>;
|
|
10
6
|
declare const sessionSchema: z.ZodObject<{
|
|
11
7
|
purchaseToken: z.ZodString;
|
|
12
8
|
managementUrl: z.ZodString;
|
|
@@ -29,15 +25,9 @@ declare const restoreSchema: z.ZodObject<{
|
|
|
29
25
|
publicPrefix: z.ZodNullable<z.ZodString>;
|
|
30
26
|
recoveryKey: z.ZodString;
|
|
31
27
|
}, z.core.$strict>;
|
|
32
|
-
declare const prefixSchema: z.ZodObject<{
|
|
33
|
-
publicPrefix: z.ZodString;
|
|
34
|
-
mcpUrl: z.ZodString;
|
|
35
|
-
webUrl: z.ZodString;
|
|
36
|
-
}, z.core.$strict>;
|
|
37
28
|
export declare class CloudApiClient {
|
|
38
29
|
private readonly baseUrl;
|
|
39
30
|
constructor(baseUrl: string);
|
|
40
|
-
registerDevice(identity: DeviceIdentity): Promise<z.infer<typeof registrationSchema>>;
|
|
41
31
|
createManagementSession(identity: DeviceIdentity): Promise<z.infer<typeof sessionSchema>>;
|
|
42
32
|
status(identity: DeviceIdentity, purchaseToken: string | null): Promise<{
|
|
43
33
|
managementSessionActive: boolean;
|
|
@@ -49,7 +39,6 @@ export declare class CloudApiClient {
|
|
|
49
39
|
}>;
|
|
50
40
|
restore(identity: DeviceIdentity, recoveryKey: string): Promise<z.infer<typeof restoreSchema>>;
|
|
51
41
|
replaceRecoveryKey(identity: DeviceIdentity): Promise<z.infer<typeof recoveryCredentialSchema>>;
|
|
52
|
-
setPrefix(identity: DeviceIdentity, prefix: string): Promise<z.infer<typeof prefixSchema>>;
|
|
53
42
|
lease(identity: DeviceIdentity, requestedServices: CloudServiceId[]): Promise<CloudLeaseState>;
|
|
54
43
|
private devicePost;
|
|
55
44
|
}
|
|
@@ -7,12 +7,6 @@ const recoveryCredentialSchema = z
|
|
|
7
7
|
recoveryKey: z.string().regex(/^crr\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
|
|
8
8
|
})
|
|
9
9
|
.strict();
|
|
10
|
-
const registrationSchema = z
|
|
11
|
-
.object({
|
|
12
|
-
installationId: z.string().uuid(),
|
|
13
|
-
registered: z.literal(true),
|
|
14
|
-
})
|
|
15
|
-
.strict();
|
|
16
10
|
const sessionSchema = z
|
|
17
11
|
.object({
|
|
18
12
|
purchaseToken: z.string().min(24),
|
|
@@ -36,22 +30,11 @@ const restoreSchema = z
|
|
|
36
30
|
recoveryKey: z.string().regex(/^crr\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
|
|
37
31
|
})
|
|
38
32
|
.strict();
|
|
39
|
-
const prefixSchema = z
|
|
40
|
-
.object({
|
|
41
|
-
publicPrefix: z.string().min(1),
|
|
42
|
-
mcpUrl: z.string().url(),
|
|
43
|
-
webUrl: z.string().url(),
|
|
44
|
-
})
|
|
45
|
-
.strict();
|
|
46
33
|
export class CloudApiClient {
|
|
47
34
|
baseUrl;
|
|
48
35
|
constructor(baseUrl) {
|
|
49
36
|
this.baseUrl = baseUrl;
|
|
50
37
|
}
|
|
51
|
-
async registerDevice(identity) {
|
|
52
|
-
const payload = { devicePublicKey: identity.devicePublicKey };
|
|
53
|
-
return registrationSchema.parse(await this.devicePost("/v1/device/register", "register", identity, payload));
|
|
54
|
-
}
|
|
55
38
|
async createManagementSession(identity) {
|
|
56
39
|
const payload = { devicePublicKey: identity.devicePublicKey };
|
|
57
40
|
return sessionSchema.parse(await this.devicePost("/v1/device/session", "session", identity, payload));
|
|
@@ -71,10 +54,6 @@ export class CloudApiClient {
|
|
|
71
54
|
const payload = { devicePublicKey: identity.devicePublicKey };
|
|
72
55
|
return recoveryCredentialSchema.parse(await this.devicePost("/v1/device/recovery-key", "recovery-key", identity, payload));
|
|
73
56
|
}
|
|
74
|
-
async setPrefix(identity, prefix) {
|
|
75
|
-
const payload = { devicePublicKey: identity.devicePublicKey, prefix };
|
|
76
|
-
return prefixSchema.parse(await this.devicePost("/v1/device/prefix", "prefix", identity, payload));
|
|
77
|
-
}
|
|
78
57
|
async lease(identity, requestedServices) {
|
|
79
58
|
const payload = {
|
|
80
59
|
devicePublicKey: identity.devicePublicKey,
|
|
@@ -24,7 +24,6 @@ export declare class CloudController {
|
|
|
24
24
|
status(): CloudStatus;
|
|
25
25
|
start(): Promise<void>;
|
|
26
26
|
stop(): Promise<void>;
|
|
27
|
-
registerDevice(): Promise<CloudStatus>;
|
|
28
27
|
managementUrl(): Promise<{
|
|
29
28
|
url: string;
|
|
30
29
|
expiresAt: string;
|
|
@@ -35,7 +34,6 @@ export declare class CloudController {
|
|
|
35
34
|
recoveryKey: string;
|
|
36
35
|
}>;
|
|
37
36
|
replaceRecoveryKey(): Promise<string>;
|
|
38
|
-
setPrefix(prefix: string): Promise<CloudStatus>;
|
|
39
37
|
setService(service: CloudServiceId, enabled: boolean): Promise<CloudStatus>;
|
|
40
38
|
private refreshLeaseIfNeeded;
|
|
41
39
|
private connectTunnel;
|
|
@@ -65,11 +65,6 @@ export class CloudController {
|
|
|
65
65
|
if (this.state.lease)
|
|
66
66
|
this.connection = "disconnected";
|
|
67
67
|
}
|
|
68
|
-
async registerDevice() {
|
|
69
|
-
await this.api.registerDevice(this.identity());
|
|
70
|
-
this.lastError = null;
|
|
71
|
-
return this.status();
|
|
72
|
-
}
|
|
73
68
|
async managementUrl() {
|
|
74
69
|
const current = this.state.managementSession;
|
|
75
70
|
if (current && Date.parse(current.expiresAt) > Date.now()) {
|
|
@@ -139,18 +134,6 @@ export class CloudController {
|
|
|
139
134
|
const result = await this.api.replaceRecoveryKey(this.identity());
|
|
140
135
|
return result.recoveryKey;
|
|
141
136
|
}
|
|
142
|
-
async setPrefix(prefix) {
|
|
143
|
-
const result = await this.api.setPrefix(this.identity(), prefix);
|
|
144
|
-
this.state = { ...this.state, publicPrefix: result.publicPrefix };
|
|
145
|
-
await this.store.save(this.state);
|
|
146
|
-
if (!this.stopped && this.state.entitlements.length > 0) {
|
|
147
|
-
await this.refreshLeaseIfNeeded(true);
|
|
148
|
-
this.connectTunnel();
|
|
149
|
-
this.scheduleRenewal();
|
|
150
|
-
}
|
|
151
|
-
this.lastError = null;
|
|
152
|
-
return this.status();
|
|
153
|
-
}
|
|
154
137
|
async setService(service, enabled) {
|
|
155
138
|
if (!CLOUD_SERVICES.includes(service))
|
|
156
139
|
throw new Error(`Unknown Cloud service: ${service}`);
|
|
@@ -59,14 +59,21 @@ export class CloudTunnelClient {
|
|
|
59
59
|
this.closeWhenIdle = "stop";
|
|
60
60
|
}
|
|
61
61
|
updateLease(lease) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
lease.tunnelUrl !== this.lease.tunnelUrl;
|
|
65
|
-
const removesService = previousServices.some((service) => !lease.services.includes(service));
|
|
62
|
+
const tunnelChanged = lease.tunnelUrl !== this.lease.tunnelUrl;
|
|
63
|
+
const removesService = this.lease.services.some((service) => !lease.services.includes(service));
|
|
66
64
|
this.lease = lease;
|
|
67
65
|
this.acceptingServices = new Set(lease.services);
|
|
68
|
-
if (
|
|
66
|
+
if (this.stopped)
|
|
69
67
|
return;
|
|
68
|
+
// A new signed lease on the same tunnel is applied in-band. This keeps the
|
|
69
|
+
// current WebUI/API request alive while service permissions change.
|
|
70
|
+
if (!tunnelChanged) {
|
|
71
|
+
if (this.socket?.readyState === WebSocket.OPEN)
|
|
72
|
+
this.send({ type: "update-lease", lease: lease.token });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Changing the tunnel endpoint still requires a reconnect. If a service is
|
|
76
|
+
// being removed, let current streams finish before moving the connection.
|
|
70
77
|
if (!removesService || this.streams.size === 0) {
|
|
71
78
|
this.socket?.close();
|
|
72
79
|
return;
|
|
@@ -5,7 +5,6 @@ import { asyncRoute } from "../../../presentation/http/http-utils.js";
|
|
|
5
5
|
export function createCloudApiRouter(controller, operations) {
|
|
6
6
|
const router = Router();
|
|
7
7
|
router.get("/cloud/status", (_req, res) => res.json(controller.status()));
|
|
8
|
-
router.post("/cloud/register", asyncRoute(async (_req, res) => res.json(await operations.run({ pluginId: "cloud", source: "gui", action: "register" }, () => controller.registerDevice()))));
|
|
9
8
|
router.post("/cloud/sync", asyncRoute(async (_req, res) => res.json(await operations.run({ pluginId: "cloud", source: "gui", action: "sync" }, () => controller.syncStatus()))));
|
|
10
9
|
router.post("/cloud/management", asyncRoute(async (_req, res) => res.json(await operations.run({ pluginId: "cloud", source: "gui", action: "management" }, () => controller.managementUrl()))));
|
|
11
10
|
router.post("/cloud/restore", asyncRoute(async (req, res) => {
|
|
@@ -16,18 +15,6 @@ export function createCloudApiRouter(controller, operations) {
|
|
|
16
15
|
res.json(await operations.run({ pluginId: "cloud", source: "gui", action: "restore", input: body }, () => controller.restore(body.recoveryKey)));
|
|
17
16
|
}));
|
|
18
17
|
router.post("/cloud/recovery-key", asyncRoute(async (_req, res) => res.json(await operations.run({ pluginId: "cloud", source: "gui", action: "recovery-key.replace" }, async () => ({ recoveryKey: await controller.replaceRecoveryKey() })))));
|
|
19
|
-
router.post("/cloud/prefix", asyncRoute(async (req, res) => {
|
|
20
|
-
const body = z
|
|
21
|
-
.object({ prefix: z.string().min(1).max(64) })
|
|
22
|
-
.strict()
|
|
23
|
-
.parse(req.body);
|
|
24
|
-
res.json(await operations.run({
|
|
25
|
-
pluginId: "cloud",
|
|
26
|
-
source: "gui",
|
|
27
|
-
action: "prefix.set",
|
|
28
|
-
input: body,
|
|
29
|
-
}, () => controller.setPrefix(body.prefix)));
|
|
30
|
-
}));
|
|
31
18
|
router.post("/cloud/services/:service", asyncRoute(async (req, res) => {
|
|
32
19
|
const service = CLOUD_SERVICE_SCHEMA.parse(req.params.service);
|
|
33
20
|
const body = z.object({ enabled: z.boolean() }).strict().parse(req.body);
|