repl.it-api
Advanced tools
Comparing version 1.0.1 to 1.1.0
20
lib.js
@@ -1,2 +0,2 @@ | ||
const { CookieJar } = require('tough-cookie') | ||
const { CookieJar, Cookie } = require('tough-cookie') | ||
const nodeFetch = require('node-fetch') | ||
@@ -16,3 +16,4 @@ const fetchCookie = require('fetch-cookie') | ||
this.got = {} | ||
this.fetch = fetchCookie(nodeFetch, new CookieJar()) | ||
this.jar = new CookieJar() | ||
this.fetch = fetchCookie(nodeFetch, this.jar) | ||
this.timeout = timeout | ||
@@ -43,2 +44,17 @@ } | ||
login(sid) { | ||
const cookie = Cookie.fromJSON({ | ||
key: 'connect.sid', | ||
value: sid, | ||
domain: 'repl.it', | ||
path: '/' | ||
}) | ||
return new Promise((resolve, reject) => { | ||
this.jar.setCookie(cookie, 'https://repl.it/', (error) => { | ||
if (error) return reject(error) | ||
resolve() | ||
}) | ||
}) | ||
} | ||
async connect() { | ||
@@ -45,0 +61,0 @@ const connection = await new Promise((resolve, reject) => { |
{ | ||
"name": "repl.it-api", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A Node.js client for creating projects and executing code on Repl.it.", | ||
@@ -5,0 +5,0 @@ "main": "lib.js", |
@@ -92,2 +92,12 @@ # Repl.it API | ||
### Log In | ||
If you want, you can create repls under your account by logging in. You have to get the cookie `connect.sid` from your browser, and save that somewhere super safe. **Don't store it anywhere public, including Git!** | ||
```javascript | ||
await client.login(sid) | ||
``` | ||
`client#login` takes one argument: a string which should be the `connect.sid` cookie's value. | ||
### Close the Connection | ||
@@ -94,0 +104,0 @@ |
11393
172
127