fix(sdk-api): route authenticate() to v2 login - #9716
Conversation
/api/auth/v1/session is behind a Cloudflare managed challenge that HTTP/Node clients cannot complete, breaking the documented SDK login flow. Route bitgo.authenticate() to /api/v2/user/login instead. Also: - Make authenticateWithAccessToken async and await the HMAC strategy setToken() so the token is registered before the caller issues any subsequent signed request (closes a race for async strategies like WebCryptoHmacStrategy). Await at both call sites. Ticket: WCN-2652
|
|
| * can safely issue signed requests immediately after. | ||
| */ | ||
| authenticateWithAccessToken({ accessToken }: AccessTokenOptions): void { | ||
| async authenticateWithAccessToken({ accessToken }: AccessTokenOptions): Promise<void> { |
There was a problem hiding this comment.
This changes the public method contract from synchronous void to Promise<void>. Consumers that call authenticateWithAccessToken() before issuing signed requests must now await it, and callers that continue ignoring the return value can race asynchronous HMAC token setup. Please treat this as a breaking SDK change: mark the commit accordingly (for example, fix(sdk-api)!: ... plus a BREAKING CHANGE: footer) and audit/migrate all public callers, including the example scripts.
mohammadalfaiyazbitgo
left a comment
There was a problem hiding this comment.
Change looks good, but we need to be explicit that the signature change is a breaking change.
What
/api/auth/v1/session is behind a Cloudflare managed challenge that HTTP/Node clients cannot complete, breaking the documented SDK login flow. Route bitgo.authenticate() to /api/v2/user/login instead.
Also:
Ticket: WCN-2652
Testing