|
14 | 14 |
|
15 | 15 | import { randomUUID } from 'node:crypto'; |
16 | 16 | import type { Browser, BrowserContext, Response } from 'playwright'; |
17 | | -import { ApiCredentials, ApiCredentialStatus, OAuthCredentials } from '../apiCredentials/base.js'; |
| 17 | +import { ApiCredentials, OAuthCredentials } from '../apiCredentials/base.js'; |
18 | 18 | import { |
19 | 19 | exchangeCodeForTokens, |
20 | 20 | generateCodeChallenge, |
@@ -193,10 +193,18 @@ export class Ramp extends Service { |
193 | 193 | 'Ramp agent-tools API; the REST API is not supported. ' + |
194 | 194 | 'Docs: https://api.ramp.com/v1/public/agent-tools/spec/.'; |
195 | 195 |
|
196 | | - // Unused: browser-login credentials are validated by holding/refreshing a live |
197 | | - // token (see checkApiCredentials), not by hitting a resource endpoint. Only present |
198 | | - // because the base class declares it abstract. |
| 196 | + // Validate credentials against `search-help-center-snippets`: the one agent-tools |
| 197 | + // endpoint that requires only a valid token and no specific scope (`security: |
| 198 | + // [{oauth2: []}]` in the spec), so the check works regardless of which scopes the |
| 199 | + // signed-in user's agent key was granted. It's a POST taking a required |
| 200 | + // {query, rationale} body; a bad token returns a non-200 (404 DEVELOPER_7002). |
199 | 201 | readonly credentialCheckCurlArguments = [ |
| 202 | + '-X', |
| 203 | + 'POST', |
| 204 | + '-H', |
| 205 | + 'Content-Type: application/json', |
| 206 | + '-d', |
| 207 | + '{"query":"ping","rationale":"latchkey credential check"}', |
200 | 208 | 'https://api.ramp.com/developer/v1/agent-tools/search-help-center-snippets', |
201 | 209 | ] as const; |
202 | 210 |
|
@@ -243,28 +251,6 @@ export class Ramp extends Service { |
243 | 251 | ) |
244 | 252 | ); |
245 | 253 | } |
246 | | - |
247 | | - /** |
248 | | - * Validate credentials by confirming a live token is held (refreshing first if |
249 | | - * expired) rather than by hitting a resource endpoint -- Ramp has no scope-free |
250 | | - * endpoint, so a resource check would force the user to grant a particular scope. |
251 | | - */ |
252 | | - override async checkApiCredentials(apiCredentials: ApiCredentials): Promise<ApiCredentialStatus> { |
253 | | - if (!(apiCredentials instanceof OAuthCredentials)) { |
254 | | - return ApiCredentialStatus.Missing; |
255 | | - } |
256 | | - let credentials: OAuthCredentials | null = apiCredentials; |
257 | | - if (credentials.isExpired() === true) { |
258 | | - const refreshed = await this.refreshCredentials(apiCredentials); |
259 | | - credentials = refreshed instanceof OAuthCredentials ? refreshed : null; |
260 | | - } |
261 | | - if (credentials?.accessToken === undefined) { |
262 | | - return ApiCredentialStatus.Invalid; |
263 | | - } |
264 | | - return credentials.isExpired() === true |
265 | | - ? ApiCredentialStatus.Invalid |
266 | | - : ApiCredentialStatus.Valid; |
267 | | - } |
268 | 254 | } |
269 | 255 |
|
270 | 256 | export const RAMP = new Ramp(); |
0 commit comments