@plitzi/sdk-server 0.32.10 → 0.32.12
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/CHANGELOG.md +20 -0
- package/dist/core/http/dispatcher.js +48 -10
- package/dist/core/requestParser.js +18 -1
- package/dist/core/services/mcp.js +4 -4
- package/dist/core/services/oauth.js +71 -0
- package/dist/core/services/registry.js +2 -0
- package/dist/core/services/rsc.js +1 -0
- package/dist/helpers/serverLog.js +34 -0
- package/dist/index.js +2 -1
- package/dist/mcp.js +2 -1
- package/dist/modules/mcp/handler.js +10 -0
- package/dist/modules/mcp/helpers/log.js +20 -10
- package/dist/modules/mcp/resources/register.js +10 -4
- package/dist/modules/mcp/resources/renderGuide.js +17 -7
- package/dist/modules/mcp/server.js +1 -1
- package/dist/modules/oauth/authorize.js +160 -0
- package/dist/modules/oauth/consentPage.js +111 -0
- package/dist/modules/oauth/metadata.js +43 -0
- package/dist/modules/oauth/params.js +5 -0
- package/dist/modules/oauth/pkce.js +15 -0
- package/dist/modules/oauth/records.js +35 -0
- package/dist/modules/oauth/register.js +48 -0
- package/dist/modules/oauth/respond.js +44 -0
- package/dist/modules/oauth/token.js +92 -0
- package/dist/plugins/manager.js +2 -0
- package/dist/plugins/validate.js +23 -0
- package/dist/src/core/http/dispatcher.test.d.ts +1 -0
- package/dist/src/core/http/types.d.ts +3 -0
- package/dist/src/core/requestParser.d.ts +5 -0
- package/dist/src/core/services/oauth.d.ts +8 -0
- package/dist/src/helpers/buildResponseHelpers.d.ts +2 -0
- package/dist/src/helpers/serverLog.d.ts +10 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/mcp.d.ts +1 -0
- package/dist/src/modules/mcp/handler.d.ts +4 -4
- package/dist/src/modules/mcp/helpers/log.d.ts +3 -3
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +2 -1
- package/dist/src/modules/mcp/server.d.ts +2 -2
- package/dist/src/modules/oauth/authorize.d.ts +7 -0
- package/dist/src/modules/oauth/consentPage.d.ts +7 -0
- package/dist/src/modules/oauth/metadata.d.ts +17 -0
- package/dist/src/modules/oauth/oauth.test.d.ts +1 -0
- package/dist/src/modules/oauth/params.d.ts +5 -0
- package/dist/src/modules/oauth/pkce.d.ts +6 -0
- package/dist/src/modules/oauth/records.d.ts +49 -0
- package/dist/src/modules/oauth/register.d.ts +5 -0
- package/dist/src/modules/oauth/respond.d.ts +13 -0
- package/dist/src/modules/oauth/token.d.ts +5 -0
- package/dist/src/plugins/validate.d.ts +9 -0
- package/dist/src/plugins/validate.test.d.ts +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OAuthGrantTarget, OAuthStore, OAuthUser } from '@plitzi/sdk-shared';
|
|
2
|
+
/** A client that registered itself through RFC 7591. Public clients only — a desktop host cannot keep a secret,
|
|
3
|
+
* so the token endpoint authenticates the exchange with PKCE instead. */
|
|
4
|
+
export type ClientRecord = {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientName: string;
|
|
7
|
+
redirectUris: string[];
|
|
8
|
+
};
|
|
9
|
+
/** The authorization request, parked while the user logs in. `challenge` binds the eventual code to the client
|
|
10
|
+
* that started the flow. */
|
|
11
|
+
export type PendingRecord = {
|
|
12
|
+
clientId: string;
|
|
13
|
+
redirectUri: string;
|
|
14
|
+
challenge: string;
|
|
15
|
+
state?: string;
|
|
16
|
+
scope?: string;
|
|
17
|
+
user: OAuthUser;
|
|
18
|
+
};
|
|
19
|
+
/** A code, redeemable once, for the token it already resolves to. Minting the bearer at consent time (rather than
|
|
20
|
+
* at redemption) means a failure the user could act on — no space, revoked access — surfaces on the consent
|
|
21
|
+
* screen instead of as an opaque `invalid_grant` inside the host. */
|
|
22
|
+
export type CodeRecord = {
|
|
23
|
+
clientId: string;
|
|
24
|
+
redirectUri: string;
|
|
25
|
+
challenge: string;
|
|
26
|
+
token: string;
|
|
27
|
+
expiresInSeconds?: number;
|
|
28
|
+
scope?: string;
|
|
29
|
+
user: OAuthUser;
|
|
30
|
+
target: OAuthGrantTarget;
|
|
31
|
+
};
|
|
32
|
+
/** A refresh grant: everything needed to mint a fresh bearer without asking the user again. */
|
|
33
|
+
export type RefreshRecord = {
|
|
34
|
+
clientId: string;
|
|
35
|
+
scope?: string;
|
|
36
|
+
user: OAuthUser;
|
|
37
|
+
target: OAuthGrantTarget;
|
|
38
|
+
};
|
|
39
|
+
export declare const putClient: (store: OAuthStore, client: ClientRecord) => Promise<void>;
|
|
40
|
+
export declare const getClient: (store: OAuthStore, clientId: string) => Promise<ClientRecord | undefined>;
|
|
41
|
+
export declare const putPending: (store: OAuthStore, id: string, pending: PendingRecord) => Promise<void>;
|
|
42
|
+
export declare const getPending: (store: OAuthStore, id: string) => Promise<PendingRecord | undefined>;
|
|
43
|
+
export declare const dropPending: (store: OAuthStore, id: string) => Promise<void>;
|
|
44
|
+
export declare const putCode: (store: OAuthStore, code: string, record: CodeRecord, ttlSeconds: number) => Promise<void>;
|
|
45
|
+
export declare const getCode: (store: OAuthStore, code: string) => Promise<CodeRecord | undefined>;
|
|
46
|
+
export declare const dropCode: (store: OAuthStore, code: string) => Promise<void>;
|
|
47
|
+
export declare const putRefresh: (store: OAuthStore, token: string, record: RefreshRecord, ttlSeconds: number) => Promise<void>;
|
|
48
|
+
export declare const getRefresh: (store: OAuthStore, token: string) => Promise<RefreshRecord | undefined>;
|
|
49
|
+
export declare const dropRefresh: (store: OAuthStore, token: string) => Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { OAuthConfig, SSRResponseHelpers } from '@plitzi/sdk-shared';
|
|
2
|
+
/** RFC 7591 dynamic client registration. A remote host has no way to be configured into this server ahead of
|
|
3
|
+
* time, so it registers itself on first connect; the record it gets back is only ever used to pin the redirect
|
|
4
|
+
* target, since a public client authenticates with PKCE rather than with credentials. */
|
|
5
|
+
export declare const handleRegister: (config: OAuthConfig, res: SSRResponseHelpers, body: unknown) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SSRResponseHelpers } from '@plitzi/sdk-shared';
|
|
2
|
+
/** The error codes RFC 6749 defines for the responses this server produces. */
|
|
3
|
+
export type OAuthErrorCode = 'invalid_request' | 'invalid_client' | 'invalid_grant' | 'unauthorized_client' | 'unsupported_grant_type' | 'unsupported_response_type' | 'invalid_scope' | 'access_denied' | 'server_error';
|
|
4
|
+
export declare const sendJson: (res: SSRResponseHelpers, status: number, body: unknown) => void;
|
|
5
|
+
export declare const sendHtml: (res: SSRResponseHelpers, status: number, html: string) => void;
|
|
6
|
+
export declare const sendErrorJson: (res: SSRResponseHelpers, status: number, error: OAuthErrorCode, description: string) => void;
|
|
7
|
+
/** Shown when the authorization request itself is unusable — an unknown client, a `redirect_uri` that is not
|
|
8
|
+
* registered. Redirecting those back would turn the endpoint into an open redirector. */
|
|
9
|
+
export declare const sendErrorPage: (res: SSRResponseHelpers, title: string, detail: string) => void;
|
|
10
|
+
/** The other half of RFC 6749 error handling: once the redirect target is known to be legitimate, failures go
|
|
11
|
+
* back to the client so the host can report them, carrying `state` so it can match the response to its request. */
|
|
12
|
+
export declare const redirectWithError: (res: SSRResponseHelpers, redirectUri: string, error: OAuthErrorCode, description: string, state?: string) => void;
|
|
13
|
+
export declare const redirectWithCode: (res: SSRResponseHelpers, redirectUri: string, code: string, state?: string) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { OAuthParams } from './params';
|
|
2
|
+
import { OAuthConfig, SSRResponseHelpers } from '@plitzi/sdk-shared';
|
|
3
|
+
/** POST /token. Public clients only, so there is no client authentication to check — PKCE is what proves the
|
|
4
|
+
* caller is the one that started the flow. */
|
|
5
|
+
export declare const handleToken: (config: OAuthConfig, res: SSRResponseHelpers, params: OAuthParams) => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginSource } from '@plitzi/sdk-shared';
|
|
2
|
+
/** The file a plugin source needs on disk, or null when nothing local is involved — a remote URL (fetched and
|
|
3
|
+
* cached at request time) or a component handed in directly. */
|
|
4
|
+
export declare const localSourcePath: (source: PluginSource) => string | null;
|
|
5
|
+
/** Fail at boot on a plugin whose entry file is missing. A plugin entry is a plain string path in the server
|
|
6
|
+
* config, so nothing — not tsc, not eslint — notices when that file is moved or deleted; without this check the
|
|
7
|
+
* server starts happily and only dies on the first render that needs the plugin, with an esbuild resolve error
|
|
8
|
+
* far from its cause. */
|
|
9
|
+
export declare const assertPluginSources: (plugins: Record<string, PluginSource>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.12",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
31
31
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
32
|
-
"@plitzi/plitzi-sdk": "0.32.
|
|
33
|
-
"@plitzi/sdk-schema": "0.32.
|
|
34
|
-
"@plitzi/sdk-shared": "0.32.
|
|
32
|
+
"@plitzi/plitzi-sdk": "0.32.12",
|
|
33
|
+
"@plitzi/sdk-schema": "0.32.12",
|
|
34
|
+
"@plitzi/sdk-shared": "0.32.12",
|
|
35
35
|
"ejs": "^6.0.1",
|
|
36
36
|
"esbuild": "^0.28.1",
|
|
37
37
|
"zod": "^4.4.3"
|