@frontmcp/auth 1.0.4 → 1.1.0-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.
Files changed (85) hide show
  1. package/authorities/authorities.context.d.ts +63 -0
  2. package/authorities/authorities.context.d.ts.map +1 -0
  3. package/authorities/authorities.engine.d.ts +65 -0
  4. package/authorities/authorities.engine.d.ts.map +1 -0
  5. package/authorities/authorities.errors.d.ts +59 -0
  6. package/authorities/authorities.errors.d.ts.map +1 -0
  7. package/authorities/authorities.evaluator.d.ts +28 -0
  8. package/authorities/authorities.evaluator.d.ts.map +1 -0
  9. package/authorities/authorities.metadata-augment.d.ts +31 -0
  10. package/authorities/authorities.metadata-augment.d.ts.map +1 -0
  11. package/authorities/authorities.profiles.d.ts +75 -0
  12. package/authorities/authorities.profiles.d.ts.map +1 -0
  13. package/authorities/authorities.registry.d.ts +86 -0
  14. package/authorities/authorities.registry.d.ts.map +1 -0
  15. package/authorities/authorities.schema.d.ts +24 -0
  16. package/authorities/authorities.schema.d.ts.map +1 -0
  17. package/authorities/authorities.scope-mapping.d.ts +16 -0
  18. package/authorities/authorities.scope-mapping.d.ts.map +1 -0
  19. package/authorities/authorities.types.d.ts +290 -0
  20. package/authorities/authorities.types.d.ts.map +1 -0
  21. package/authorities/index.d.ts +17 -0
  22. package/authorities/index.d.ts.map +1 -0
  23. package/authorization/authorization.class.d.ts +2 -3
  24. package/authorization/authorization.class.d.ts.map +1 -1
  25. package/authorization/authorization.types.d.ts +53 -54
  26. package/authorization/authorization.types.d.ts.map +1 -1
  27. package/authorization/index.d.ts +1 -1
  28. package/authorization/index.d.ts.map +1 -1
  29. package/cimd/cimd.types.d.ts +90 -90
  30. package/cimd/cimd.types.d.ts.map +1 -1
  31. package/common/jwt.types.d.ts +16 -16
  32. package/common/jwt.types.d.ts.map +1 -1
  33. package/common/session.types.d.ts +75 -76
  34. package/common/session.types.d.ts.map +1 -1
  35. package/common/zod-utils.d.ts +1 -1
  36. package/common/zod-utils.d.ts.map +1 -1
  37. package/consent/consent.types.d.ts +69 -69
  38. package/consent/consent.types.d.ts.map +1 -1
  39. package/context/frontmcp-auth-context.d.ts +113 -0
  40. package/context/frontmcp-auth-context.d.ts.map +1 -0
  41. package/context/frontmcp-auth-context.factory.d.ts +39 -0
  42. package/context/frontmcp-auth-context.factory.d.ts.map +1 -0
  43. package/context/frontmcp-auth-context.impl.d.ts +72 -0
  44. package/context/frontmcp-auth-context.impl.d.ts.map +1 -0
  45. package/context/index.d.ts +16 -0
  46. package/context/index.d.ts.map +1 -0
  47. package/detection/auth-provider-detection.d.ts +25 -25
  48. package/detection/auth-provider-detection.d.ts.map +1 -1
  49. package/esm/index.mjs +1036 -120
  50. package/esm/package.json +5 -5
  51. package/fetch/fetch-credential-middleware.d.ts +99 -0
  52. package/fetch/fetch-credential-middleware.d.ts.map +1 -0
  53. package/fetch/index.d.ts +10 -0
  54. package/fetch/index.d.ts.map +1 -0
  55. package/index.d.ts +6 -2
  56. package/index.d.ts.map +1 -1
  57. package/index.js +1619 -680
  58. package/machine-id/index.d.ts +1 -1
  59. package/machine-id/index.d.ts.map +1 -1
  60. package/options/app-auth.schema.d.ts +235 -235
  61. package/options/app-auth.schema.d.ts.map +1 -1
  62. package/options/orchestrated.schema.d.ts +371 -371
  63. package/options/orchestrated.schema.d.ts.map +1 -1
  64. package/options/public.schema.d.ts +16 -16
  65. package/options/public.schema.d.ts.map +1 -1
  66. package/options/schema.d.ts +227 -227
  67. package/options/schema.d.ts.map +1 -1
  68. package/options/shared.schemas.d.ts +97 -97
  69. package/options/shared.schemas.d.ts.map +1 -1
  70. package/options/transparent.schema.d.ts +30 -30
  71. package/options/transparent.schema.d.ts.map +1 -1
  72. package/options/typecheck.d.ts.map +1 -1
  73. package/package.json +5 -5
  74. package/session/authorization-vault.d.ts +380 -380
  75. package/session/authorization-vault.d.ts.map +1 -1
  76. package/session/authorization.store.d.ts +28 -29
  77. package/session/authorization.store.d.ts.map +1 -1
  78. package/session/encrypted-authorization-vault.d.ts +21 -21
  79. package/session/encrypted-authorization-vault.d.ts.map +1 -1
  80. package/session/transport-session.types.d.ts +166 -167
  81. package/session/transport-session.types.d.ts.map +1 -1
  82. package/session/vault-encryption.d.ts +27 -27
  83. package/session/vault-encryption.d.ts.map +1 -1
  84. package/vault/auth-providers.types.d.ts +45 -46
  85. package/vault/auth-providers.types.d.ts.map +1 -1
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Authorities Evaluation Context Builder
3
+ *
4
+ * Builds an AuthoritiesEvaluationContext from AuthInfo and claimsMapping.
5
+ * Handles JWT shape differences across IdPs (Auth0, Keycloak, Okta, etc.).
6
+ */
7
+ import type { AuthoritiesEvaluationContext, RelationshipResolver } from './authorities.types';
8
+ import type { AuthoritiesClaimsMapping } from './authorities.profiles';
9
+ /**
10
+ * Resolve a dot-path value from a nested object.
11
+ * First tries a direct key lookup (for keys containing dots, e.g., Auth0 namespaced claims),
12
+ * then falls back to dot-separated path traversal.
13
+ *
14
+ * @example
15
+ * resolveDotPath({ a: { b: { c: 42 } } }, 'a.b.c') // 42
16
+ * resolveDotPath({ 'https://myapp.com/roles': ['admin'] }, 'https://myapp.com/roles') // ['admin']
17
+ * resolveDotPath({ a: 1 }, 'a.b') // undefined
18
+ */
19
+ export declare function resolveDotPath(obj: Record<string, unknown>, path: string): unknown;
20
+ /**
21
+ * Function signature for custom claims resolution.
22
+ */
23
+ export type ClaimsResolverFn = (authInfo: Partial<AuthInfoLike>) => {
24
+ roles: string[];
25
+ permissions: string[];
26
+ claims: Record<string, unknown>;
27
+ };
28
+ /**
29
+ * Minimal shape of AuthInfo that the context builder needs.
30
+ * Avoids hard dependency on @frontmcp/protocol.
31
+ */
32
+ export interface AuthInfoLike {
33
+ user?: {
34
+ sub?: string;
35
+ roles?: string[];
36
+ permissions?: string[];
37
+ [key: string]: unknown;
38
+ };
39
+ extra?: Record<string, unknown>;
40
+ [key: string]: unknown;
41
+ }
42
+ /**
43
+ * Options for building an evaluation context.
44
+ */
45
+ export interface AuthoritiesContextBuilderOptions {
46
+ claimsMapping?: AuthoritiesClaimsMapping;
47
+ claimsResolver?: ClaimsResolverFn;
48
+ relationshipResolver?: RelationshipResolver;
49
+ }
50
+ /**
51
+ * Builds AuthoritiesEvaluationContext from request-time AuthInfo.
52
+ */
53
+ export declare class AuthoritiesContextBuilder {
54
+ private readonly claimsMapping;
55
+ private readonly claimsResolver;
56
+ private readonly relationshipResolver;
57
+ constructor(options?: AuthoritiesContextBuilderOptions);
58
+ /**
59
+ * Build an evaluation context from AuthInfo and tool input.
60
+ */
61
+ build(authInfo: Partial<AuthInfoLike>, input?: Record<string, unknown>, env?: Record<string, unknown>): AuthoritiesEvaluationContext;
62
+ }
63
+ //# sourceMappingURL=authorities.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.context.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAelF;AA0BD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK;IAClE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED;;GAEG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuC;IACrE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAC9D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;gBAEhD,OAAO,GAAE,gCAAqC;IAM1D;;OAEG;IACH,KAAK,CACH,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,EAC/B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACnC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAChC,4BAA4B;CAsEhC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Authorities Evaluation Engine
3
+ *
4
+ * Orchestrates policy evaluation with profile resolution,
5
+ * built-in evaluators, custom evaluators, and combinators.
6
+ */
7
+ import type { AuthoritiesEvaluatorRegistry, AuthoritiesProfileRegistry } from './authorities.registry';
8
+ import type { AuthoritiesEvaluationContext, AuthoritiesMetadata, AuthoritiesResult } from './authorities.types';
9
+ /**
10
+ * The main evaluation engine.
11
+ *
12
+ * Usage:
13
+ * ```typescript
14
+ * const engine = new AuthoritiesEngine(profileRegistry, evaluatorRegistry);
15
+ * const result = await engine.evaluate(authorities, ctx);
16
+ * if (!result.granted) throw new AuthorityDeniedError({ ... });
17
+ * ```
18
+ */
19
+ export declare class AuthoritiesEngine {
20
+ private readonly profiles;
21
+ private readonly evaluators;
22
+ constructor(profiles: AuthoritiesProfileRegistry, evaluators: AuthoritiesEvaluatorRegistry);
23
+ /**
24
+ * Evaluate an AuthoritiesMetadata value (string, string[], or policy object).
25
+ */
26
+ evaluate(authorities: AuthoritiesMetadata, ctx: AuthoritiesEvaluationContext): Promise<AuthoritiesResult>;
27
+ /**
28
+ * Resolve and evaluate a single named profile.
29
+ */
30
+ private evaluateProfile;
31
+ /**
32
+ * Evaluate an array of profile names (AND semantics).
33
+ */
34
+ private evaluateProfileArray;
35
+ /**
36
+ * Evaluate an inline policy object.
37
+ */
38
+ private evaluatePolicy;
39
+ /**
40
+ * Combine results with AND or OR semantics.
41
+ */
42
+ private combineResults;
43
+ /**
44
+ * Evaluate custom evaluators.
45
+ */
46
+ private evaluateCustom;
47
+ /**
48
+ * Evaluate async guard functions in sequence.
49
+ * Each guard returns true (granted) or a string (denial message).
50
+ */
51
+ private evaluateGuards;
52
+ /**
53
+ * allOf combinator — all nested policies must pass.
54
+ */
55
+ private evaluateAllOf;
56
+ /**
57
+ * anyOf combinator — at least one nested policy must pass.
58
+ */
59
+ private evaluateAnyOf;
60
+ /**
61
+ * not combinator — inverts the nested policy result.
62
+ */
63
+ private evaluateNot;
64
+ }
65
+ //# sourceMappingURL=authorities.engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.engine.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,KAAK,EACV,4BAA4B,EAC5B,mBAAmB,EAEnB,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAoB7B;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,QAAQ,EAAE,0BAA0B,EACpC,UAAU,EAAE,4BAA4B;IAG3D;;OAEG;IACG,QAAQ,CAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,EAAE,4BAA4B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAe/G;;OAEG;YACW,eAAe;IAsB7B;;OAEG;YACW,oBAAoB;IAclC;;OAEG;YACW,cAAc;IA+C5B;;OAEG;IACH,OAAO,CAAC,cAAc;IA0BtB;;OAEG;YACW,cAAc;IA2B5B;;;OAGG;YACW,cAAc;IAoB5B;;OAEG;YACW,aAAa;IAiB3B;;OAEG;YACW,aAAa;IAwB3B;;OAEG;YACW,WAAW;CAa1B"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Authority Denied Error
3
+ *
4
+ * Thrown when an entry's authorities policy denies access.
5
+ * Uses MCP FORBIDDEN error code (-32003) for JSON-RPC responses.
6
+ */
7
+ import type { AuthoritiesDenial } from './authorities.types';
8
+ /**
9
+ * Parameters for creating an AuthorityDeniedError.
10
+ */
11
+ export interface AuthorityDeniedErrorParams {
12
+ /** Entry type: 'Tool', 'Resource', 'Prompt', 'Skill', 'Agent' */
13
+ entryType: string;
14
+ /** Entry name (e.g., 'delete-user') */
15
+ entryName: string;
16
+ /** Policy that denied access (e.g., "roles.all: missing 'admin'") */
17
+ deniedBy: string;
18
+ /** Optional custom message */
19
+ message?: string;
20
+ /** Structured denial data (machine-parsable) */
21
+ denial?: AuthoritiesDenial;
22
+ /** Required scopes for scope challenges */
23
+ requiredScopes?: string[];
24
+ }
25
+ /**
26
+ * Error thrown when an authorities policy denies access.
27
+ *
28
+ * Extends the standard Error class. When used within the FrontMCP SDK,
29
+ * the enforcement plugin maps this to the appropriate MCP error response
30
+ * with code -32003 (FORBIDDEN).
31
+ */
32
+ export declare class AuthorityDeniedError extends Error {
33
+ /** MCP error code for JSON-RPC responses */
34
+ readonly mcpErrorCode = -32003;
35
+ /** HTTP status code equivalent */
36
+ readonly statusCode = 403;
37
+ /** Error classification code */
38
+ readonly code = "AUTHORITY_DENIED";
39
+ /** Entry type that was denied */
40
+ readonly entryType: string;
41
+ /** Entry name that was denied */
42
+ readonly entryName: string;
43
+ /** Policy that caused the denial */
44
+ readonly deniedBy: string;
45
+ /** Structured denial data (machine-parsable) */
46
+ readonly denial?: AuthoritiesDenial;
47
+ /** Required scopes for scope challenges */
48
+ readonly requiredScopes?: string[];
49
+ constructor(params: AuthorityDeniedErrorParams);
50
+ /**
51
+ * Convert to JSON-RPC error format.
52
+ */
53
+ toJsonRpcError(): {
54
+ code: number;
55
+ message: string;
56
+ data?: Record<string, unknown>;
57
+ };
58
+ }
59
+ //# sourceMappingURL=authorities.errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.errors.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,4CAA4C;IAC5C,QAAQ,CAAC,YAAY,UAAkB;IACvC,kCAAkC;IAClC,QAAQ,CAAC,UAAU,OAAO;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,IAAI,sBAAsB;IACnC,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;gBAEvB,MAAM,EAAE,0BAA0B;IAW9C;;OAEG;IACH,cAAc,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAcpF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Built-in Authority Evaluators
3
+ *
4
+ * Pure functions for evaluating RBAC, ABAC, and ReBAC policies.
5
+ */
6
+ import type { RbacRolesPolicy, RbacPermissionsPolicy, AbacPolicy, RebacPolicy, ResourceIdRef, AuthoritiesResult, AuthoritiesEvaluationContext } from './authorities.types';
7
+ /**
8
+ * Evaluate RBAC roles policy against user roles.
9
+ */
10
+ export declare function evaluateRbacRoles(policy: RbacRolesPolicy, ctx: AuthoritiesEvaluationContext): AuthoritiesResult;
11
+ /**
12
+ * Evaluate RBAC permissions policy against user permissions.
13
+ */
14
+ export declare function evaluateRbacPermissions(policy: RbacPermissionsPolicy, ctx: AuthoritiesEvaluationContext): AuthoritiesResult;
15
+ /**
16
+ * Evaluate ABAC policy.
17
+ */
18
+ export declare function evaluateAbac(policy: AbacPolicy, ctx: AuthoritiesEvaluationContext): AuthoritiesResult;
19
+ /**
20
+ * Resolve a ResourceIdRef to a concrete string.
21
+ */
22
+ export declare function resolveResourceId(ref: ResourceIdRef, ctx: AuthoritiesEvaluationContext): string | undefined;
23
+ /**
24
+ * Evaluate ReBAC policy (single or array).
25
+ * Multiple policies are AND-ed (all relationships must hold).
26
+ */
27
+ export declare function evaluateRebac(policy: RebacPolicy | RebacPolicy[], ctx: AuthoritiesEvaluationContext): Promise<AuthoritiesResult>;
28
+ //# sourceMappingURL=authorities.evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.evaluator.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.evaluator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,UAAU,EAEV,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,qBAAqB,CAAC;AAO7B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,4BAA4B,GAAG,iBAAiB,CA4B/G;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,4BAA4B,GAChC,iBAAiB,CA4BnB;AA6FD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,4BAA4B,GAAG,iBAAiB,CAqCrG;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,4BAA4B,GAAG,MAAM,GAAG,SAAS,CAc3G;AAuCD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,WAAW,GAAG,WAAW,EAAE,EACnC,GAAG,EAAE,4BAA4B,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAS5B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Global interface augmentation for authorities metadata.
3
+ *
4
+ * Adds the `authorities` field to all entry type metadata interfaces.
5
+ * Entry-level Zod schemas use `.passthrough()` so the field is accepted at runtime.
6
+ *
7
+ * Server/app-level configuration (claimsMapping, profiles) is passed via
8
+ * `AuthoritiesPlugin.init({ claimsMapping, profiles })`.
9
+ *
10
+ * Import this file (or anything from '@frontmcp/auth/authorities') to
11
+ * activate the augmentation.
12
+ */
13
+ import type { AuthoritiesMetadata } from './authorities.types';
14
+ declare global {
15
+ interface ExtendFrontMcpToolMetadata {
16
+ authorities?: AuthoritiesMetadata;
17
+ }
18
+ interface ExtendFrontMcpResourceMetadata {
19
+ authorities?: AuthoritiesMetadata;
20
+ }
21
+ interface ExtendFrontMcpResourceTemplateMetadata {
22
+ authorities?: AuthoritiesMetadata;
23
+ }
24
+ interface ExtendFrontMcpPromptMetadata {
25
+ authorities?: AuthoritiesMetadata;
26
+ }
27
+ interface ExtendFrontMcpSkillMetadata {
28
+ authorities?: AuthoritiesMetadata;
29
+ }
30
+ }
31
+ //# sourceMappingURL=authorities.metadata-augment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.metadata-augment.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.metadata-augment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,0BAA0B;QAClC,WAAW,CAAC,EAAE,mBAAmB,CAAC;KACnC;IAED,UAAU,8BAA8B;QACtC,WAAW,CAAC,EAAE,mBAAmB,CAAC;KACnC;IAED,UAAU,sCAAsC;QAC9C,WAAW,CAAC,EAAE,mBAAmB,CAAC;KACnC;IAED,UAAU,4BAA4B;QACpC,WAAW,CAAC,EAAE,mBAAmB,CAAC;KACnC;IAED,UAAU,2BAA2B;QACnC,WAAW,CAAC,EAAE,mBAAmB,CAAC;KACnC;CACF"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Authority Profiles Configuration
3
+ *
4
+ * Types for JWT claims mapping and pre-registered authority profiles.
5
+ * Configured at server/app level via @FrontMcp({ authorities: { ... } })
6
+ */
7
+ import type { AuthoritiesPolicyMetadata } from './authorities.types';
8
+ /**
9
+ * Maps IdP-specific JWT claim paths to standard authority fields.
10
+ * Each value is a dot-path into the JWT claims object.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Auth0
15
+ * { roles: 'https://myapp.com/roles', permissions: 'permissions', tenantId: 'org_id' }
16
+ *
17
+ * // Keycloak
18
+ * { roles: 'realm_access.roles', permissions: 'resource_access.account.roles' }
19
+ *
20
+ * // Okta
21
+ * { roles: 'groups', permissions: 'scp' }
22
+ *
23
+ * // Cognito
24
+ * { roles: 'cognito:groups', permissions: 'scope' }
25
+ *
26
+ * // Frontegg
27
+ * { roles: 'roles', permissions: 'permissions', tenantId: 'tenantId' }
28
+ * ```
29
+ */
30
+ export interface AuthoritiesClaimsMapping {
31
+ /** Dot-path to roles array in JWT claims */
32
+ roles?: string;
33
+ /** Dot-path to permissions array/string in JWT claims */
34
+ permissions?: string;
35
+ /** Dot-path to tenant/org ID in JWT claims */
36
+ tenantId?: string;
37
+ /** Dot-path to user ID in JWT claims (default: 'sub') */
38
+ userId?: string;
39
+ /** Extensible: additional custom claim mappings */
40
+ [key: string]: string | undefined;
41
+ }
42
+ /**
43
+ * Maps authority denials to OAuth scope challenges.
44
+ * When an authority check fails and the denial matches a scopeMapping key,
45
+ * the required scopes are included in the 403 insufficient_scope response.
46
+ * Explicit only — no automatic permission-to-scope inference.
47
+ */
48
+ export interface AuthoritiesScopeMapping {
49
+ /** Map role names to required OAuth scopes: `{ admin: ['admin:all'] }` */
50
+ roles?: Record<string, string[]>;
51
+ /** Map permission names to required OAuth scopes: `{ 'repo:write': ['repo'] }` */
52
+ permissions?: Record<string, string[]>;
53
+ /** Map profile names to required OAuth scopes: `{ admin: ['admin:all'] }` */
54
+ profiles?: Record<string, string[]>;
55
+ }
56
+ /**
57
+ * Server/app-level authorities configuration.
58
+ * Registered in `@FrontMcp({ authorities: { ... } })`.
59
+ */
60
+ export interface AuthoritiesConfig {
61
+ /** JWT claims mapping for your IdP */
62
+ claimsMapping?: AuthoritiesClaimsMapping;
63
+ /** Pre-registered named authority profiles */
64
+ profiles?: Record<string, AuthoritiesPolicyMetadata>;
65
+ /** Map authority denials to OAuth scope challenges */
66
+ scopeMapping?: AuthoritiesScopeMapping;
67
+ /**
68
+ * Auth context pipes — extract custom typed fields from JWT claims.
69
+ * Pipes run during context construction and their results are merged
70
+ * into the FrontMcpAuthContext. Declare custom fields via
71
+ * `declare global { interface ExtendFrontMcpAuthContext { ... } }`.
72
+ */
73
+ pipes?: import('../context/frontmcp-auth-context').AuthContextPipe[];
74
+ }
75
+ //# sourceMappingURL=authorities.profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.profiles.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.profiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAMrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACjC,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACrD,sDAAsD;IACtD,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,kCAAkC,EAAE,eAAe,EAAE,CAAC;CACtE"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Authority Registries
3
+ *
4
+ * - AuthoritiesProfileRegistry: stores named authority profiles
5
+ * - AuthoritiesEvaluatorRegistry: stores custom evaluators
6
+ */
7
+ import type { AuthoritiesPolicyMetadata, AuthoritiesEvaluator } from './authorities.types';
8
+ /**
9
+ * Registry for named authority profiles.
10
+ * Profiles map a string name to a policy, allowing
11
+ * `authorities: 'admin'` shorthand in decorators.
12
+ */
13
+ export declare class AuthoritiesProfileRegistry {
14
+ private readonly profiles;
15
+ /**
16
+ * Register a named profile.
17
+ * Overwrites any existing profile with the same name.
18
+ */
19
+ register(name: string, policy: AuthoritiesPolicyMetadata): void;
20
+ /**
21
+ * Register multiple profiles at once.
22
+ */
23
+ registerAll(profiles: Record<string, AuthoritiesPolicyMetadata>): void;
24
+ /**
25
+ * Resolve a profile name to its policy.
26
+ * Returns `undefined` if the profile is not registered.
27
+ */
28
+ resolve(name: string): AuthoritiesPolicyMetadata | undefined;
29
+ /**
30
+ * Check if a profile is registered.
31
+ */
32
+ has(name: string): boolean;
33
+ /**
34
+ * Get all registered profiles.
35
+ */
36
+ getAll(): Record<string, AuthoritiesPolicyMetadata>;
37
+ /**
38
+ * Get the number of registered profiles.
39
+ */
40
+ get size(): number;
41
+ /**
42
+ * Remove a profile by name.
43
+ */
44
+ remove(name: string): boolean;
45
+ /**
46
+ * Clear all profiles.
47
+ */
48
+ clear(): void;
49
+ }
50
+ /**
51
+ * Registry for custom authority evaluators.
52
+ * Custom evaluators handle the `custom.*` field in policies.
53
+ */
54
+ export declare class AuthoritiesEvaluatorRegistry {
55
+ private readonly evaluators;
56
+ /**
57
+ * Register a custom evaluator.
58
+ * The evaluator's name must match the key used in `custom.*`.
59
+ */
60
+ register(name: string, evaluator: AuthoritiesEvaluator): void;
61
+ /**
62
+ * Register multiple evaluators at once.
63
+ */
64
+ registerAll(evaluators: Record<string, AuthoritiesEvaluator>): void;
65
+ /**
66
+ * Get an evaluator by name.
67
+ */
68
+ get(name: string): AuthoritiesEvaluator | undefined;
69
+ /**
70
+ * Check if an evaluator is registered.
71
+ */
72
+ has(name: string): boolean;
73
+ /**
74
+ * Get the number of registered evaluators.
75
+ */
76
+ get size(): number;
77
+ /**
78
+ * Remove an evaluator by name.
79
+ */
80
+ remove(name: string): boolean;
81
+ /**
82
+ * Clear all evaluators.
83
+ */
84
+ clear(): void;
85
+ }
86
+ //# sourceMappingURL=authorities.registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.registry.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAM7B;;;;GAIG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgD;IAEzE;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,GAAG,IAAI;IAI/D;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,IAAI;IAMtE;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS;IAI5D;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC;IAQnD;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAMD;;;GAGG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA2C;IAEtE;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAI7D;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,IAAI;IAMnE;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAInD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Zod Validation Schemas for Authorities
3
+ *
4
+ * Runtime validation for authorities metadata, profiles, and claims mapping.
5
+ */
6
+ import { z } from '@frontmcp/lazy-zod';
7
+ import type { AuthoritiesClaimsMapping, AuthoritiesConfig } from './authorities.profiles';
8
+ import type { AbacCondition, AbacOperator, AbacPolicy, AuthoritiesMetadata, AuthoritiesPolicyMetadata, RbacPermissionsPolicy, RbacRolesPolicy, RebacPolicy, ResourceIdRef } from './authorities.types';
9
+ export declare const rbacRolesPolicySchema: z.ZodType<RbacRolesPolicy>;
10
+ export declare const rbacPermissionsPolicySchema: z.ZodType<RbacPermissionsPolicy>;
11
+ export declare const abacOperatorSchema: z.ZodType<AbacOperator>;
12
+ export declare const abacConditionSchema: z.ZodType<AbacCondition>;
13
+ export declare const abacPolicySchema: z.ZodType<AbacPolicy>;
14
+ export declare const resourceIdRefSchema: z.ZodType<ResourceIdRef>;
15
+ export declare const rebacPolicySchema: z.ZodType<RebacPolicy>;
16
+ export declare const authoritiesPolicySchema: z.ZodType<AuthoritiesPolicyMetadata>;
17
+ /**
18
+ * Validates the `authorities` field on any entry decorator.
19
+ * Accepts: string (profile), string[] (profiles), or policy object.
20
+ */
21
+ export declare const authoritiesMetadataSchema: z.ZodType<AuthoritiesMetadata>;
22
+ export declare const authoritiesClaimsMappingSchema: z.ZodType<AuthoritiesClaimsMapping>;
23
+ export declare const authoritiesConfigSchema: z.ZodType<AuthoritiesConfig>;
24
+ //# sourceMappingURL=authorities.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.schema.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAEvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,yBAAyB,EAEzB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,aAAa,EACd,MAAM,qBAAqB,CAAC;AAM7B,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAOzD,CAAC;AAEL,eAAO,MAAM,2BAA2B,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAOrE,CAAC;AAML,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAcrD,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAIvD,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAO/C,CAAC;AAML,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAIvD,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAInD,CAAC;AAgBH,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAOxE,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAInE,CAAC;AAMH,eAAO,MAAM,8BAA8B,EAAE,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAI3E,CAAC;AAML,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAG/D,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Scope Mapping Resolver
3
+ *
4
+ * Resolves required OAuth scopes from a structured authority denial
5
+ * using explicit scopeMapping configuration.
6
+ */
7
+ import type { AuthoritiesDenial, AuthoritiesMetadata } from './authorities.types';
8
+ import type { AuthoritiesScopeMapping } from './authorities.profiles';
9
+ /**
10
+ * Resolve required OAuth scopes from a structured denial and scopeMapping.
11
+ * Returns undefined if no mapping matches the denial.
12
+ *
13
+ * Uses explicit mapping only — no automatic permission-to-scope inference.
14
+ */
15
+ export declare function resolveRequiredScopes(denial: AuthoritiesDenial, mapping: AuthoritiesScopeMapping, authorities: AuthoritiesMetadata): string[] | undefined;
16
+ //# sourceMappingURL=authorities.scope-mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorities.scope-mapping.d.ts","sourceRoot":"","sources":["../../src/authorities/authorities.scope-mapping.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,uBAAuB,EAChC,WAAW,EAAE,mBAAmB,GAC/B,MAAM,EAAE,GAAG,SAAS,CAkCtB"}