Files
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

22 lines
910 B
JavaScript

import { AuthRequiredError } from '@jackwener/opencli/errors';
const STS2_URL = 'https://creator.douyin.com/aweme/mid/video/sts2/?scene=web&aid=1128&cookie_enabled=true&device_platform=web';
/**
* Fetch STS2 temporary credentials from the creator center.
* These are used to authenticate Node.js-side TOS multipart uploads.
* Returns: { access_key_id, secret_access_key, session_token, expired_time }
*/
export async function getSts2Credentials(page) {
const js = `fetch(${JSON.stringify(STS2_URL)}, { credentials: 'include' }).then(r => r.json())`;
const res = await page.evaluate(js);
const credentials = (typeof res === 'object' &&
res !== null &&
'data' in res &&
res.data)
? res.data
: res;
if (!credentials?.access_key_id) {
throw new AuthRequiredError('creator.douyin.com', 'STS2 credentials missing');
}
return credentials;
}