@williamp29/project-mcp-server 1.0.4 → 1.1.0

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.
@@ -1,3 +1,4 @@
1
+ import { isIdentifiable } from "./types.js";
1
2
  import { BearerStrategy } from "./strategies/bearer-strategy.js";
2
3
  import { IdentityStrategy } from "./strategies/identity-strategy.js";
3
4
  import { NoAuthStrategy } from "./strategies/no-auth-strategy.js";
@@ -16,7 +17,7 @@ export class GlobalAuthContext {
16
17
  this.strategy = strategy;
17
18
  }
18
19
  setIdentifier(value) {
19
- if (this.strategy instanceof IdentityStrategy) {
20
+ if (isIdentifiable(this.strategy)) {
20
21
  this.strategy.setIdentifier(value);
21
22
  }
22
23
  else {
@@ -24,7 +25,7 @@ export class GlobalAuthContext {
24
25
  }
25
26
  }
26
27
  getIdentifier() {
27
- if (this.strategy instanceof IdentityStrategy) {
28
+ if (isIdentifiable(this.strategy)) {
28
29
  return this.strategy.getIdentifier();
29
30
  }
30
31
  return "";
@@ -1,9 +1,9 @@
1
- import { AuthStrategy } from "../types.js";
1
+ import { IdentifiableStrategy } from "../types.js";
2
2
  /**
3
3
  * Highly flexible authentication strategy for custom headers and identifiers.
4
4
  * Useful for scenarios like "Authorization: UID <identifier>" or "X-API-Key: <key>".
5
5
  */
6
- export declare class IdentityStrategy implements AuthStrategy {
6
+ export declare class IdentityStrategy implements IdentifiableStrategy {
7
7
  private headerKey;
8
8
  private identifiable;
9
9
  name: string;
@@ -9,6 +9,18 @@ export interface AuthStrategy {
9
9
  */
10
10
  getHeaders(): Record<string, string> | Promise<Record<string, string>>;
11
11
  }
12
+ /**
13
+ * Extension of AuthStrategy that supports dynamic identity changes.
14
+ * Implement this interface if your custom strategy needs impersonation.
15
+ */
16
+ export interface IdentifiableStrategy extends AuthStrategy {
17
+ setIdentifier(value: string): void;
18
+ getIdentifier(): string;
19
+ }
20
+ /**
21
+ * Type guard to check if a strategy supports identifier changes.
22
+ */
23
+ export declare function isIdentifiable(strategy: AuthStrategy): strategy is IdentifiableStrategy;
12
24
  /**
13
25
  * Manages the current authentication state and allows dynamic identifier updates.
14
26
  */
@@ -1 +1,6 @@
1
- export {};
1
+ /**
2
+ * Type guard to check if a strategy supports identifier changes.
3
+ */
4
+ export function isIdentifiable(strategy) {
5
+ return 'setIdentifier' in strategy && 'getIdentifier' in strategy;
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamp29/project-mcp-server",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "A ModelContextProtocol server to let agents discover your project, such as APIs (using OpenAPI) or other resources.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",