@mondaydotcomorg/atp-server 0.24.0 → 0.24.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.
- package/dist/client-sessions.d.ts +0 -13
- package/dist/client-sessions.d.ts.map +1 -1
- package/dist/client-sessions.js +1 -57
- package/dist/client-sessions.js.map +1 -1
- package/dist/create-server.d.ts +0 -1
- package/dist/create-server.d.ts.map +1 -1
- package/dist/create-server.js +1 -7
- package/dist/create-server.js.map +1 -1
- package/dist/graphql-loader.d.ts +21 -0
- package/dist/graphql-loader.d.ts.map +1 -1
- package/dist/graphql-loader.js +6 -3
- package/dist/graphql-loader.js.map +1 -1
- package/dist/http/router.d.ts.map +1 -1
- package/dist/http/router.js +0 -3
- package/dist/http/router.js.map +1 -1
- package/dist/index.cjs +17 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -89
- package/dist/index.js.map +1 -1
- package/dist/openapi-loader.d.ts +28 -0
- package/dist/openapi-loader.d.ts.map +1 -1
- package/dist/openapi-loader.js +6 -4
- package/dist/openapi-loader.js.map +1 -1
- package/package.json +1 -1
- package/src/client-sessions.ts +1 -64
- package/src/create-server.ts +1 -7
- package/src/graphql-loader.ts +28 -3
- package/src/http/router.ts +0 -2
- package/src/openapi-loader.ts +38 -4
- package/dist/handlers/token.handler.d.ts +0 -18
- package/dist/handlers/token.handler.d.ts.map +0 -1
- package/dist/handlers/token.handler.js +0 -36
- package/dist/handlers/token.handler.js.map +0 -1
- package/src/handlers/token.handler.ts +0 -59
package/dist/index.js
CHANGED
|
@@ -6179,7 +6179,7 @@ function isSwagger2(spec) {
|
|
|
6179
6179
|
return "swagger" in spec;
|
|
6180
6180
|
}
|
|
6181
6181
|
async function loadOpenAPI(source, options = {}) {
|
|
6182
|
-
const spec = await loadSpec(source);
|
|
6182
|
+
const spec = await loadSpec(source, options.fetcher);
|
|
6183
6183
|
const name = options.name || spec.info.title.toLowerCase().replace(/\s+/g, "-");
|
|
6184
6184
|
let baseURL = options.baseURL;
|
|
6185
6185
|
if (!baseURL) {
|
|
@@ -6223,11 +6223,14 @@ async function loadOpenAPI(source, options = {}) {
|
|
|
6223
6223
|
auth
|
|
6224
6224
|
};
|
|
6225
6225
|
}
|
|
6226
|
-
async function loadSpec(source) {
|
|
6226
|
+
async function loadSpec(source, fetcher) {
|
|
6227
6227
|
let content;
|
|
6228
6228
|
let isYaml = false;
|
|
6229
6229
|
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
6230
|
-
const
|
|
6230
|
+
const fetchFn = fetcher || fetch;
|
|
6231
|
+
const response = await fetchFn(source, {
|
|
6232
|
+
method: "GET"
|
|
6233
|
+
});
|
|
6231
6234
|
if (!response.ok) {
|
|
6232
6235
|
throw new Error(`Failed to load OpenAPI spec from ${source}: ${response.statusText}`);
|
|
6233
6236
|
}
|
|
@@ -6459,7 +6462,8 @@ function convertOperation(path, method, operation, spec, baseURL, options, pathP
|
|
|
6459
6462
|
if (transformed.headers) finalHeaders = transformed.headers;
|
|
6460
6463
|
if (transformed.body !== void 0) finalBody = transformed.body;
|
|
6461
6464
|
}
|
|
6462
|
-
const
|
|
6465
|
+
const fetchFn = options.fetcher || fetch;
|
|
6466
|
+
const response = await fetchFn(finalUrl, {
|
|
6463
6467
|
method: finalMethod,
|
|
6464
6468
|
headers: finalHeaders,
|
|
6465
6469
|
body: finalBody
|
|
@@ -6792,12 +6796,11 @@ var ClientSessionManager = class {
|
|
|
6792
6796
|
this.jwtSecret = secret;
|
|
6793
6797
|
}
|
|
6794
6798
|
}
|
|
6795
|
-
ensureClientJWT(token, clientId
|
|
6799
|
+
ensureClientJWT(token, clientId) {
|
|
6796
6800
|
const decoded = jwt.verify(token, this.jwtSecret, {
|
|
6797
6801
|
algorithms: [
|
|
6798
6802
|
"HS256"
|
|
6799
|
-
]
|
|
6800
|
-
ignoreExpiration
|
|
6803
|
+
]
|
|
6801
6804
|
});
|
|
6802
6805
|
if (decoded.clientId !== clientId || decoded.type !== "client") {
|
|
6803
6806
|
return false;
|
|
@@ -6845,22 +6848,6 @@ var ClientSessionManager = class {
|
|
|
6845
6848
|
}
|
|
6846
6849
|
}
|
|
6847
6850
|
/**
|
|
6848
|
-
* Verify client token for refresh purposes - allows expired JWT tokens.
|
|
6849
|
-
* This is used during token refresh when the JWT may have expired but
|
|
6850
|
-
* the session still exists in cache.
|
|
6851
|
-
*/
|
|
6852
|
-
async verifyClientForRefresh(clientId, token) {
|
|
6853
|
-
try {
|
|
6854
|
-
if (!this.ensureClientJWT(token, clientId, true)) {
|
|
6855
|
-
return false;
|
|
6856
|
-
}
|
|
6857
|
-
const session = await this.cache.get(`session:${clientId}`);
|
|
6858
|
-
return session !== null;
|
|
6859
|
-
} catch {
|
|
6860
|
-
return false;
|
|
6861
|
-
}
|
|
6862
|
-
}
|
|
6863
|
-
/**
|
|
6864
6851
|
* Get client session
|
|
6865
6852
|
*/
|
|
6866
6853
|
async getSession(clientId) {
|
|
@@ -6900,36 +6887,6 @@ var ClientSessionManager = class {
|
|
|
6900
6887
|
});
|
|
6901
6888
|
}
|
|
6902
6889
|
/**
|
|
6903
|
-
* Refresh token for an existing client session.
|
|
6904
|
-
* Returns new token credentials if session exists in cache.
|
|
6905
|
-
* This works even if the session's expiresAt has passed - the refresh
|
|
6906
|
-
* will update expiresAt to extend the session.
|
|
6907
|
-
*/
|
|
6908
|
-
async refreshToken(clientId) {
|
|
6909
|
-
const session = await this.cache.get(`session:${clientId}`);
|
|
6910
|
-
if (!session) {
|
|
6911
|
-
return null;
|
|
6912
|
-
}
|
|
6913
|
-
await this.cache.delete(`session:${clientId}`);
|
|
6914
|
-
const newClientId = this.generateClientId();
|
|
6915
|
-
const now = Date.now();
|
|
6916
|
-
const newExpiresAt = now + this.tokenTTL;
|
|
6917
|
-
const newTokenRotateAt = now + this.tokenRotation;
|
|
6918
|
-
const updatedSession = {
|
|
6919
|
-
...session,
|
|
6920
|
-
clientId,
|
|
6921
|
-
expiresAt: newExpiresAt
|
|
6922
|
-
};
|
|
6923
|
-
await this.cache.set(`session:${newClientId}`, updatedSession);
|
|
6924
|
-
const newToken = this.generateToken(newClientId);
|
|
6925
|
-
return {
|
|
6926
|
-
clientId: newClientId,
|
|
6927
|
-
token: newToken,
|
|
6928
|
-
expiresAt: newExpiresAt,
|
|
6929
|
-
tokenRotateAt: newTokenRotateAt
|
|
6930
|
-
};
|
|
6931
|
-
}
|
|
6932
|
-
/**
|
|
6933
6890
|
* Get token TTL and rotation settings (useful for clients)
|
|
6934
6891
|
*/
|
|
6935
6892
|
getTokenSettings() {
|
|
@@ -11415,8 +11372,6 @@ async function handleRoute(ctx, server) {
|
|
|
11415
11372
|
} else if (ctx.path.startsWith("/api/resume/") && ctx.method === "POST") {
|
|
11416
11373
|
const executionId = ctx.path.substring("/api/resume/".length);
|
|
11417
11374
|
ctx.responseBody = await server.handleResume(ctx, executionId);
|
|
11418
|
-
} else if (ctx.path === "/api/token/refresh" && ctx.method === "POST") {
|
|
11419
|
-
ctx.responseBody = await server.handleTokenRefresh(ctx);
|
|
11420
11375
|
} else {
|
|
11421
11376
|
ctx.status = 404;
|
|
11422
11377
|
ctx.responseBody = {
|
|
@@ -12154,32 +12109,6 @@ async function handleResume(ctx, executionId, executor, stateManager, serverConf
|
|
|
12154
12109
|
return result;
|
|
12155
12110
|
}
|
|
12156
12111
|
__name(handleResume, "handleResume");
|
|
12157
|
-
async function handleTokenRefresh(ctx, sessionManager) {
|
|
12158
|
-
const clientId = ctx.clientId || ctx.body?.clientId;
|
|
12159
|
-
if (!clientId) {
|
|
12160
|
-
ctx.throw(400, "Client ID is required for token refresh");
|
|
12161
|
-
}
|
|
12162
|
-
const authHeader = ctx.headers["authorization"];
|
|
12163
|
-
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
12164
|
-
ctx.throw(401, "Bearer token required for refresh");
|
|
12165
|
-
}
|
|
12166
|
-
const currentToken = authHeader.substring(7);
|
|
12167
|
-
const isValid = await sessionManager.verifyClientForRefresh(clientId, currentToken);
|
|
12168
|
-
if (!isValid) {
|
|
12169
|
-
ctx.throw(401, "Invalid token or session expired");
|
|
12170
|
-
}
|
|
12171
|
-
const refreshResult = await sessionManager.refreshToken(clientId);
|
|
12172
|
-
if (!refreshResult) {
|
|
12173
|
-
ctx.throw(401, "Session not found or expired");
|
|
12174
|
-
}
|
|
12175
|
-
log.debug("Token refreshed", {
|
|
12176
|
-
clientId,
|
|
12177
|
-
newExpiresAt: refreshResult.expiresAt,
|
|
12178
|
-
newRotateAt: refreshResult.tokenRotateAt
|
|
12179
|
-
});
|
|
12180
|
-
return refreshResult;
|
|
12181
|
-
}
|
|
12182
|
-
__name(handleTokenRefresh, "handleTokenRefresh");
|
|
12183
12112
|
|
|
12184
12113
|
// src/handlers/definitions.handler.ts
|
|
12185
12114
|
async function getDefinitions(apiGroups) {
|
|
@@ -21467,8 +21396,9 @@ async function loadGraphQL(source, options = {}) {
|
|
|
21467
21396
|
__name(loadGraphQL, "loadGraphQL");
|
|
21468
21397
|
async function loadSchema(source, options) {
|
|
21469
21398
|
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
21399
|
+
const fetchFn = options.fetcher || fetch;
|
|
21470
21400
|
const headers = await resolveHeaders(options);
|
|
21471
|
-
const response = await
|
|
21401
|
+
const response = await fetchFn(source, {
|
|
21472
21402
|
method: "POST",
|
|
21473
21403
|
headers: {
|
|
21474
21404
|
"Content-Type": "application/json",
|
|
@@ -21479,7 +21409,8 @@ async function loadSchema(source, options) {
|
|
|
21479
21409
|
})
|
|
21480
21410
|
});
|
|
21481
21411
|
if (!response.ok) {
|
|
21482
|
-
const getResponse = await
|
|
21412
|
+
const getResponse = await fetchFn(source, {
|
|
21413
|
+
method: "GET",
|
|
21483
21414
|
headers
|
|
21484
21415
|
});
|
|
21485
21416
|
if (getResponse.ok) {
|
|
@@ -21550,7 +21481,8 @@ function convertFieldToFunction(type, fieldName, field, url, options) {
|
|
|
21550
21481
|
context.metadata.graphql_variables = variables;
|
|
21551
21482
|
}
|
|
21552
21483
|
const headers = await resolveHeaders(options, paramsObj, context);
|
|
21553
|
-
const
|
|
21484
|
+
const fetchFn = options.fetcher || fetch;
|
|
21485
|
+
const response = await fetchFn(url, {
|
|
21554
21486
|
method: "POST",
|
|
21555
21487
|
headers: {
|
|
21556
21488
|
"Content-Type": "application/json",
|
|
@@ -21868,7 +21800,7 @@ var AgentToolProtocolServer = class {
|
|
|
21868
21800
|
if (!this.cacheProvider) {
|
|
21869
21801
|
this.cacheProvider = new MemoryCache({
|
|
21870
21802
|
maxKeys: 1e3,
|
|
21871
|
-
defaultTTL: 3600
|
|
21803
|
+
defaultTTL: 24 * 3600
|
|
21872
21804
|
});
|
|
21873
21805
|
log.info("Cache provider configured (default)", {
|
|
21874
21806
|
provider: "memory"
|
|
@@ -22241,10 +22173,6 @@ var AgentToolProtocolServer = class {
|
|
|
22241
22173
|
}
|
|
22242
22174
|
return await handleResume(ctx, executionId, this.executor, this.stateManager, this.config, this.sessionManager);
|
|
22243
22175
|
}
|
|
22244
|
-
async handleTokenRefresh(ctx) {
|
|
22245
|
-
if (!this.sessionManager) ctx.throw(503, "Session manager not initialized");
|
|
22246
|
-
return await handleTokenRefresh(ctx, this.sessionManager);
|
|
22247
|
-
}
|
|
22248
22176
|
/**
|
|
22249
22177
|
* Update server components with new API groups (internal method)
|
|
22250
22178
|
* @private
|