Skip to content

Commit e10ab76

Browse files
waleedlatif1claude
andcommitted
fix(sap-concur): rename misleading exchange-rate tool, drop unusable refresh_token grant, validate geolocation host
- Rename sap_concur_get_exchange_rate to sap_concur_upload_exchange_rates (POST bulk upload, not GET) - Remove refresh_token from SapConcurGrantType / Zod enum / block dropdown / docs (no implementation) - Validate Concur geolocation hostname against SAP_CONCUR_ALLOWED_DATACENTERS Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d767d76 commit e10ab76

76 files changed

Lines changed: 165 additions & 158 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/content/docs/en/tools/sap_concur.mdx

Lines changed: 71 additions & 71 deletions
Large diffs are not rendered by default.

apps/sim/app/api/tools/sap_concur/shared.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const SapConcurDatacenterSchema = z
2222
message: `datacenter must be one of: ${Array.from(SAP_CONCUR_ALLOWED_DATACENTERS).join(', ')}`,
2323
})
2424

25-
export const SapConcurGrantTypeSchema = z.enum(['client_credentials', 'password', 'refresh_token'])
25+
export const SapConcurGrantTypeSchema = z.enum(['client_credentials', 'password'])
2626

2727
export const SapConcurAuthSchema = z.object({
2828
datacenter: SapConcurDatacenterSchema.default('us.api.concursolutions.com'),
@@ -257,7 +257,12 @@ export async function fetchSapConcurAccessToken(
257257
}
258258

259259
const geolocation = normalizeGeolocation(data.geolocation, auth.datacenter)
260-
assertSafeExternalUrl(geolocation, 'geolocation')
260+
const geolocationUrl = assertSafeExternalUrl(geolocation, 'geolocation')
261+
if (!SAP_CONCUR_ALLOWED_DATACENTERS.has(geolocationUrl.hostname.toLowerCase())) {
262+
throw new Error(
263+
`Concur geolocation host is not in the allowed datacenter list: ${geolocationUrl.hostname}`
264+
)
265+
}
261266

262267
const expiresInMs = (data.expires_in ?? 3600) * 1000
263268
rememberToken(cacheKey, {

apps/sim/blocks/blocks/sap_concur.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const BODY_OPS = [
152152
'sap_concur_update_user',
153153
'sap_concur_search_users',
154154
'sap_concur_create_purchase_request',
155-
'sap_concur_get_exchange_rate',
155+
'sap_concur_upload_exchange_rates',
156156
]
157157

158158
export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
@@ -247,7 +247,7 @@ export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
247247
{ label: 'List Budgets', id: 'sap_concur_list_budgets' },
248248
{ label: 'Get Budget', id: 'sap_concur_get_budget' },
249249
{ label: 'List Budget Categories', id: 'sap_concur_list_budget_categories' },
250-
{ label: 'Get Exchange Rate', id: 'sap_concur_get_exchange_rate' },
250+
{ label: 'Upload Exchange Rates', id: 'sap_concur_upload_exchange_rates' },
251251
{ label: 'Create Purchase Request', id: 'sap_concur_create_purchase_request' },
252252
{ label: 'Get Purchase Request', id: 'sap_concur_get_purchase_request' },
253253
{ label: 'Get Travel Profile', id: 'sap_concur_get_travel_profile' },
@@ -284,7 +284,6 @@ export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
284284
options: [
285285
{ label: 'Client Credentials', id: 'client_credentials' },
286286
{ label: 'Password', id: 'password' },
287-
{ label: 'Refresh Token', id: 'refresh_token' },
288287
],
289288
value: () => 'client_credentials',
290289
},
@@ -1240,7 +1239,7 @@ export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
12401239
'sap_concur_update_user',
12411240
'sap_concur_search_users',
12421241
'sap_concur_create_purchase_request',
1243-
'sap_concur_get_exchange_rate',
1242+
'sap_concur_upload_exchange_rates',
12441243
'sap_concur_create_list_item',
12451244
'sap_concur_update_list_item',
12461245
],
@@ -1270,7 +1269,7 @@ export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
12701269
'sap_concur_get_allocation',
12711270
'sap_concur_get_budget',
12721271
'sap_concur_get_cash_advance',
1273-
'sap_concur_get_exchange_rate',
1272+
'sap_concur_upload_exchange_rates',
12741273
'sap_concur_get_expected_expense',
12751274
'sap_concur_get_expense',
12761275
'sap_concur_get_expense_report',
@@ -1699,7 +1698,7 @@ export const SapConcurBlock: BlockConfig<SapConcurProxyResponse> = {
16991698
return { ...auth, budgetId: params.budgetId }
17001699
case 'sap_concur_list_budget_categories':
17011700
return { ...auth }
1702-
case 'sap_concur_get_exchange_rate':
1701+
case 'sap_concur_upload_exchange_rates':
17031702
return { ...auth, body: params.body }
17041703
case 'sap_concur_create_purchase_request':
17051704
return { ...auth, body: params.body }

apps/sim/tools/registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,6 @@ import {
22922292
getAllocationTool as sapConcurGetAllocationTool,
22932293
getBudgetTool as sapConcurGetBudgetTool,
22942294
getCashAdvanceTool as sapConcurGetCashAdvanceTool,
2295-
getExchangeRateTool as sapConcurGetExchangeRateTool,
22962295
getExpectedExpenseTool as sapConcurGetExpectedExpenseTool,
22972296
getExpenseReportTool as sapConcurGetExpenseReportTool,
22982297
getExpenseTool as sapConcurGetExpenseTool,
@@ -2340,6 +2339,7 @@ import {
23402339
updateListItemTool as sapConcurUpdateListItemTool,
23412340
updateTravelRequestTool as sapConcurUpdateTravelRequestTool,
23422341
updateUserTool as sapConcurUpdateUserTool,
2342+
uploadExchangeRatesTool as sapConcurUploadExchangeRatesTool,
23432343
uploadReceiptImageTool as sapConcurUploadReceiptImageTool,
23442344
} from '@/tools/sap_concur'
23452345
import {
@@ -5463,7 +5463,7 @@ export const tools: Record<string, ToolConfig> = {
54635463
sap_concur_get_allocation: sapConcurGetAllocationTool,
54645464
sap_concur_get_budget: sapConcurGetBudgetTool,
54655465
sap_concur_get_cash_advance: sapConcurGetCashAdvanceTool,
5466-
sap_concur_get_exchange_rate: sapConcurGetExchangeRateTool,
5466+
sap_concur_upload_exchange_rates: sapConcurUploadExchangeRatesTool,
54675467
sap_concur_get_expected_expense: sapConcurGetExpectedExpenseTool,
54685468
sap_concur_get_expense: sapConcurGetExpenseTool,
54695469
sap_concur_get_expense_report: sapConcurGetExpenseReportTool,

apps/sim/tools/sap_concur/approve_expense_report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const approveExpenseReportTool: ToolConfig<
2727
type: 'string',
2828
required: false,
2929
visibility: 'user-only',
30-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
30+
description: 'OAuth grant type: client_credentials (default) or password',
3131
},
3232
clientId: {
3333
type: 'string',

apps/sim/tools/sap_concur/associate_attendees.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const associateAttendeesTool: ToolConfig<AssociateAttendeesParams, SapCon
2525
type: 'string',
2626
required: false,
2727
visibility: 'user-only',
28-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
28+
description: 'OAuth grant type: client_credentials (default) or password',
2929
},
3030
clientId: {
3131
type: 'string',

apps/sim/tools/sap_concur/create_cash_advance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const createCashAdvanceTool: ToolConfig<CreateCashAdvanceParams, SapConcu
2222
type: 'string',
2323
required: false,
2424
visibility: 'user-only',
25-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
25+
description: 'OAuth grant type: client_credentials (default) or password',
2626
},
2727
clientId: {
2828
type: 'string',

apps/sim/tools/sap_concur/create_expected_expense.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const createExpectedExpenseTool: ToolConfig<
2727
type: 'string',
2828
required: false,
2929
visibility: 'user-only',
30-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
30+
description: 'OAuth grant type: client_credentials (default) or password',
3131
},
3232
clientId: {
3333
type: 'string',

apps/sim/tools/sap_concur/create_expense_report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const createExpenseReportTool: ToolConfig<
2727
type: 'string',
2828
required: false,
2929
visibility: 'user-only',
30-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
30+
description: 'OAuth grant type: client_credentials (default) or password',
3131
},
3232
clientId: {
3333
type: 'string',

apps/sim/tools/sap_concur/create_list_item.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const createListItemTool: ToolConfig<CreateListItemParams, SapConcurProxy
2222
type: 'string',
2323
required: false,
2424
visibility: 'user-only',
25-
description: 'OAuth grant type: client_credentials (default), password, refresh_token',
25+
description: 'OAuth grant type: client_credentials (default) or password',
2626
},
2727
clientId: {
2828
type: 'string',

0 commit comments

Comments
 (0)