@agentix-security/express 0.1.1 → 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 +8 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +8 -1
- package/package.json +1 -1
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.
|
|
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;
|
|
@@ -384,6 +390,7 @@ function agentixMiddleware(sdk) {
|
|
|
384
390
|
function secure(sdk, intent, handler, opts = {}) {
|
|
385
391
|
const mode = opts.mode ?? "enforce";
|
|
386
392
|
sdk.registerIntent(intent, mode);
|
|
393
|
+
if (opts.path) sdk.registerIntentRoute(intent, opts.path);
|
|
387
394
|
return async (req, res, next) => {
|
|
388
395
|
await sdk.ensureInitialized();
|
|
389
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,
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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.
|
|
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;
|
|
@@ -382,6 +388,7 @@ function agentixMiddleware(sdk) {
|
|
|
382
388
|
function secure(sdk, intent, handler, opts = {}) {
|
|
383
389
|
const mode = opts.mode ?? "enforce";
|
|
384
390
|
sdk.registerIntent(intent, mode);
|
|
391
|
+
if (opts.path) sdk.registerIntentRoute(intent, opts.path);
|
|
385
392
|
return async (req, res, next) => {
|
|
386
393
|
await sdk.ensureInitialized();
|
|
387
394
|
const token = bearerToken(req);
|