bug: DingTalk web connector drops corpId from the access-token response
Describe the bug
The DingTalk web connector drops corpId returned by DingTalk's access-token endpoint before constructing the social user information.
At upstream commit a2d6e83a4f769b79900e1a34f373d96c751faa47 (@logto/connector-dingtalk-web version 0.4.6):
accessTokenResponseGuardalready accepts an optionalcorpId.getAccessToken()extracts and returns onlyaccessToken, discardingcorpId.getUserInfo()returnsrawDatafrom the separate user-info response without carrying over the corporation ID from the token response.
Consequently, even when DingTalk supplies corpId, that value does not reach the social identity details through this connector. Applications that need the corporation identifier cannot retrieve it from those details.
Expected behavior
When the token response includes corpId, preserve it in the returned social user information, for example as rawData.corpId, alongside the original user-info fields.
When corpId is absent, preserve the existing behavior. Access and refresh tokens should not be copied into rawData.
This request concerns retaining provider metadata; it does not request automatic organization assignment or additional token claims.
How to reproduce?
This is reproducible with the connector's existing mocked HTTP tests; no live DingTalk credentials are needed.
Check out upstream commit
a2d6e83a4f769b79900e1a34f373d96c751faa47and prepare the connector's workspace dependencies.In
packages/connectors/connector-dingtalk-web/src/index.test.ts, use the existing token-response fixture, which already includesaccessToken: 'accessToken'andcorpId: 'corpId'.Strengthen the
getAccessTokentest to assert the complete result:expect(await getAccessToken('code', mockedConfig)).toStrictEqual({ accessToken: 'accessToken', corpId: 'corpId', });It fails because the actual result contains only
accessToken.In the existing valid
getUserInfotest, expectcorpId: 'corpId'insiderawData. This also fails because the returnedrawDatacontains only the user-info response fields.Run the connector tests with
pnpm exec vitest run src --globalsfrom the connector directory.
Both regression assertions failed on the original implementation. With the proposed fix, all 7 connector tests pass, including a case verifying that an absent corpId leaves the user-info data unchanged and retains additional provider fields.
I am willing to contribute the fix. The implementation and tests are available for discussion here: https://github.com/renyijiu/logto/commit/5090fb3
Environment
Self-hosted (Node.js) — reproduced locally against the source code using mocked HTTP responses, not an end-to-end DingTalk sign-in.
- Upstream commit:
a2d6e83a4f769b79900e1a34f373d96c751faa47 - Connector:
@logto/[email protected] - Local test runtime: Node.js
26.5.1, pnpm10.34.5, Vitest4.1.8 - The project specifies Node.js
^22.14.0; the local test runtime above differs from that requirement.
Screenshots
Not applicable; the reproduction is covered by assertions on the connector's returned data.
Source: logto-io/logto