@kya-os/agentshield-nextjs 0.1.46 → 0.1.48

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.mjs CHANGED
@@ -1990,10 +1990,12 @@ function createEnhancedAgentShieldMiddleware(config = {}) {
1990
1990
 
1991
1991
  // src/api-client.ts
1992
1992
  var DEFAULT_BASE_URL = "https://kya.vouched.id";
1993
+ var EDGE_DETECT_URL = "https://detect.kya-os.ai";
1993
1994
  var DEFAULT_TIMEOUT = 5e3;
1994
1995
  var AgentShieldClient = class {
1995
1996
  apiKey;
1996
1997
  baseUrl;
1998
+ useEdge;
1997
1999
  timeout;
1998
2000
  debug;
1999
2001
  constructor(config) {
@@ -2001,7 +2003,8 @@ var AgentShieldClient = class {
2001
2003
  throw new Error("AgentShield API key is required");
2002
2004
  }
2003
2005
  this.apiKey = config.apiKey;
2004
- this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
2006
+ this.useEdge = config.useEdge || false;
2007
+ this.baseUrl = config.baseUrl || (this.useEdge ? EDGE_DETECT_URL : DEFAULT_BASE_URL);
2005
2008
  this.timeout = config.timeout || DEFAULT_TIMEOUT;
2006
2009
  this.debug = config.debug || false;
2007
2010
  }
@@ -2014,7 +2017,8 @@ var AgentShieldClient = class {
2014
2017
  const controller = new AbortController();
2015
2018
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2016
2019
  try {
2017
- const response = await fetch(`${this.baseUrl}/api/v1/enforce`, {
2020
+ const endpoint = this.useEdge ? `${this.baseUrl}/__detect/enforce` : `${this.baseUrl}/api/v1/enforce`;
2021
+ const response = await fetch(endpoint, {
2018
2022
  method: "POST",
2019
2023
  headers: {
2020
2024
  "Content-Type": "application/json",
@@ -2101,6 +2105,7 @@ function getAgentShieldClient(config) {
2101
2105
  clientInstance = new AgentShieldClient({
2102
2106
  apiKey,
2103
2107
  baseUrl: config?.baseUrl || process.env.AGENTSHIELD_API_URL,
2108
+ useEdge: config?.useEdge || process.env.AGENTSHIELD_USE_EDGE === "true",
2104
2109
  timeout: config?.timeout,
2105
2110
  debug: config?.debug || process.env.AGENTSHIELD_DEBUG === "true"
2106
2111
  });
@@ -2167,6 +2172,7 @@ function withAgentShield(config = {}) {
2167
2172
  client = getAgentShieldClient({
2168
2173
  apiKey: config.apiKey,
2169
2174
  baseUrl: config.apiUrl,
2175
+ useEdge: config.useEdge,
2170
2176
  timeout: config.timeout,
2171
2177
  debug: config.debug
2172
2178
  });
@@ -2224,6 +2230,7 @@ function withAgentShield(config = {}) {
2224
2230
  isAgent: decision.isAgent,
2225
2231
  confidence: decision.confidence,
2226
2232
  agentName: decision.agentName,
2233
+ detectionMethod: result.data.detection?.detectionMethod || "not-included",
2227
2234
  processingTimeMs: Date.now() - startTime
2228
2235
  });
2229
2236
  }