openyida 2026.9.22-beta.1 → 2026.9.22-beta.2
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/dws-sync.js +8 -5
- package/package.json +1 -1
package/lib/auth/dws-sync.js
CHANGED
|
@@ -46,7 +46,7 @@ function readHandoff(input = process.stdin, timeoutMs = 10000) {
|
|
|
46
46
|
|| Object.keys(data).some((key) => !['accessToken', 'corpId', 'environment'].includes(key))
|
|
47
47
|
|| typeof data.accessToken !== 'string' || !data.accessToken || data.accessToken.length > 8192
|
|
48
48
|
|| (/\s/.test(data.accessToken) || [...data.accessToken].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
|
|
49
|
-
|| typeof data.corpId !== 'string' || !data.corpId || data.corpId.length > 256
|
|
49
|
+
|| (data.corpId !== undefined && (typeof data.corpId !== 'string' || !data.corpId.trim() || data.corpId.length > 256))
|
|
50
50
|
|| !['pre', 'prod'].includes(data.environment)) {
|
|
51
51
|
finish(failure('INVALID_HANDOFF')); return;
|
|
52
52
|
}
|
|
@@ -73,11 +73,12 @@ async function syncDws(options = {}) {
|
|
|
73
73
|
if (target.protocol !== 'https:' || target.username || target.password || target.search || target.hash
|
|
74
74
|
|| target.pathname !== '/') { throw failure('TRUSTED_HTTPS_ORIGIN_REQUIRED'); }
|
|
75
75
|
const handoff = await readHandoff(options.input || process.stdin, options.stdinTimeoutMs);
|
|
76
|
-
if (options.corpId && options.corpId !== handoff.corpId) { throw failure('ORG_CONFLICT'); }
|
|
76
|
+
if (options.corpId && handoff.corpId && options.corpId !== handoff.corpId) { throw failure('ORG_CONFLICT'); }
|
|
77
|
+
const expectedCorp = options.corpId || handoff.corpId;
|
|
77
78
|
let response;
|
|
78
79
|
try {
|
|
79
80
|
response = await requestJson('POST', `${target.origin}/openapi/cli/v1/auth/dws/token`, {
|
|
80
|
-
corpId:
|
|
81
|
+
...(expectedCorp ? { corpId: expectedCorp } : {}), environment: handoff.environment,
|
|
81
82
|
}, { Authorization: `Bearer ${handoff.accessToken}` }, { timeoutMs: 30000, maxResponseBytes: 65536 });
|
|
82
83
|
} catch {
|
|
83
84
|
throw failure('EXCHANGE_REQUEST_FAILED');
|
|
@@ -92,7 +93,9 @@ async function syncDws(options = {}) {
|
|
|
92
93
|
const now = Date.now() / 1000;
|
|
93
94
|
if (typeof data.access_token !== 'string' || !data.access_token
|
|
94
95
|
|| typeof data.refresh_token !== 'string' || !data.refresh_token
|
|
95
|
-
|| data.client_id !== DINGTALK_OAUTH_CLIENT_ID
|
|
96
|
+
|| data.client_id !== DINGTALK_OAUTH_CLIENT_ID
|
|
97
|
+
|| typeof data.corp_id !== 'string' || !data.corp_id.trim()
|
|
98
|
+
|| (expectedCorp && data.corp_id !== expectedCorp)
|
|
96
99
|
|| typeof data.user_id !== 'string' || !data.user_id
|
|
97
100
|
|| data.credential_source !== 'dws' || data.environment !== handoff.environment
|
|
98
101
|
|| typeof data.session_id !== 'string' || !/^[a-f0-9-]{36}$/.test(data.session_id)
|
|
@@ -129,7 +132,7 @@ async function syncDws(options = {}) {
|
|
|
129
132
|
|
|
130
133
|
async function run(args, options = {}) {
|
|
131
134
|
if (args.length === 2 && args.includes('--capabilities') && args.includes('--json')) {
|
|
132
|
-
const capabilities = { protocol_version: 1, private_stdin: true, independent_profile: true };
|
|
135
|
+
const capabilities = { protocol_version: 1, private_stdin: true, independent_profile: true, server_identity: true };
|
|
133
136
|
console.log(JSON.stringify(capabilities));
|
|
134
137
|
return capabilities;
|
|
135
138
|
}
|