@1mcp/agent 0.11.0 → 0.13.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.
Files changed (200) hide show
  1. package/README.md +45 -50
  2. package/build/auth/clientSessionManager.d.ts +94 -0
  3. package/build/auth/clientSessionManager.d.ts.map +1 -0
  4. package/build/auth/clientSessionManager.js +220 -0
  5. package/build/auth/clientSessionManager.js.map +1 -0
  6. package/build/auth/sdkOAuthClientProvider.d.ts +93 -0
  7. package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -0
  8. package/build/auth/sdkOAuthClientProvider.js +199 -0
  9. package/build/auth/sdkOAuthClientProvider.js.map +1 -0
  10. package/build/auth/sdkOAuthServerProvider.d.ts +63 -0
  11. package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -0
  12. package/build/auth/sdkOAuthServerProvider.js +428 -0
  13. package/build/auth/sdkOAuthServerProvider.js.map +1 -0
  14. package/build/{server/auth/sessionManager.d.ts → auth/serverSessionManager.d.ts} +26 -37
  15. package/build/auth/serverSessionManager.d.ts.map +1 -0
  16. package/build/{server/auth/sessionManager.js → auth/serverSessionManager.js} +104 -19
  17. package/build/auth/serverSessionManager.js.map +1 -0
  18. package/build/auth/sessionTypes.d.ts +24 -0
  19. package/build/auth/sessionTypes.d.ts.map +1 -0
  20. package/build/auth/sessionTypes.js +3 -0
  21. package/build/auth/sessionTypes.js.map +1 -0
  22. package/build/capabilities/capabilityManager.d.ts +2 -2
  23. package/build/capabilities/capabilityManager.d.ts.map +1 -1
  24. package/build/capabilities/capabilityManager.js +40 -7
  25. package/build/capabilities/capabilityManager.js.map +1 -1
  26. package/build/config/{configManager.d.ts → mcpConfigManager.d.ts} +18 -7
  27. package/build/config/mcpConfigManager.d.ts.map +1 -0
  28. package/build/config/{configManager.js → mcpConfigManager.js} +50 -10
  29. package/build/config/mcpConfigManager.js.map +1 -0
  30. package/build/constants.d.ts +36 -14
  31. package/build/constants.d.ts.map +1 -1
  32. package/build/constants.js +40 -17
  33. package/build/constants.js.map +1 -1
  34. package/build/{client.d.ts → core/client/clientFactory.d.ts} +1 -1
  35. package/build/core/client/clientFactory.d.ts.map +1 -0
  36. package/build/{client.js → core/client/clientFactory.js} +2 -2
  37. package/build/core/client/clientFactory.js.map +1 -0
  38. package/build/{clients → core/client}/clientManager.d.ts +14 -6
  39. package/build/core/client/clientManager.d.ts.map +1 -0
  40. package/build/core/client/clientManager.js +209 -0
  41. package/build/core/client/clientManager.js.map +1 -0
  42. package/build/{server/config/serverConfig.d.ts → core/server/agentConfig.d.ts} +50 -15
  43. package/build/core/server/agentConfig.d.ts.map +1 -0
  44. package/build/core/server/agentConfig.js +166 -0
  45. package/build/core/server/agentConfig.js.map +1 -0
  46. package/build/core/server/serverManager.d.ts +39 -0
  47. package/build/core/server/serverManager.d.ts.map +1 -0
  48. package/build/core/server/serverManager.js +169 -0
  49. package/build/core/server/serverManager.js.map +1 -0
  50. package/build/core/types/client.d.ts +51 -0
  51. package/build/core/types/client.d.ts.map +1 -0
  52. package/build/core/types/client.js +15 -0
  53. package/build/core/types/client.js.map +1 -0
  54. package/build/core/types/index.d.ts +4 -0
  55. package/build/core/types/index.d.ts.map +1 -0
  56. package/build/core/types/index.js +5 -0
  57. package/build/core/types/index.js.map +1 -0
  58. package/build/core/types/server.d.ts +14 -0
  59. package/build/core/types/server.d.ts.map +1 -0
  60. package/build/core/types/server.js +2 -0
  61. package/build/core/types/server.js.map +1 -0
  62. package/build/{types.d.ts → core/types/transport.d.ts} +59 -49
  63. package/build/core/types/transport.d.ts.map +1 -0
  64. package/build/{types.js → core/types/transport.js} +11 -13
  65. package/build/core/types/transport.js.map +1 -0
  66. package/build/handlers/notificationHandlers.d.ts +3 -3
  67. package/build/handlers/notificationHandlers.d.ts.map +1 -1
  68. package/build/handlers/notificationHandlers.js +13 -9
  69. package/build/handlers/notificationHandlers.js.map +1 -1
  70. package/build/handlers/requestHandlers.d.ts +2 -2
  71. package/build/handlers/requestHandlers.d.ts.map +1 -1
  72. package/build/handlers/requestHandlers.js +25 -3
  73. package/build/handlers/requestHandlers.js.map +1 -1
  74. package/build/index.js +48 -8
  75. package/build/index.js.map +1 -1
  76. package/build/logger/logger.js +1 -1
  77. package/build/logger/logger.js.map +1 -1
  78. package/build/{middleware/loggingMiddleware.d.ts → logger/mcpLoggingEnhancer.d.ts} +1 -1
  79. package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -0
  80. package/build/{middleware/loggingMiddleware.js → logger/mcpLoggingEnhancer.js} +2 -2
  81. package/build/logger/mcpLoggingEnhancer.js.map +1 -0
  82. package/build/server.d.ts +1 -1
  83. package/build/server.d.ts.map +1 -1
  84. package/build/server.js +9 -6
  85. package/build/server.js.map +1 -1
  86. package/build/services/configReloadService.d.ts +15 -5
  87. package/build/services/configReloadService.d.ts.map +1 -1
  88. package/build/services/configReloadService.js +31 -14
  89. package/build/services/configReloadService.js.map +1 -1
  90. package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -0
  91. package/build/{server → transport/http/middlewares}/errorHandler.js +1 -1
  92. package/build/transport/http/middlewares/errorHandler.js.map +1 -0
  93. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +42 -0
  94. package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -0
  95. package/build/transport/http/middlewares/scopeAuthMiddleware.js +136 -0
  96. package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -0
  97. package/build/transport/http/middlewares/securityMiddleware.d.ts +30 -0
  98. package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -0
  99. package/build/transport/http/middlewares/securityMiddleware.js +201 -0
  100. package/build/transport/http/middlewares/securityMiddleware.js.map +1 -0
  101. package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -0
  102. package/build/transport/http/middlewares/tagsExtractor.js.map +1 -0
  103. package/build/transport/http/routes/oauthRoutes.d.ts +4 -0
  104. package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -0
  105. package/build/transport/http/routes/oauthRoutes.js +474 -0
  106. package/build/transport/http/routes/oauthRoutes.js.map +1 -0
  107. package/build/transport/http/routes/sseRoutes.d.ts +4 -0
  108. package/build/transport/http/routes/sseRoutes.d.ts.map +1 -0
  109. package/build/{server → transport/http}/routes/sseRoutes.js +12 -10
  110. package/build/transport/http/routes/sseRoutes.js.map +1 -0
  111. package/build/transport/http/routes/streamableHttpRoutes.d.ts +4 -0
  112. package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -0
  113. package/build/{server → transport/http}/routes/streamableHttpRoutes.js +46 -13
  114. package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -0
  115. package/build/{server/expressServer.d.ts → transport/http/server.d.ts} +5 -4
  116. package/build/transport/http/server.d.ts.map +1 -0
  117. package/build/{server/expressServer.js → transport/http/server.js} +60 -23
  118. package/build/transport/http/server.js.map +1 -0
  119. package/build/transport/transportFactory.d.ts +9 -0
  120. package/build/transport/transportFactory.d.ts.map +1 -0
  121. package/build/transport/transportFactory.js +148 -0
  122. package/build/transport/transportFactory.js.map +1 -0
  123. package/build/utils/clientFiltering.d.ts +4 -4
  124. package/build/utils/clientFiltering.d.ts.map +1 -1
  125. package/build/utils/clientFiltering.js +14 -14
  126. package/build/utils/clientFiltering.js.map +1 -1
  127. package/build/utils/errorHandling.d.ts +0 -11
  128. package/build/utils/errorHandling.d.ts.map +1 -1
  129. package/build/utils/errorHandling.js +1 -18
  130. package/build/utils/errorHandling.js.map +1 -1
  131. package/build/utils/errorTypes.js +4 -4
  132. package/build/utils/errorTypes.js.map +1 -1
  133. package/build/utils/pagination.d.ts +2 -2
  134. package/build/utils/pagination.d.ts.map +1 -1
  135. package/build/utils/pagination.js +87 -8
  136. package/build/utils/pagination.js.map +1 -1
  137. package/build/utils/parsing.d.ts +13 -0
  138. package/build/utils/parsing.d.ts.map +1 -0
  139. package/build/utils/parsing.js +32 -0
  140. package/build/utils/parsing.js.map +1 -0
  141. package/build/utils/sanitization.d.ts +60 -0
  142. package/build/utils/sanitization.d.ts.map +1 -0
  143. package/build/utils/sanitization.js +149 -0
  144. package/build/utils/sanitization.js.map +1 -0
  145. package/build/utils/scopeValidation.d.ts +102 -0
  146. package/build/utils/scopeValidation.d.ts.map +1 -0
  147. package/build/utils/scopeValidation.js +244 -0
  148. package/build/utils/scopeValidation.js.map +1 -0
  149. package/package.json +23 -9
  150. package/build/client.d.ts.map +0 -1
  151. package/build/client.js.map +0 -1
  152. package/build/clients/clientManager.d.ts.map +0 -1
  153. package/build/clients/clientManager.js +0 -147
  154. package/build/clients/clientManager.js.map +0 -1
  155. package/build/config/configManager.d.ts.map +0 -1
  156. package/build/config/configManager.js.map +0 -1
  157. package/build/config/transportConfig.d.ts +0 -7
  158. package/build/config/transportConfig.d.ts.map +0 -1
  159. package/build/config/transportConfig.js +0 -90
  160. package/build/config/transportConfig.js.map +0 -1
  161. package/build/middleware/loggingMiddleware.d.ts.map +0 -1
  162. package/build/middleware/loggingMiddleware.js.map +0 -1
  163. package/build/server/auth/authManager.d.ts +0 -109
  164. package/build/server/auth/authManager.d.ts.map +0 -1
  165. package/build/server/auth/authManager.js +0 -173
  166. package/build/server/auth/authManager.js.map +0 -1
  167. package/build/server/auth/authMiddleware.d.ts +0 -16
  168. package/build/server/auth/authMiddleware.d.ts.map +0 -1
  169. package/build/server/auth/authMiddleware.js +0 -45
  170. package/build/server/auth/authMiddleware.js.map +0 -1
  171. package/build/server/auth/sessionManager.d.ts.map +0 -1
  172. package/build/server/auth/sessionManager.js.map +0 -1
  173. package/build/server/config/serverConfig.d.ts.map +0 -1
  174. package/build/server/config/serverConfig.js +0 -117
  175. package/build/server/config/serverConfig.js.map +0 -1
  176. package/build/server/errorHandler.d.ts.map +0 -1
  177. package/build/server/errorHandler.js.map +0 -1
  178. package/build/server/expressServer.d.ts.map +0 -1
  179. package/build/server/expressServer.js.map +0 -1
  180. package/build/server/routes/oauthRoutes.d.ts +0 -14
  181. package/build/server/routes/oauthRoutes.d.ts.map +0 -1
  182. package/build/server/routes/oauthRoutes.js +0 -132
  183. package/build/server/routes/oauthRoutes.js.map +0 -1
  184. package/build/server/routes/sseRoutes.d.ts +0 -4
  185. package/build/server/routes/sseRoutes.d.ts.map +0 -1
  186. package/build/server/routes/sseRoutes.js.map +0 -1
  187. package/build/server/routes/streamableHttpRoutes.d.ts +0 -4
  188. package/build/server/routes/streamableHttpRoutes.d.ts.map +0 -1
  189. package/build/server/routes/streamableHttpRoutes.js.map +0 -1
  190. package/build/server/tagsExtractor.d.ts.map +0 -1
  191. package/build/server/tagsExtractor.js.map +0 -1
  192. package/build/serverManager.d.ts +0 -27
  193. package/build/serverManager.d.ts.map +0 -1
  194. package/build/serverManager.js +0 -87
  195. package/build/serverManager.js.map +0 -1
  196. package/build/types.d.ts.map +0 -1
  197. package/build/types.js.map +0 -1
  198. /package/build/{server → transport/http/middlewares}/errorHandler.d.ts +0 -0
  199. /package/build/{server → transport/http/middlewares}/tagsExtractor.d.ts +0 -0
  200. /package/build/{server → transport/http/middlewares}/tagsExtractor.js +0 -0
@@ -0,0 +1,199 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import logger from '../logger/logger.js';
3
+ import { ClientSessionManager } from './clientSessionManager.js';
4
+ import { AUTH_CONFIG } from '../constants.js';
5
+ /**
6
+ * SDK-compatible OAuth client provider that replaces the custom implementation.
7
+ *
8
+ * This provider implements the OAuth 2.1 Authorization Code Grant flow using
9
+ * the SDK's OAuthClientProvider interface while maintaining compatibility with
10
+ * the existing session storage system.
11
+ */
12
+ export class SDKOAuthClientProvider {
13
+ _clientMetadata;
14
+ _clientInfo;
15
+ _tokens;
16
+ _codeVerifier;
17
+ _state;
18
+ sessionManager;
19
+ serverName;
20
+ config;
21
+ _authorizationUrl;
22
+ constructor(serverName, config, sessionStoragePath) {
23
+ this.serverName = serverName;
24
+ this.config = config;
25
+ this.sessionManager = new ClientSessionManager(sessionStoragePath);
26
+ // Set up client metadata for registration with better defaults
27
+ this._clientMetadata = {
28
+ client_name: `1MCP Agent - ${serverName}`,
29
+ redirect_uris: [config.redirectUrl || ''],
30
+ grant_types: ['authorization_code', 'refresh_token'],
31
+ response_types: ['code'],
32
+ token_endpoint_auth_method: config.clientSecret ? 'client_secret_post' : 'none',
33
+ scope: config.scopes?.join(' ') || AUTH_CONFIG.CLIENT.OAUTH.DEFAULT_SCOPES.join(' '),
34
+ };
35
+ logger.debug(`OAuth client metadata: ${JSON.stringify(this._clientMetadata)}`);
36
+ // Load existing client info and tokens if available
37
+ this.loadPersistedData();
38
+ }
39
+ get redirectUrl() {
40
+ return this.config.redirectUrl || '';
41
+ }
42
+ get clientMetadata() {
43
+ return this._clientMetadata;
44
+ }
45
+ /**
46
+ * Returns current client registration information
47
+ */
48
+ clientInformation() {
49
+ return this._clientInfo;
50
+ }
51
+ /**
52
+ * Saves client registration information from dynamic registration
53
+ */
54
+ saveClientInformation(clientInfo) {
55
+ this._clientInfo = clientInfo;
56
+ this.persistAllData();
57
+ logger.info(`OAuth client registered for ${this.serverName}: ${clientInfo.client_id}`);
58
+ }
59
+ /**
60
+ * Returns current OAuth tokens
61
+ */
62
+ tokens() {
63
+ return this._tokens;
64
+ }
65
+ /**
66
+ * Saves OAuth tokens after successful authorization
67
+ */
68
+ saveTokens(tokens) {
69
+ this._tokens = tokens;
70
+ this.persistAllData();
71
+ logger.info(`OAuth tokens saved for ${this.serverName}`);
72
+ }
73
+ /**
74
+ * Stores authorization URL instead of prompting user in console
75
+ */
76
+ redirectToAuthorization(authorizationUrl) {
77
+ this._authorizationUrl = authorizationUrl.toString();
78
+ }
79
+ /**
80
+ * Gets the current authorization URL
81
+ */
82
+ getAuthorizationUrl() {
83
+ return this._authorizationUrl;
84
+ }
85
+ /**
86
+ * Clears the stored authorization URL
87
+ */
88
+ clearAuthorizationUrl() {
89
+ this._authorizationUrl = undefined;
90
+ }
91
+ /**
92
+ * Saves PKCE code verifier for the authorization session
93
+ */
94
+ saveCodeVerifier(codeVerifier) {
95
+ this._codeVerifier = codeVerifier;
96
+ this.persistAllData();
97
+ }
98
+ /**
99
+ * Returns the PKCE code verifier for token exchange
100
+ */
101
+ codeVerifier() {
102
+ return this._codeVerifier || '';
103
+ }
104
+ /**
105
+ * Returns the OAuth state parameter for CSRF protection
106
+ */
107
+ state() {
108
+ if (!this._state) {
109
+ this._state = randomUUID();
110
+ this.persistAllData();
111
+ }
112
+ return this._state;
113
+ }
114
+ /**
115
+ * Custom resource validation (optional)
116
+ */
117
+ async validateResourceURL(serverUrl, resource) {
118
+ const url = typeof serverUrl === 'string' ? new URL(serverUrl) : serverUrl;
119
+ // Basic validation - can be extended for specific requirements
120
+ if (resource && !resource.startsWith(url.origin)) {
121
+ return undefined;
122
+ }
123
+ return url;
124
+ }
125
+ /**
126
+ * Load persisted OAuth data from unified client session storage
127
+ */
128
+ loadPersistedData() {
129
+ const clientSession = this.sessionManager.getClientSession(this.serverName);
130
+ if (clientSession) {
131
+ // Load client info
132
+ if (clientSession.clientInfo) {
133
+ this._clientInfo = JSON.parse(clientSession.clientInfo);
134
+ }
135
+ // Load tokens
136
+ if (clientSession.tokens) {
137
+ this._tokens = JSON.parse(clientSession.tokens);
138
+ // Check if tokens are expired
139
+ if (this._tokens && this.isTokenExpired(this._tokens)) {
140
+ logger.warn(`OAuth tokens expired for ${this.serverName}, clearing`);
141
+ this._tokens = undefined;
142
+ this.persistAllData();
143
+ }
144
+ }
145
+ // Load code verifier
146
+ if (clientSession.codeVerifier) {
147
+ this._codeVerifier = clientSession.codeVerifier;
148
+ }
149
+ // Load state
150
+ if (clientSession.state) {
151
+ this._state = clientSession.state;
152
+ }
153
+ }
154
+ }
155
+ /**
156
+ * Persist all OAuth data to unified client session storage
157
+ */
158
+ persistAllData() {
159
+ // Calculate the longest TTL based on the data we have
160
+ let maxTtl = AUTH_CONFIG.CLIENT.OAUTH.TTL_MS; // Default to 30 days
161
+ // If we have tokens, use their expiry time
162
+ if (this._tokens && this._tokens.expires_in) {
163
+ const tokenTtl = this._tokens.expires_in * 1000;
164
+ maxTtl = Math.max(maxTtl, tokenTtl);
165
+ }
166
+ // Code verifier and state have shorter TTL, but we keep them for completeness
167
+ const clientSessionData = {
168
+ serverName: this.serverName,
169
+ clientInfo: this._clientInfo ? JSON.stringify(this._clientInfo) : undefined,
170
+ tokens: this._tokens ? JSON.stringify(this._tokens) : undefined,
171
+ codeVerifier: this._codeVerifier,
172
+ state: this._state,
173
+ expires: Date.now() + maxTtl,
174
+ createdAt: Date.now(),
175
+ };
176
+ this.sessionManager.createClientSession(this.serverName, clientSessionData);
177
+ }
178
+ /**
179
+ * Check if OAuth tokens are expired
180
+ */
181
+ isTokenExpired(tokens) {
182
+ if (!tokens.expires_in) {
183
+ return false; // No expiration info, assume valid
184
+ }
185
+ // This is a simple check - in practice, you might want to store the issued_at time
186
+ // For now, we'll rely on the session storage TTL for expiration
187
+ return false;
188
+ }
189
+ /**
190
+ * Clean up resources
191
+ */
192
+ shutdown() {
193
+ // Clean up temporary session data by clearing verifier and state
194
+ this._codeVerifier = undefined;
195
+ this._state = undefined;
196
+ this.persistAllData();
197
+ }
198
+ }
199
+ //# sourceMappingURL=sdkOAuthClientProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkOAuthClientProvider.js","sourceRoot":"","sources":["../../src/auth/sdkOAuthClientProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAa9C;;;;;;GAMG;AACH,MAAM,OAAO,sBAAsB;IACzB,eAAe,CAAsB;IACrC,WAAW,CAA8B;IACzC,OAAO,CAAe;IACtB,aAAa,CAAU;IACvB,MAAM,CAAU;IAChB,cAAc,CAAuB;IACrC,UAAU,CAAS;IACnB,MAAM,CAAoB;IAC1B,iBAAiB,CAAU;IAEnC,YAAY,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/B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,63 @@
1
+ import type { Response } from 'express';
2
+ import type { OAuthServerProvider, AuthorizationParams } from '@modelcontextprotocol/sdk/server/auth/provider.js';
3
+ import type { OAuthRegisteredClientsStore } from '@modelcontextprotocol/sdk/server/auth/clients.js';
4
+ import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
5
+ import type { OAuthClientInformationFull, OAuthTokens, OAuthTokenRevocationRequest } from '@modelcontextprotocol/sdk/shared/auth.js';
6
+ /**
7
+ * Implementation of SDK's OAuthServerProvider interface using existing SessionManager.
8
+ *
9
+ * This provider implements OAuth 2.1 server functionality using the MCP SDK's interfaces
10
+ * while maintaining compatibility with the existing session storage system.
11
+ */
12
+ export declare class SDKOAuthServerProvider implements OAuthServerProvider {
13
+ private sessionManager;
14
+ private configManager;
15
+ private _clientsStore;
16
+ constructor(sessionStoragePath?: string);
17
+ get clientsStore(): OAuthRegisteredClientsStore;
18
+ /**
19
+ * Handles the authorization request with scope validation and user consent
20
+ */
21
+ authorize(client: OAuthClientInformationFull, params: AuthorizationParams, res: Response): Promise<void>;
22
+ /**
23
+ * Determines if user consent is required for the authorization
24
+ */
25
+ private requiresUserConsent;
26
+ /**
27
+ * Renders the consent page for scope selection
28
+ */
29
+ private renderConsentPage;
30
+ /**
31
+ * Approves the authorization and redirects back to client
32
+ */
33
+ approveAuthorization(client: OAuthClientInformationFull, params: AuthorizationParams, grantedScopes: string[], res: Response): Promise<void>;
34
+ /**
35
+ * Generates the HTML for the consent page
36
+ */
37
+ private generateConsentPageHtml;
38
+ /**
39
+ * Retrieves the PKCE challenge for an authorization code
40
+ */
41
+ challengeForAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string): Promise<string>;
42
+ /**
43
+ * Exchanges authorization code for access token
44
+ */
45
+ exchangeAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string, _codeVerifier?: string, redirectUri?: string, resource?: URL): Promise<OAuthTokens>;
46
+ /**
47
+ * Exchanges refresh token for new access token (not implemented)
48
+ */
49
+ exchangeRefreshToken(_client: OAuthClientInformationFull, _refreshToken: string, _scopes?: string[], _resource?: URL): Promise<OAuthTokens>;
50
+ /**
51
+ * Verifies access token and returns auth info with granted scopes
52
+ */
53
+ verifyAccessToken(token: string): Promise<AuthInfo>;
54
+ /**
55
+ * Revokes a token
56
+ */
57
+ revokeToken(client: OAuthClientInformationFull, request: OAuthTokenRevocationRequest): Promise<void>;
58
+ /**
59
+ * Graceful shutdown
60
+ */
61
+ shutdown(): void;
62
+ }
63
+ //# sourceMappingURL=sdkOAuthServerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdkOAuthServerProvider.d.ts","sourceRoot":"","sources":["../../src/auth/sdkOAuthServerProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAClH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EACV,0BAA0B,EAC1B,WAAW,EACX,2BAA2B,EAC5B,MAAM,0CAA0C,CAAC;AA2FlD;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,aAAa,CAA8B;gBAEvC,kBAAkB,CAAC,EAAE,MAAM;IAMvC,IAAI,YAAY,IAAI,2BAA2B,CAE9C;IAED;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,0BAA0B,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,QAAQ,GAAG,OA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