@agentix-security/express 0.1.0 → 0.1.2

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/index.cjs CHANGED
@@ -301,7 +301,13 @@ var AgentixSDK = class {
301
301
  return this.engine;
302
302
  }
303
303
  registerIntent(intent, mode = "enforce") {
304
- this.intentRegistry.set(intent, mode);
304
+ if (!this.intentRegistry.has(intent)) {
305
+ this.intentRegistry.set(intent, { mode, routes: /* @__PURE__ */ new Set() });
306
+ }
307
+ }
308
+ registerIntentRoute(intent, route) {
309
+ const entry = this.intentRegistry.get(intent);
310
+ if (entry) entry.routes.add(route);
305
311
  }
306
312
  getIntentRegistry() {
307
313
  return this.intentRegistry;
@@ -372,6 +378,8 @@ function agentixMiddleware(sdk) {
372
378
  await sdk.ensureInitialized();
373
379
  const result = await sdk.getEngine().handle(normalize(req));
374
380
  if (result.type === "passthrough") {
381
+ const baseUrl = `${req.get("x-forwarded-proto") ?? req.protocol ?? "http"}://${req.get("host") ?? req.hostname ?? "localhost"}`;
382
+ res.setHeader("link", `<${baseUrl}/.well-known/ai-agent.json>; rel="agent-discovery"`);
375
383
  next();
376
384
  return;
377
385
  }
@@ -382,6 +390,7 @@ function agentixMiddleware(sdk) {
382
390
  function secure(sdk, intent, handler, opts = {}) {
383
391
  const mode = opts.mode ?? "enforce";
384
392
  sdk.registerIntent(intent, mode);
393
+ if (opts.path) sdk.registerIntentRoute(intent, opts.path);
385
394
  return async (req, res, next) => {
386
395
  await sdk.ensureInitialized();
387
396
  const token = bearerToken(req);
package/dist/index.d.cts CHANGED
@@ -41,7 +41,10 @@ interface EngineOptions {
41
41
  controlPlaneUrl: string;
42
42
  controlPlaneAdminKey?: string;
43
43
  getLease: () => LicenseLease | null;
44
- getRegisteredIntents?: () => ReadonlyMap<string, 'enforce' | 'shadow'>;
44
+ getRegisteredIntents?: () => ReadonlyMap<string, {
45
+ mode: 'enforce' | 'shadow';
46
+ routes: Set<string>;
47
+ }>;
45
48
  devMode?: boolean;
46
49
  }
47
50
  declare class Engine {
@@ -86,7 +89,11 @@ declare class AgentixSDK {
86
89
  private _init;
87
90
  getEngine(): Engine;
88
91
  registerIntent(intent: string, mode?: 'enforce' | 'shadow'): void;
89
- getIntentRegistry(): ReadonlyMap<string, 'enforce' | 'shadow'>;
92
+ registerIntentRoute(intent: string, route: string): void;
93
+ getIntentRegistry(): ReadonlyMap<string, {
94
+ mode: 'enforce' | 'shadow';
95
+ routes: Set<string>;
96
+ }>;
90
97
  getResolvedDomain(): string;
91
98
  getResolvedTenantId(): string;
92
99
  getResolvedTokenSecret(): string;
@@ -107,6 +114,7 @@ declare function agentixMiddleware(sdk: AgentixSDK): RequestHandler;
107
114
  */
108
115
  declare function secure(sdk: AgentixSDK, intent: string, handler: RequestHandler, opts?: {
109
116
  mode?: 'enforce' | 'shadow';
117
+ path?: string;
110
118
  }): RequestHandler;
111
119
 
112
120
  export { AgentixSDK, type AgentixSDKConfig, agentixMiddleware, secure };
package/dist/index.d.ts CHANGED
@@ -41,7 +41,10 @@ interface EngineOptions {
41
41
  controlPlaneUrl: string;
42
42
  controlPlaneAdminKey?: string;
43
43
  getLease: () => LicenseLease | null;
44
- getRegisteredIntents?: () => ReadonlyMap<string, 'enforce' | 'shadow'>;
44
+ getRegisteredIntents?: () => ReadonlyMap<string, {
45
+ mode: 'enforce' | 'shadow';
46
+ routes: Set<string>;
47
+ }>;
45
48
  devMode?: boolean;
46
49
  }
47
50
  declare class Engine {
@@ -86,7 +89,11 @@ declare class AgentixSDK {
86
89
  private _init;
87
90
  getEngine(): Engine;
88
91
  registerIntent(intent: string, mode?: 'enforce' | 'shadow'): void;
89
- getIntentRegistry(): ReadonlyMap<string, 'enforce' | 'shadow'>;
92
+ registerIntentRoute(intent: string, route: string): void;
93
+ getIntentRegistry(): ReadonlyMap<string, {
94
+ mode: 'enforce' | 'shadow';
95
+ routes: Set<string>;
96
+ }>;
90
97
  getResolvedDomain(): string;
91
98
  getResolvedTenantId(): string;
92
99
  getResolvedTokenSecret(): string;
@@ -107,6 +114,7 @@ declare function agentixMiddleware(sdk: AgentixSDK): RequestHandler;
107
114
  */
108
115
  declare function secure(sdk: AgentixSDK, intent: string, handler: RequestHandler, opts?: {
109
116
  mode?: 'enforce' | 'shadow';
117
+ path?: string;
110
118
  }): RequestHandler;
111
119
 
112
120
  export { AgentixSDK, type AgentixSDKConfig, agentixMiddleware, secure };
package/dist/index.js CHANGED
@@ -299,7 +299,13 @@ var AgentixSDK = class {
299
299
  return this.engine;
300
300
  }
301
301
  registerIntent(intent, mode = "enforce") {
302
- this.intentRegistry.set(intent, mode);
302
+ if (!this.intentRegistry.has(intent)) {
303
+ this.intentRegistry.set(intent, { mode, routes: /* @__PURE__ */ new Set() });
304
+ }
305
+ }
306
+ registerIntentRoute(intent, route) {
307
+ const entry = this.intentRegistry.get(intent);
308
+ if (entry) entry.routes.add(route);
303
309
  }
304
310
  getIntentRegistry() {
305
311
  return this.intentRegistry;
@@ -370,6 +376,8 @@ function agentixMiddleware(sdk) {
370
376
  await sdk.ensureInitialized();
371
377
  const result = await sdk.getEngine().handle(normalize(req));
372
378
  if (result.type === "passthrough") {
379
+ const baseUrl = `${req.get("x-forwarded-proto") ?? req.protocol ?? "http"}://${req.get("host") ?? req.hostname ?? "localhost"}`;
380
+ res.setHeader("link", `<${baseUrl}/.well-known/ai-agent.json>; rel="agent-discovery"`);
373
381
  next();
374
382
  return;
375
383
  }
@@ -380,6 +388,7 @@ function agentixMiddleware(sdk) {
380
388
  function secure(sdk, intent, handler, opts = {}) {
381
389
  const mode = opts.mode ?? "enforce";
382
390
  sdk.registerIntent(intent, mode);
391
+ if (opts.path) sdk.registerIntentRoute(intent, opts.path);
383
392
  return async (req, res, next) => {
384
393
  await sdk.ensureInitialized();
385
394
  const token = bearerToken(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentix-security/express",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Agentix Express adapter — AI agent intent-based authorization for Express apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",