@mondaydotcomorg/atp-server 0.24.0 → 0.24.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/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 +27 -5
- package/dist/graphql-loader.d.ts.map +1 -1
- package/dist/graphql-loader.js +14 -11
- 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 +29 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -98
- package/dist/index.js.map +1 -1
- package/dist/openapi-loader.d.ts +32 -7
- package/dist/openapi-loader.d.ts.map +1 -1
- package/dist/openapi-loader.js +11 -9
- package/dist/openapi-loader.js.map +1 -1
- package/package.json +6 -6
- package/src/client-sessions.ts +1 -64
- package/src/create-server.ts +1 -7
- package/src/graphql-loader.ts +43 -17
- package/src/http/router.ts +0 -2
- package/src/openapi-loader.ts +47 -17
- 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
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { RequestContext } from '../core/config.js';
|
|
2
|
-
import type { ClientSessionManager } from '../client-sessions.js';
|
|
3
|
-
export interface TokenRefreshRequest {
|
|
4
|
-
clientId: string;
|
|
5
|
-
}
|
|
6
|
-
export interface TokenRefreshResponse {
|
|
7
|
-
clientId: string;
|
|
8
|
-
token: string;
|
|
9
|
-
expiresAt: number;
|
|
10
|
-
tokenRotateAt: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Handle token refresh requests.
|
|
14
|
-
* Allows clients to refresh their token, even if the JWT has expired.
|
|
15
|
-
* The session must still exist in the cache for refresh to succeed.
|
|
16
|
-
*/
|
|
17
|
-
export declare function handleTokenRefresh(ctx: RequestContext, sessionManager: ClientSessionManager): Promise<TokenRefreshResponse>;
|
|
18
|
-
//# sourceMappingURL=token.handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.handler.d.ts","sourceRoot":"","sources":["../../src/handlers/token.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,oBAAoB,GAClC,OAAO,CAAC,oBAAoB,CAAC,CAmC/B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { log } from '@mondaydotcomorg/atp-runtime';
|
|
2
|
-
/**
|
|
3
|
-
* Handle token refresh requests.
|
|
4
|
-
* Allows clients to refresh their token, even if the JWT has expired.
|
|
5
|
-
* The session must still exist in the cache for refresh to succeed.
|
|
6
|
-
*/
|
|
7
|
-
export async function handleTokenRefresh(ctx, sessionManager) {
|
|
8
|
-
// Get clientId from header or body
|
|
9
|
-
const clientId = ctx.clientId || ctx.body?.clientId;
|
|
10
|
-
if (!clientId) {
|
|
11
|
-
ctx.throw(400, 'Client ID is required for token refresh');
|
|
12
|
-
}
|
|
13
|
-
// Verify the current token (from Authorization header)
|
|
14
|
-
const authHeader = ctx.headers['authorization'];
|
|
15
|
-
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
16
|
-
ctx.throw(401, 'Bearer token required for refresh');
|
|
17
|
-
}
|
|
18
|
-
const currentToken = authHeader.substring(7);
|
|
19
|
-
// Verify the token belongs to this client - allows expired JWT tokens
|
|
20
|
-
const isValid = await sessionManager.verifyClientForRefresh(clientId, currentToken);
|
|
21
|
-
if (!isValid) {
|
|
22
|
-
ctx.throw(401, 'Invalid token or session expired');
|
|
23
|
-
}
|
|
24
|
-
// Refresh the token
|
|
25
|
-
const refreshResult = await sessionManager.refreshToken(clientId);
|
|
26
|
-
if (!refreshResult) {
|
|
27
|
-
ctx.throw(401, 'Session not found or expired');
|
|
28
|
-
}
|
|
29
|
-
log.debug('Token refreshed', {
|
|
30
|
-
clientId,
|
|
31
|
-
newExpiresAt: refreshResult.expiresAt,
|
|
32
|
-
newRotateAt: refreshResult.tokenRotateAt,
|
|
33
|
-
});
|
|
34
|
-
return refreshResult;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=token.handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.handler.js","sourceRoot":"","sources":["../../src/handlers/token.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AAanD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,GAAmB,EACnB,cAAoC;IAEpC,mCAAmC;IACnC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAK,GAAG,CAAC,IAA4B,EAAE,QAAQ,CAAC;IAE7E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,yCAAyC,CAAC,CAAC;IAC3D,CAAC;IAED,uDAAuD;IACvD,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAChD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,mCAAmC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE7C,sEAAsE;IACtE,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,sBAAsB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACpF,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,kCAAkC,CAAC,CAAC;IACpD,CAAC;IAED,oBAAoB;IACpB,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClE,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,8BAA8B,CAAC,CAAC;IAChD,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE;QAC5B,QAAQ;QACR,YAAY,EAAE,aAAa,CAAC,SAAS;QACrC,WAAW,EAAE,aAAa,CAAC,aAAa;KACxC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC;AACtB,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { RequestContext } from '../core/config.js';
|
|
2
|
-
import type { ClientSessionManager } from '../client-sessions.js';
|
|
3
|
-
import { log } from '@mondaydotcomorg/atp-runtime';
|
|
4
|
-
|
|
5
|
-
export interface TokenRefreshRequest {
|
|
6
|
-
clientId: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface TokenRefreshResponse {
|
|
10
|
-
clientId: string;
|
|
11
|
-
token: string;
|
|
12
|
-
expiresAt: number;
|
|
13
|
-
tokenRotateAt: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Handle token refresh requests.
|
|
18
|
-
* Allows clients to refresh their token, even if the JWT has expired.
|
|
19
|
-
* The session must still exist in the cache for refresh to succeed.
|
|
20
|
-
*/
|
|
21
|
-
export async function handleTokenRefresh(
|
|
22
|
-
ctx: RequestContext,
|
|
23
|
-
sessionManager: ClientSessionManager
|
|
24
|
-
): Promise<TokenRefreshResponse> {
|
|
25
|
-
// Get clientId from header or body
|
|
26
|
-
const clientId = ctx.clientId || (ctx.body as TokenRefreshRequest)?.clientId;
|
|
27
|
-
|
|
28
|
-
if (!clientId) {
|
|
29
|
-
ctx.throw(400, 'Client ID is required for token refresh');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Verify the current token (from Authorization header)
|
|
33
|
-
const authHeader = ctx.headers['authorization'];
|
|
34
|
-
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
|
35
|
-
ctx.throw(401, 'Bearer token required for refresh');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const currentToken = authHeader.substring(7);
|
|
39
|
-
|
|
40
|
-
// Verify the token belongs to this client - allows expired JWT tokens
|
|
41
|
-
const isValid = await sessionManager.verifyClientForRefresh(clientId, currentToken);
|
|
42
|
-
if (!isValid) {
|
|
43
|
-
ctx.throw(401, 'Invalid token or session expired');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Refresh the token
|
|
47
|
-
const refreshResult = await sessionManager.refreshToken(clientId);
|
|
48
|
-
if (!refreshResult) {
|
|
49
|
-
ctx.throw(401, 'Session not found or expired');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
log.debug('Token refreshed', {
|
|
53
|
-
clientId,
|
|
54
|
-
newExpiresAt: refreshResult.expiresAt,
|
|
55
|
-
newRotateAt: refreshResult.tokenRotateAt,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return refreshResult;
|
|
59
|
-
}
|