diff --git a/lib/peertubeRequester.ts b/lib/peertubeRequester.ts index 9e58271..4c09776 100644 --- a/lib/peertubeRequester.ts +++ b/lib/peertubeRequester.ts @@ -17,38 +17,39 @@ type UploadInstruction = { }; class PeerTubeRequester { - readonly domain_name: URL; + readonly domainName: URL; readonly username: string; readonly password: string; constructor(readonly config: PeerTubeRequester.Config) { - this.domain_name = new URL("/", config.domain_name); + this.domainName = new URL("/", config.domainName); this.username = config.username; this.password = config.password; } private async requestAuthToken(): Promise { let response = await fetch( - new URL(`/api/v1/oauth-clients/local`, this.domain_name) + new URL(`/api/v1/oauth-clients/local`, this.domainName) ); if (!response.ok) { throw new Error(response.statusText); // CRASH } - const { client_id, client_secret } = await response.json(); + const { client_id: clientId, client_secret: clientSecret } = + await response.json(); - const client_info: { [key: string]: string } = { - client_id, - client_secret, - grant_type: "password", - response_type: "code", + const clientInfo: { [key: string]: string } = { + clientId, + clientSecret, + grantType: "password", + responseType: "code", username: this.username, password: this.password, }; let myParams = new URLSearchParams(); - for (const key in client_info) myParams.append(key, client_info[key]); + for (const key in clientInfo) myParams.append(key, clientInfo[key]); - response = await fetch(new URL(`/api/v1/users/token`, this.domain_name), { + response = await fetch(new URL(`/api/v1/users/token`, this.domainName), { method: "post", body: myParams, }); @@ -67,7 +68,7 @@ class PeerTubeRequester { for (const key in message) myUploadForm.append(key, message[key]); const response = await fetch( - new URL(`/api/v1/videos/imports`, this.domain_name), + new URL("/api/v1/videos/imports", this.domainName), { method: "post", headers: myHeader,