mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
d2974a9ff6
* refactor(adapters): convert adapter layer from TypeScript to JavaScript Core framework stays TypeScript; adapter layer moves to JS-first. Adapters are essentially "executable config + browser scripts" that barely use TS features — this simplifies the build/distribution pipeline by removing the dist/clis/ intermediate compilation step. Changes: - Convert all 753 adapter files in clis/ from .ts to .js - Update tsconfig to exclude clis/ from compilation - Simplify build-manifest to scan clis/*.js directly (no dist/clis/) - Update discovery, main, fetch-adapters to load JS adapters from clis/ - Update generate-verified to output .js artifacts - Update package.json files field: dist/clis/ → clis/ - Fix all test files for the .ts → .js transition * fix(main): use findPackageRoot for BUILTIN_CLIS path The previous relative path (../../clis from __dirname) only worked for dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname is <repo>/src — resolving to /clis instead of <repo>/clis. Use findPackageRoot() which works for both dev and prod paths.
22 lines
910 B
JavaScript
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;
|
|
}
|