poe-code 3.0.450 → 3.0.451-beta.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "3.0.450",
3
+ "version": "3.0.451-beta.1",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -277,6 +277,7 @@
277
277
  "globals": "^17.3.0",
278
278
  "husky": "^9.1.7",
279
279
  "mcp-oauth": "*",
280
+ "mcp-oauth-server": "*",
280
281
  "memfs": "^4.56.10",
281
282
  "opencode-poe-auth": "*",
282
283
  "poe-oauth": "*",
@@ -1,6 +1,7 @@
1
1
  import "./node-require-shim.js";
2
2
  import { type HttpListenOptions, type HttpServer, type HttpServerHandle, type HttpToolContext, type HttpTransportOptions } from "../../tiny-http-mcp-server/dist/server.js";
3
3
  import type { Group } from "./index.js";
4
+ import type { OAuthAuthorizationServer } from "../../mcp-oauth-server/dist/index.js";
4
5
  import { type RunMCPOptions } from "./mcp.js";
5
6
  export type ToolcraftHTTPContext = HttpToolContext;
6
7
  export type ToolcraftHTTPServer = HttpServer;
@@ -13,7 +14,16 @@ export interface RunHTTPMCPOptions<TServices extends object = Record<string, unk
13
14
  path?: string;
14
15
  requestServices?(context: ToolcraftHTTPContext): Partial<TServices> | Promise<Partial<TServices>>;
15
16
  }
17
+ export interface HTTPMCPAuthorizationOptions {
18
+ authorizationServer: Pick<OAuthAuthorizationServer, "issuer" | "verifyAccessToken">;
19
+ resource: string;
20
+ requiredScopes?: readonly string[];
21
+ scopesSupported?: readonly string[];
22
+ }
23
+ export declare function createHTTPMCPAuthorization(options: HTTPMCPAuthorizationOptions): import("../../tiny-http-mcp-server/dist/server.js").TinyHttpMcpServerOAuthOptions;
16
24
  export declare function createHTTPMCPServer<TServices extends object = Record<string, unknown>>(roots: Group<TServices> | Group<TServices>[], options: RunHTTPMCPOptions<TServices>): Promise<ToolcraftHTTPServer>;
17
25
  export declare function runHTTPMCP<TServices extends object = Record<string, unknown>>(roots: Group<TServices> | Group<TServices>[], options: RunHTTPMCPOptions<TServices>): Promise<ToolcraftHTTPServerHandle>;
18
26
  export type { HttpListenOptions, HttpObservabilityEvent, HttpObservabilityOptions, RequestAuthInfo, Session, SessionStore, StreamableHttpTransportOptions, TinyHttpMcpServerOAuthOptions, TokenVerifier, VerifiedAccessToken } from "../../tiny-http-mcp-server/dist/server.js";
19
27
  export { createJwksTokenVerifier, TokenVerificationError } from "../../tiny-http-mcp-server/dist/server.js";
28
+ export { createAuthorizationInteractionSecurity, createInMemoryAuthorizationServerStore, createOAuthAuthorizationServer, verifyAuthorizationInteractionCsrf } from "../../mcp-oauth-server/dist/index.js";
29
+ export type { AuthorizationInteraction, AuthorizationInteractionSecurity, AuthorizationServerStore, OAuthAuthorizationServer, OAuthAuthorizationServerOptions, VerifiedAuthorizationServerToken } from "../../mcp-oauth-server/dist/index.js";
@@ -2,6 +2,45 @@ import "./node-require-shim.js";
2
2
  import { createHttpServer } from "tiny-http-mcp-server/server";
3
3
  import { createMCPServerForTransport } from "./mcp.js";
4
4
  import { enableSourceMaps } from "./stack-trim.js";
5
+ function toVerifiedAccessToken(token, issuer, verified) {
6
+ return {
7
+ token,
8
+ issuer,
9
+ audience: [verified.resource],
10
+ scopes: [...verified.scopes],
11
+ expiresAt: verified.expiresAt,
12
+ claims: {
13
+ sub: verified.subject,
14
+ client_id: verified.clientId,
15
+ aud: verified.resource,
16
+ jti: verified.tokenId
17
+ },
18
+ subject: verified.subject,
19
+ clientId: verified.clientId
20
+ };
21
+ }
22
+ export function createHTTPMCPAuthorization(options) {
23
+ const issuer = options.authorizationServer.issuer;
24
+ const resource = new URL(options.resource).href;
25
+ return {
26
+ resource,
27
+ authorizationServers: [issuer],
28
+ requiredScopes: options.requiredScopes,
29
+ scopesSupported: options.scopesSupported ?? options.requiredScopes,
30
+ verifier: {
31
+ async verify(input) {
32
+ if (input.authorizationServers.length !== 1 || input.authorizationServers[0] !== issuer) {
33
+ throw new Error("authorization server issuer does not match");
34
+ }
35
+ if (new URL(input.resource).href !== resource) {
36
+ throw new Error("protected resource does not match");
37
+ }
38
+ const verified = await options.authorizationServer.verifyAccessToken(input.token, resource);
39
+ return toVerifiedAccessToken(input.token, issuer, verified);
40
+ }
41
+ }
42
+ };
43
+ }
5
44
  function createTransportOptions(options, serverOptions) {
6
45
  return {
7
46
  ...serverOptions,
@@ -60,3 +99,4 @@ export async function runHTTPMCP(roots, options) {
60
99
  return server.listenHttp(createListenOptions(options));
61
100
  }
62
101
  export { createJwksTokenVerifier, TokenVerificationError } from "tiny-http-mcp-server/server";
102
+ export { createAuthorizationInteractionSecurity, createInMemoryAuthorizationServerStore, createOAuthAuthorizationServer, verifyAuthorizationInteractionCsrf } from "mcp-oauth-server";