-
Notifications
You must be signed in to change notification settings - Fork 2
feat(package): add CSRF token management #4
Conversation
cd9c3fc
to
761eca5
Compare
770b2f6
to
45b336e
Compare
78c538d
to
400045e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks.
}; | ||
|
||
authenticatedAPIClient.getCsrfToken = apiHostname => | ||
authenticatedAPIClient.get(`https://${apiHostname}${authenticatedAPIClient.csrfTokenApiPath}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need http support for local dev environment? Probably not a blocker, but just curious about local development.
const url = new Url(request.url); | ||
const { hostname } = url; | ||
const csrfToken = csrfTokens[hostname]; | ||
if (!csrfToken) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simpler to follow if you start with if (csrfToken)
and set header and return early. Then the rest of the method would be used for the queue and promise.
const originalRequest = request; | ||
const isAuthUrl = authenticatedAPIClient.isAuthUrl(originalRequest.url); | ||
const isAccessTokenExpired = authenticatedAPIClient.isAccessTokenExpired(); | ||
if (!isAuthUrl && isAccessTokenExpired) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Similar comment in terms of possibly inverting the if and returning earlier.
}); | ||
expects(client); | ||
|
||
if (expectHeaderSet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need an else?
18ca4e9
to
d91a223
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to make any of the remaining changes as you see fit. Thanks.
d91a223
to
5bcd094
Compare
5bcd094
to
e9f9b9a
Compare
No description provided.