initial commit
This commit is contained in:
44
.setup/services/auth.service.ts
Normal file
44
.setup/services/auth.service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import api from "./api.service";
|
||||
import rl from "readline-sync";
|
||||
import cookie from "cookie";
|
||||
|
||||
const getToken = async () => {
|
||||
var email = rl.question("Email: ");
|
||||
var password = rl.question("Password: ", {
|
||||
hideEchoBack: true,
|
||||
});
|
||||
|
||||
const credentials = await api().post("/account/sessions", {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
|
||||
return cookie.parse(credentials.headers["set-cookie"].toString())
|
||||
.a_session_console_legacy;
|
||||
};
|
||||
|
||||
const generateApiKey = async () => {
|
||||
const res = await api().post("/projects/pingvin-share/keys", {
|
||||
name: "Setup key",
|
||||
scopes: [
|
||||
"collections.read",
|
||||
"collections.write",
|
||||
"attributes.read",
|
||||
"attributes.write",
|
||||
"indexes.read",
|
||||
"indexes.write",
|
||||
"documents.read",
|
||||
"documents.write",
|
||||
"functions.read",
|
||||
"functions.write",
|
||||
"execution.read",
|
||||
"execution.write",
|
||||
],
|
||||
});
|
||||
return res.data.secret;
|
||||
};
|
||||
|
||||
export default {
|
||||
getToken,
|
||||
generateApiKey,
|
||||
};
|
||||
Reference in New Issue
Block a user