@opencode/server 0.0.0-dev-20113 → 0.0.0-dev-20115
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/api.js +5 -5
- package/dist/auth.d.ts +4 -0
- package/dist/auth.js +10 -2
- package/dist/chunks/{options-5bwq5cz2.js → fetch-1g0h49bb.js} +2 -2
- package/dist/chunks/{options-xewf68xm.js → fetch-1y0kev0a.js} +19 -15
- package/dist/chunks/{options-5rwqcaw2.js → fetch-27edjygf.js} +1 -1
- package/dist/chunks/{options-wz0qz28j.js → fetch-2nqgjchx.js} +2 -2
- package/dist/chunks/{options-18k6g42r.js → fetch-3jweah5a.js} +7 -7
- package/dist/chunks/{options-b1rdg9nf.js → fetch-42hredtt.js} +2 -2
- package/dist/chunks/{options-6qwktr1g.js → fetch-436zj0s2.js} +1 -1
- package/dist/chunks/{options-hp5sxeae.js → fetch-4zhj4tp6.js} +2 -2
- package/dist/chunks/{options-5jh9m3wx.js → fetch-5xpvxbxg.js} +5 -5
- package/dist/chunks/{options-g1cbdcxy.js → fetch-70rdrjmf.js} +4 -4
- package/dist/chunks/{options-v1emgcvb.js → fetch-77mkgw7d.js} +2 -2
- package/dist/chunks/{options-x5ncpjy3.js → fetch-830yc5sa.js} +1 -1
- package/dist/chunks/{options-6gkz39ey.js → fetch-8j6eh3dh.js} +3 -3
- package/dist/chunks/{options-haswyr8z.js → fetch-8tzsm9rr.js} +2 -2
- package/dist/chunks/{options-tjpn0s1b.js → fetch-99sfd1j8.js} +10 -10
- package/dist/chunks/{options-qj9kjxn3.js → fetch-9gjx5y7a.js} +1 -1
- package/dist/chunks/{options-s0padj6k.js → fetch-9qna85w8.js} +3 -3
- package/dist/chunks/fetch-anm12x33.js +66 -0
- package/dist/chunks/{options-v573ws0d.js → fetch-cb0457h1.js} +3 -3
- package/dist/chunks/{options-hr75rahr.js → fetch-fbrf1xh2.js} +2 -2
- package/dist/chunks/{options-m6wvgbfq.js → fetch-gtkdacvk.js} +28 -7
- package/dist/chunks/{options-ees77nh9.js → fetch-h7dczx71.js} +2 -2
- package/dist/chunks/{options-3kzx88w9.js → fetch-kb9735wh.js} +1 -1
- package/dist/chunks/{options-44xy5pnk.js → fetch-kbnh7vq7.js} +1 -1
- package/dist/chunks/{options-zpz5afwq.js → fetch-kpeb8xpg.js} +2 -2
- package/dist/chunks/{options-f1xg0r1h.js → fetch-kwec6m6e.js} +33 -33
- package/dist/chunks/{options-bt9tc5rb.js → fetch-m7cvtaax.js} +1 -1
- package/dist/chunks/{options-96s6m0w3.js → fetch-nq5wb210.js} +2 -2
- package/dist/chunks/{options-7eckj7zq.js → fetch-nq63h5nv.js} +2 -2
- package/dist/chunks/{options-rjqbhscq.js → fetch-qvxvnv5e.js} +1 -1
- package/dist/chunks/{options-pme11y2y.js → fetch-rnws4wbc.js} +2 -2
- package/dist/chunks/{options-t88f2hhf.js → fetch-rre9g8c5.js} +3 -3
- package/dist/chunks/fetch-sstsrjtg.js +35 -0
- package/dist/chunks/fetch-sxpmt7wt.js +53 -0
- package/dist/chunks/{options-bkk2wfbz.js → fetch-t7k3q1ah.js} +5 -5
- package/dist/chunks/{options-140y8w7p.js → fetch-tj793hqk.js} +2 -2
- package/dist/chunks/{options-f8rap8f6.js → fetch-vgwss5ek.js} +1 -1
- package/dist/chunks/{options-aa9bsk9n.js → fetch-vmxdyx1n.js} +6 -6
- package/dist/chunks/{options-ctscy0f5.js → fetch-x34qkqqy.js} +2 -2
- package/dist/chunks/{options-vpz7f20y.js → fetch-xsrtpxyd.js} +4 -4
- package/dist/chunks/{options-bmqkn4ah.js → fetch-y7jha6td.js} +1 -1
- package/dist/chunks/{options-np19kmxx.js → fetch-ybejac25.js} +2 -2
- package/dist/chunks/{options-26ta7ngt.js → fetch-ywj7qjmv.js} +2 -2
- package/dist/chunks/{options-367ngss7.js → fetch-yybhtx8s.js} +2 -2
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +7 -7
- package/dist/fetch.js +49 -48
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +6 -6
- package/dist/handlers/debug.js +6 -6
- package/dist/handlers/event.js +7 -7
- package/dist/handlers/form.js +6 -6
- package/dist/handlers/fs.js +6 -6
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/location.js +6 -6
- package/dist/handlers/mcp.js +6 -6
- package/dist/handlers/message.js +6 -6
- package/dist/handlers/migration.js +6 -6
- package/dist/handlers/model.js +6 -6
- package/dist/handlers/permission.js +6 -6
- package/dist/handlers/persistent-pty.js +8 -8
- package/dist/handlers/plugin.js +6 -6
- package/dist/handlers/project.js +6 -6
- package/dist/handlers/provider.js +6 -6
- package/dist/handlers/pty-socket.js +1 -1
- package/dist/handlers/pty.js +9 -9
- package/dist/handlers/reference.js +6 -6
- package/dist/handlers/rpc.js +6 -6
- package/dist/handlers/server.d.ts +3 -1
- package/dist/handlers/server.js +9 -7
- package/dist/handlers/session-error.js +1 -1
- package/dist/handlers/session.js +6 -6
- package/dist/handlers/shell.js +6 -6
- package/dist/handlers/skill.js +6 -6
- package/dist/handlers/vcs.js +6 -6
- package/dist/handlers/websearch.js +6 -6
- package/dist/handlers/worktree.js +6 -6
- package/dist/handlers.d.ts +1 -1
- package/dist/handlers.js +43 -41
- package/dist/location.js +4 -4
- package/dist/middleware/authorization.d.ts +2 -1
- package/dist/middleware/authorization.js +5 -3
- package/dist/middleware/form-location.js +3 -3
- package/dist/middleware/schema-error.js +1 -1
- package/dist/middleware/session-location.js +3 -3
- package/dist/pairing.d.ts +13 -0
- package/dist/pairing.js +10 -0
- package/dist/process.js +56 -59
- package/dist/pty-environment.js +3 -3
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +3 -2
- package/dist/routes.js +46 -45
- package/dist/server-info.js +5 -5
- package/dist/service-status.js +3 -3
- package/dist/workerd.js +50 -49
- package/package.json +8 -8
- package/dist/chunks/options-veszktdp.js +0 -21
- package/dist/chunks/options-zyv89x5n.js +0 -30
- /package/dist/chunks/{options-9rqn6x4v.js → fetch-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{options-hezj1jdf.js → fetch-hezj1jdf.js} +0 -0
- /package/dist/chunks/{options-q4bn6dy8.js → fetch-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{options-smaf4a18.js → fetch-smaf4a18.js} +0 -0
- /package/dist/chunks/{options-t8yzmczr.js → fetch-t8yzmczr.js} +0 -0
- /package/dist/chunks/{options-yc7nft6q.js → fetch-yc7nft6q.js} +0 -0
package/dist/api.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import"./chunks/
|
|
5
|
-
import"./chunks/
|
|
6
|
-
import"./chunks/
|
|
7
|
-
import"./chunks/
|
|
3
|
+
} from "./chunks/fetch-cb0457h1.js";
|
|
4
|
+
import"./chunks/fetch-27edjygf.js";
|
|
5
|
+
import"./chunks/fetch-kb9735wh.js";
|
|
6
|
+
import"./chunks/fetch-8j6eh3dh.js";
|
|
7
|
+
import"./chunks/fetch-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
10
10
|
};
|
package/dist/auth.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type Info = {
|
|
|
8
8
|
readonly password: Option.Option<string>;
|
|
9
9
|
readonly username: string;
|
|
10
10
|
};
|
|
11
|
+
export declare const SESSION_TTL_SECONDS: number;
|
|
11
12
|
declare const Config_base: Context.ServiceClass<Config, "@opencode/ServerAuthConfig", Info>;
|
|
12
13
|
export declare class Config extends Config_base {
|
|
13
14
|
static configLayer(input: Pick<Info, "password">): Layer.Layer<Config, never, never>;
|
|
@@ -15,3 +16,6 @@ export declare class Config extends Config_base {
|
|
|
15
16
|
}
|
|
16
17
|
export declare function required(config: Info): boolean;
|
|
17
18
|
export declare function authorized(credentials: DecodedCredentials, config: Info): boolean;
|
|
19
|
+
export declare function issueSession(config: Info, now?: number): string | undefined;
|
|
20
|
+
export declare function verifySession(token: string, config: Info, now?: number): boolean;
|
|
21
|
+
export declare function sessionCookieName(host: string | undefined): string;
|
package/dist/auth.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SESSION_TTL_SECONDS2,
|
|
2
3
|
Config2,
|
|
3
4
|
required2,
|
|
4
5
|
authorized2,
|
|
6
|
+
issueSession2,
|
|
7
|
+
verifySession2,
|
|
8
|
+
sessionCookieName2,
|
|
5
9
|
exports_auth
|
|
6
|
-
} from "./chunks/
|
|
10
|
+
} from "./chunks/fetch-anm12x33.js";
|
|
7
11
|
export {
|
|
8
12
|
Config2 as Config,
|
|
13
|
+
SESSION_TTL_SECONDS2 as SESSION_TTL_SECONDS,
|
|
9
14
|
exports_auth as ServerAuth,
|
|
10
15
|
authorized2 as authorized,
|
|
11
|
-
|
|
16
|
+
issueSession2 as issueSession,
|
|
17
|
+
required2 as required,
|
|
18
|
+
sessionCookieName2 as sessionCookieName,
|
|
19
|
+
verifySession2 as verifySession
|
|
12
20
|
};
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./
|
|
2
|
+
layer2
|
|
3
|
+
} from "./fetch-8j6eh3dh.js";
|
|
4
4
|
import {
|
|
5
5
|
formLocationLayer2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-27edjygf.js";
|
|
7
7
|
import {
|
|
8
8
|
sessionLocationLayer2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-kb9735wh.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./fetch-cb0457h1.js";
|
|
13
13
|
import {
|
|
14
14
|
Config2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./fetch-anm12x33.js";
|
|
16
16
|
import {
|
|
17
17
|
CorsConfig2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./fetch-q4bn6dy8.js";
|
|
19
|
+
import {
|
|
20
|
+
layer4
|
|
21
|
+
} from "./fetch-3jweah5a.js";
|
|
19
22
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./
|
|
23
|
+
node3
|
|
24
|
+
} from "./fetch-sstsrjtg.js";
|
|
22
25
|
import {
|
|
23
26
|
node2
|
|
24
|
-
} from "./
|
|
27
|
+
} from "./fetch-t7k3q1ah.js";
|
|
25
28
|
import {
|
|
26
29
|
handlers2
|
|
27
|
-
} from "./
|
|
30
|
+
} from "./fetch-kwec6m6e.js";
|
|
28
31
|
import {
|
|
29
32
|
authorizationLayer2
|
|
30
|
-
} from "./
|
|
33
|
+
} from "./fetch-gtkdacvk.js";
|
|
31
34
|
import {
|
|
32
35
|
schemaErrorLayer2
|
|
33
|
-
} from "./
|
|
36
|
+
} from "./fetch-t8yzmczr.js";
|
|
34
37
|
|
|
35
38
|
// src/routes.ts
|
|
36
39
|
import { Database } from "@opencode/core/database/database";
|
|
@@ -89,6 +92,7 @@ var applicationServiceNodes = [
|
|
|
89
92
|
Credential.node,
|
|
90
93
|
WellKnown.node,
|
|
91
94
|
node2,
|
|
95
|
+
node3,
|
|
92
96
|
LocationServiceMap.node,
|
|
93
97
|
LocationActivity.node,
|
|
94
98
|
SessionRestart.node,
|
|
@@ -140,8 +144,8 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
140
144
|
})) : build(overrides);
|
|
141
145
|
return serviceLayer.pipe(Layer.flatMap((context) => {
|
|
142
146
|
const services = Layer.succeedContext(context);
|
|
143
|
-
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)),
|
|
144
|
-
const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(
|
|
147
|
+
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer4(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
|
|
148
|
+
const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer2), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
|
|
145
149
|
return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
|
|
146
150
|
}));
|
|
147
151
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/server-info.ts
|
|
6
6
|
var exports_server_info = {};
|
|
7
7
|
__export(exports_server_info, {
|
|
8
8
|
ServerInfo: () => exports_server_info,
|
|
9
|
-
Service: () =>
|
|
9
|
+
Service: () => Service3,
|
|
10
10
|
connectionURLs: () => connectionURLs2,
|
|
11
|
-
layer: () =>
|
|
11
|
+
layer: () => layer4
|
|
12
12
|
});
|
|
13
13
|
import { Context, Layer } from "effect";
|
|
14
14
|
import { networkInterfaces } from "node:os";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class Service3 extends Context.Service()("@opencode/server/ServerInfo") {
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return Layer.succeed(
|
|
18
|
+
function layer4(urls, tmp, app = {}) {
|
|
19
|
+
return Layer.succeed(Service3, Service3.of({ urls, app, paths: { tmp } }));
|
|
20
20
|
}
|
|
21
21
|
function connectionURLs2(value, requestedHostname) {
|
|
22
22
|
const url = new URL(value);
|
|
@@ -33,4 +33,4 @@ function connectionURLs2(value, requestedHostname) {
|
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export {
|
|
36
|
+
export { Service3, layer4, connectionURLs2, exports_server_info };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-8j6eh3dh.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-cb0457h1.js";
|
|
7
7
|
import {
|
|
8
8
|
CorsConfig2,
|
|
9
9
|
isAllowedRequestOrigin2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./fetch-q4bn6dy8.js";
|
|
11
11
|
import {
|
|
12
12
|
Service2
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./fetch-t7k3q1ah.js";
|
|
14
14
|
import {
|
|
15
15
|
runPtySocket2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./fetch-hezj1jdf.js";
|
|
17
17
|
|
|
18
18
|
// src/handlers/pty.ts
|
|
19
19
|
import { Pty } from "@opencode/core/pty";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-cb0457h1.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
Service4,
|
|
6
6
|
frame2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./fetch-99sfd1j8.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/event.ts
|
|
10
10
|
import { Event } from "@opencode/schema/event";
|
|
@@ -12,7 +12,7 @@ import { Effect, Stream } from "effect";
|
|
|
12
12
|
import { HttpServerResponse } from "effect/unstable/http";
|
|
13
13
|
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
14
14
|
var EventHandler2 = HttpApiBuilder.group(Api2, "server.event", (handlers) => Effect.gen(function* () {
|
|
15
|
-
const feed = yield*
|
|
15
|
+
const feed = yield* Service4;
|
|
16
16
|
return handlers.handleRaw("event.subscribe", () => Effect.gen(function* () {
|
|
17
17
|
const connected = {
|
|
18
18
|
id: Event.ID.create(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-smaf4a18.js";
|
|
4
4
|
|
|
5
5
|
// src/location.ts
|
|
6
6
|
import { Location } from "@opencode/core/location";
|
|
@@ -44,7 +44,7 @@ function decode(input) {
|
|
|
44
44
|
return input;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
var
|
|
47
|
+
var layer2 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
48
48
|
const locations = yield* LocationServiceMap.Service;
|
|
49
49
|
return LocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
50
50
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
@@ -52,4 +52,4 @@ var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
|
52
52
|
}));
|
|
53
53
|
}));
|
|
54
54
|
|
|
55
|
-
export { LocationMiddleware2, response2, sessionInfo2, requestRef2,
|
|
55
|
+
export { LocationMiddleware2, response2, sessionInfo2, requestRef2, layer2 };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/event-feed.ts
|
|
6
6
|
var exports_event_feed = {};
|
|
7
7
|
__export(exports_event_feed, {
|
|
8
8
|
EncodingError: () => EncodingError2,
|
|
9
9
|
EventFeed: () => exports_event_feed,
|
|
10
|
-
Service: () =>
|
|
10
|
+
Service: () => Service4,
|
|
11
11
|
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
12
|
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
13
|
frame: () => frame2,
|
|
14
|
-
layer: () =>
|
|
15
|
-
make: () =>
|
|
14
|
+
layer: () => layer5,
|
|
15
|
+
make: () => make4
|
|
16
16
|
});
|
|
17
17
|
import { Bus } from "@opencode/core/bus";
|
|
18
18
|
import { Event } from "@opencode/schema/event";
|
|
@@ -30,14 +30,14 @@ class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
|
|
|
30
30
|
}) {
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class Service4 extends Context.Service()("@opencode/server/EventFeed") {
|
|
34
34
|
}
|
|
35
35
|
function frame2(event) {
|
|
36
36
|
return `data: ${JSON.stringify(event)}
|
|
37
37
|
|
|
38
38
|
`;
|
|
39
39
|
}
|
|
40
|
-
var
|
|
40
|
+
var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
41
41
|
const capacity = options?.capacity ?? SubscriberCapacity2;
|
|
42
42
|
const render = options?.encode ?? frame2;
|
|
43
43
|
const subscribers = new Set;
|
|
@@ -71,13 +71,13 @@ var make3 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
|
71
71
|
});
|
|
72
72
|
const unsubscribe = yield* observe(publish);
|
|
73
73
|
yield* Effect.addFinalizer(() => unsubscribe);
|
|
74
|
-
return
|
|
74
|
+
return Service4.of({
|
|
75
75
|
subscribe: Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.add(queue)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
var
|
|
78
|
+
var layer5 = Layer.effect(Service4, Effect.gen(function* () {
|
|
79
79
|
const bus = yield* Bus.Service;
|
|
80
|
-
return yield*
|
|
80
|
+
return yield* make4(bus.listen);
|
|
81
81
|
}));
|
|
82
82
|
|
|
83
|
-
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2,
|
|
83
|
+
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make4, layer5, exports_event_feed };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-cb0457h1.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./fetch-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
runPtySocket2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./fetch-hezj1jdf.js";
|
|
11
11
|
|
|
12
12
|
// src/handlers/persistent-pty.ts
|
|
13
13
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./fetch-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/auth.ts
|
|
6
|
+
var exports_auth = {};
|
|
7
|
+
__export(exports_auth, {
|
|
8
|
+
Config: () => Config2,
|
|
9
|
+
SESSION_TTL_SECONDS: () => SESSION_TTL_SECONDS2,
|
|
10
|
+
ServerAuth: () => exports_auth,
|
|
11
|
+
authorized: () => authorized2,
|
|
12
|
+
issueSession: () => issueSession2,
|
|
13
|
+
required: () => required2,
|
|
14
|
+
sessionCookieName: () => sessionCookieName2,
|
|
15
|
+
verifySession: () => verifySession2
|
|
16
|
+
});
|
|
17
|
+
import { Context, Layer, Option, Redacted } from "effect";
|
|
18
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
19
|
+
var SESSION_TTL_SECONDS2 = 30 * 24 * 60 * 60;
|
|
20
|
+
|
|
21
|
+
class Config2 extends Context.Service()("@opencode/ServerAuthConfig") {
|
|
22
|
+
static configLayer(input) {
|
|
23
|
+
return Layer.succeed(this, this.of({ ...input, username: "opencode" }));
|
|
24
|
+
}
|
|
25
|
+
static get layer() {
|
|
26
|
+
return this.configLayer({ password: Option.none() });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function required2(config) {
|
|
30
|
+
return Option.isSome(config.password) && config.password.value !== "";
|
|
31
|
+
}
|
|
32
|
+
function authorized2(credentials, config) {
|
|
33
|
+
if (Option.isNone(config.password) || credentials.username !== config.username)
|
|
34
|
+
return false;
|
|
35
|
+
const password = Redacted.value(credentials.password);
|
|
36
|
+
return password === config.password.value || verifySession2(password, config);
|
|
37
|
+
}
|
|
38
|
+
function issueSession2(config, now = Date.now()) {
|
|
39
|
+
if (Option.isNone(config.password))
|
|
40
|
+
return;
|
|
41
|
+
const expires = String(Math.floor(now / 1000) + SESSION_TTL_SECONDS2);
|
|
42
|
+
return `${expires}.${sign(config.password.value, expires)}`;
|
|
43
|
+
}
|
|
44
|
+
function verifySession2(token, config, now = Date.now()) {
|
|
45
|
+
if (Option.isNone(config.password))
|
|
46
|
+
return false;
|
|
47
|
+
const parts = token.split(".");
|
|
48
|
+
if (parts.length !== 2)
|
|
49
|
+
return false;
|
|
50
|
+
const expires = Number(parts[0]);
|
|
51
|
+
if (!Number.isSafeInteger(expires) || expires * 1000 <= now)
|
|
52
|
+
return false;
|
|
53
|
+
const expected = Buffer.from(sign(config.password.value, parts[0]));
|
|
54
|
+
const actual = Buffer.from(parts[1]);
|
|
55
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
56
|
+
}
|
|
57
|
+
function sessionCookieName2(host) {
|
|
58
|
+
const port = URL.parse(`http://${host ?? ""}`)?.port;
|
|
59
|
+
return port ? `opencode_session_${port}` : "opencode_session";
|
|
60
|
+
}
|
|
61
|
+
function sign(password, payload) {
|
|
62
|
+
const key = createHmac("sha256", password).update("opencode-session-v1").digest();
|
|
63
|
+
return createHmac("sha256", key).update(payload).digest("base64url");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { SESSION_TTL_SECONDS2, Config2, required2, authorized2, issueSession2, verifySession2, sessionCookieName2, exports_auth };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationMiddleware2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-8j6eh3dh.js";
|
|
4
4
|
import {
|
|
5
5
|
FormLocationMiddleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-27edjygf.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionLocationMiddleware2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-kb9735wh.js";
|
|
10
10
|
|
|
11
11
|
// src/api.ts
|
|
12
12
|
import { makeDefaultApi } from "@opencode/protocol/api";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Config2,
|
|
3
3
|
required2,
|
|
4
|
-
authorized2
|
|
5
|
-
|
|
4
|
+
authorized2,
|
|
5
|
+
verifySession2,
|
|
6
|
+
sessionCookieName2
|
|
7
|
+
} from "./fetch-anm12x33.js";
|
|
6
8
|
|
|
7
9
|
// src/middleware/authorization.ts
|
|
8
10
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
@@ -10,6 +12,7 @@ import { Authorization } from "@opencode/protocol/middleware/authorization";
|
|
|
10
12
|
import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
|
|
11
13
|
import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
|
|
12
14
|
import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
|
|
15
|
+
import { isPairingConnectURL } from "@opencode/protocol/groups/server";
|
|
13
16
|
import { Effect, Encoding, Layer, Redacted } from "effect";
|
|
14
17
|
import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
15
18
|
var AUTH_TOKEN_QUERY = "auth_token";
|
|
@@ -38,8 +41,25 @@ function credentialFromRequest(request) {
|
|
|
38
41
|
return decodeCredential(match[1]);
|
|
39
42
|
return Effect.succeed(emptyCredential());
|
|
40
43
|
}
|
|
44
|
+
var UNAUTHORIZED_MESSAGE = "Authentication required";
|
|
45
|
+
function challengeRequest(request) {
|
|
46
|
+
const mode = request.headers["sec-fetch-mode"];
|
|
47
|
+
return mode === undefined || mode === "navigate";
|
|
48
|
+
}
|
|
49
|
+
function unauthorizedResponse2(request) {
|
|
50
|
+
return HttpServerResponse.jsonUnsafe({ _tag: "UnauthorizedError", message: UNAUTHORIZED_MESSAGE }, { status: 401, headers: challengeRequest(request) ? { "www-authenticate": WWW_AUTHENTICATE } : undefined });
|
|
51
|
+
}
|
|
41
52
|
function authorizedRequest2(request, config) {
|
|
42
|
-
return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config)));
|
|
53
|
+
return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config) || authorizedSessionCookie(request, config)));
|
|
54
|
+
}
|
|
55
|
+
function authorizedSessionCookie(request, config) {
|
|
56
|
+
const token = request.cookies[sessionCookieName2(request.headers.host)];
|
|
57
|
+
if (!token)
|
|
58
|
+
return false;
|
|
59
|
+
const origin = request.headers.origin;
|
|
60
|
+
if (origin !== undefined && URL.parse(origin)?.host !== request.headers.host)
|
|
61
|
+
return false;
|
|
62
|
+
return verifySession2(token, config);
|
|
43
63
|
}
|
|
44
64
|
var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
45
65
|
const config = yield* Config2;
|
|
@@ -48,13 +68,14 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
|
48
68
|
return Authorization.of((effect) => Effect.gen(function* () {
|
|
49
69
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
50
70
|
const url = new URL(request.url, "http://localhost");
|
|
51
|
-
if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url))
|
|
71
|
+
if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url) || isPairingConnectURL(url))
|
|
52
72
|
return yield* effect;
|
|
53
73
|
if (yield* authorizedRequest2(request, config))
|
|
54
74
|
return yield* effect;
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
if (challengeRequest(request))
|
|
76
|
+
yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
|
|
77
|
+
return yield* new UnauthorizedError({ message: UNAUTHORIZED_MESSAGE });
|
|
57
78
|
}));
|
|
58
79
|
}));
|
|
59
80
|
|
|
60
|
-
export { authorizedRequest2, authorizationLayer2, Authorization2 };
|
|
81
|
+
export { unauthorizedResponse2, authorizedRequest2, authorizationLayer2, Authorization2 };
|