openyida 2026.7.17-3 → 2026.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/token-auth.js +5 -15
- package/package.json +1 -1
package/lib/auth/token-auth.js
CHANGED
|
@@ -156,10 +156,6 @@ function getTokenPayload(response) {
|
|
|
156
156
|
|
|
157
157
|
function normalizeTokenResponse(response, baseUrl, clientId) {
|
|
158
158
|
const data = getTokenPayload(response);
|
|
159
|
-
const resolvedBaseUrl = normalizeBaseUrl(
|
|
160
|
-
data.base_url || data.baseUrl || baseUrl,
|
|
161
|
-
baseUrl
|
|
162
|
-
);
|
|
163
159
|
return {
|
|
164
160
|
auth_mode: 'token',
|
|
165
161
|
status: data.status || 'ok',
|
|
@@ -170,7 +166,7 @@ function normalizeTokenResponse(response, baseUrl, clientId) {
|
|
|
170
166
|
refresh_token: data.refresh_token || data.refreshToken,
|
|
171
167
|
expires_in: data.expires_in || data.expiresIn,
|
|
172
168
|
expires_at: data.expires_at || data.expiresAt,
|
|
173
|
-
base_url:
|
|
169
|
+
base_url: baseUrl,
|
|
174
170
|
client_id: data.client_id || data.clientId || clientId,
|
|
175
171
|
corp_id: data.corp_id || data.corpId,
|
|
176
172
|
user_id: data.user_id || data.userId,
|
|
@@ -348,14 +344,9 @@ async function tokenRefresh(options = {}) {
|
|
|
348
344
|
};
|
|
349
345
|
}
|
|
350
346
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const authBaseUrlValue = resolveTokenBaseUrl({
|
|
355
|
-
projectRoot: options.projectRoot,
|
|
356
|
-
endpoint: options.endpoint,
|
|
357
|
-
});
|
|
358
|
-
const authBaseUrl = appendPath(authBaseUrlValue, DEFAULT_AUTH_PATH_PREFIX);
|
|
347
|
+
const baseUrl = normalizeBaseUrl(options.endpoint || options.baseUrl || session.base_url, null) ||
|
|
348
|
+
resolveTokenBaseUrl(options);
|
|
349
|
+
const authBaseUrl = appendPath(baseUrl, DEFAULT_AUTH_PATH_PREFIX);
|
|
359
350
|
const clientId = options.clientId || session.client_id || DINGTALK_OAUTH_CLIENT_ID;
|
|
360
351
|
const response = await requestJson('POST', appendPath(authBaseUrl, '/refresh'), {
|
|
361
352
|
refreshToken: session.refresh_token,
|
|
@@ -363,14 +354,13 @@ async function tokenRefresh(options = {}) {
|
|
|
363
354
|
});
|
|
364
355
|
requireOkResponse(response);
|
|
365
356
|
const data = getTokenPayload(response);
|
|
366
|
-
const businessBaseUrl = session.base_url || authBaseUrlValue;
|
|
367
357
|
const normalized = normalizeTokenResponse({
|
|
368
358
|
...data,
|
|
369
359
|
corp_id: data.corp_id || data.corpId || session.corp_id,
|
|
370
360
|
user_id: data.user_id || data.userId || session.user_id,
|
|
371
361
|
user_name: data.user_name || data.userName || session.user_name,
|
|
372
362
|
refresh_token: data.refresh_token || data.refreshToken || session.refresh_token,
|
|
373
|
-
},
|
|
363
|
+
}, baseUrl, clientId);
|
|
374
364
|
if (!normalized.access_token) {
|
|
375
365
|
return {
|
|
376
366
|
...normalized,
|