SalesforceCommerceCloud / commerce-sdk-isomorphic

Browser & Node.js JavaScript client for B2C Commerce API
https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/
BSD 3-Clause "New" or "Revised" License
43 stars 21 forks source link

Update SLAS helper to require channel_id #165

Closed joeluong-sfcc closed 3 months ago

joeluong-sfcc commented 3 months ago

Starting 7/31/2024, SLAS will start requiring the channel_id as a required argument when retrieving an access token with grant_type: 'client_credentials for security purposes. This PR updates the loginGuestUserPrivate SLAS helper function to require channel_id.

joeluong-sfcc commented 3 months ago

Not related to this change but I see the loginGuestUserPrivate is async, yet I don't see any await statement inside the function.

Are we missing an await statement here?

https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/blob/ba0e1a9765879326190e5d9904e5f74e0c4982ce/src/static/helpers/slasHelper.ts#L206

return await slasClient.getAccessToken(options);

@adamraya Someone can correct my javascript knowledge if its incorrect, but I believe that marking a function with async means that return value is automatically a promise, so although we don't use await statements, we return a Promise<TokenResponse>

adamraya commented 3 months ago

Someone can correct my javascript knowledge if its incorrect, but I believe that marking a function with async means that return value is automatically a promise, so although we don't use await statements, we return a Promise<TokenResponse>

Yes you're right, the function marked with async automatically returns a promise. It will not wait for getAccessToken to resolve before returning, but I guess subsequent operations are handled in getAccessToken.