@kya-os/agentshield-nextjs 0.1.47 → 0.2.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-client.d.mts +8 -0
- package/dist/api-client.d.ts +8 -0
- package/dist/api-client.js +8 -2
- package/dist/api-client.js.map +1 -1
- package/dist/api-client.mjs +8 -2
- package/dist/api-client.mjs.map +1 -1
- package/dist/api-middleware.d.mts +8 -0
- package/dist/api-middleware.d.ts +8 -0
- package/dist/api-middleware.js +9 -2
- package/dist/api-middleware.js.map +1 -1
- package/dist/api-middleware.mjs +9 -2
- package/dist/api-middleware.mjs.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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.
|
|
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
|
|
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,8 @@ function getAgentShieldClient(config) {
|
|
|
2101
2105
|
clientInstance = new AgentShieldClient({
|
|
2102
2106
|
apiKey,
|
|
2103
2107
|
baseUrl: config?.baseUrl || process.env.AGENTSHIELD_API_URL,
|
|
2108
|
+
// Default to edge detection unless explicitly disabled
|
|
2109
|
+
useEdge: config?.useEdge ?? process.env.AGENTSHIELD_USE_EDGE !== "false",
|
|
2104
2110
|
timeout: config?.timeout,
|
|
2105
2111
|
debug: config?.debug || process.env.AGENTSHIELD_DEBUG === "true"
|
|
2106
2112
|
});
|
|
@@ -2167,6 +2173,7 @@ function withAgentShield(config = {}) {
|
|
|
2167
2173
|
client = getAgentShieldClient({
|
|
2168
2174
|
apiKey: config.apiKey,
|
|
2169
2175
|
baseUrl: config.apiUrl,
|
|
2176
|
+
useEdge: config.useEdge,
|
|
2170
2177
|
timeout: config.timeout,
|
|
2171
2178
|
debug: config.debug
|
|
2172
2179
|
});
|