Why is authing with GitHub so weird
This commit is contained in:
parent
2777e68134
commit
bc89f59552
7 changed files with 41 additions and 66 deletions
|
@ -2,6 +2,10 @@
|
||||||
# HTTPS is assumed for security reasons
|
# HTTPS is assumed for security reasons
|
||||||
DAEMON_URL=
|
DAEMON_URL=
|
||||||
|
|
||||||
|
# These are for powering the LBRY Developer Program
|
||||||
|
GITHUB_APP_ID=
|
||||||
|
GITHUB_APP_TOKEN=
|
||||||
|
|
||||||
# https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app
|
# https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app
|
||||||
# We use this to show the GitHub feed on the homepage
|
# We use this to show the GitHub feed on the homepage
|
||||||
GITHUB_OAUTH_TOKEN=
|
GITHUB_OAUTH_TOKEN=
|
||||||
|
|
|
@ -35,7 +35,6 @@ function main() {
|
||||||
|
|
||||||
app.route("/", page(require("./views/home")));
|
app.route("/", page(require("./views/home")));
|
||||||
app.route("/api/*", page(require("./views/api")));
|
app.route("/api/*", page(require("./views/api")));
|
||||||
app.route("/dev-program", page(require("./views/dev")));
|
|
||||||
app.route("/spec", page(require("./views/spec")));
|
app.route("/spec", page(require("./views/spec")));
|
||||||
app.route("/*", page(require("./views/redirect")));
|
app.route("/*", page(require("./views/redirect")));
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,9 @@ function initializePlayground() {
|
||||||
document.querySelector("#fetch-claim-uri").focus();
|
document.querySelector("#fetch-claim-uri").focus();
|
||||||
document.querySelector(".playground-navigation__example:nth-child(1)").classList.add("active");
|
document.querySelector(".playground-navigation__example:nth-child(1)").classList.add("active");
|
||||||
|
|
||||||
send(JSON.stringify({
|
send({
|
||||||
message: "landed on playground"
|
message: "landed on playground"
|
||||||
}));
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".playground-navigation__example:nth-child(1)").click();
|
document.querySelector(".playground-navigation__example:nth-child(1)").click();
|
||||||
|
@ -146,12 +146,12 @@ function fetchMetadata(exampleNumber, data) {
|
||||||
|
|
||||||
switch(exampleNumber) {
|
switch(exampleNumber) {
|
||||||
case 1:
|
case 1:
|
||||||
send(JSON.stringify({
|
send({
|
||||||
claim: data,
|
claim: data,
|
||||||
message: "fetch metadata",
|
message: "fetch metadata",
|
||||||
method: "resolve",
|
method: "resolve",
|
||||||
example: exampleNumber
|
example: exampleNumber
|
||||||
}));
|
});
|
||||||
|
|
||||||
document.getElementById("fetch-claim-uri").value = data;
|
document.getElementById("fetch-claim-uri").value = data;
|
||||||
document.getElementById("playground-results").innerHTML = playgroundResponseForExample1(data);
|
document.getElementById("playground-results").innerHTML = playgroundResponseForExample1(data);
|
||||||
|
@ -159,24 +159,24 @@ function fetchMetadata(exampleNumber, data) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
send(JSON.stringify({
|
send({
|
||||||
data: data,
|
data: data,
|
||||||
message: "fetch metadata",
|
message: "fetch metadata",
|
||||||
method: "publish",
|
method: "publish",
|
||||||
example: exampleNumber
|
example: exampleNumber
|
||||||
}));
|
});
|
||||||
|
|
||||||
document.getElementById("playground-results").innerHTML = playgroundResponseForExample2(getMemeInfo());
|
document.getElementById("playground-results").innerHTML = playgroundResponseForExample2(getMemeInfo());
|
||||||
document.getElementById("playground-loader").style.display = "none";
|
document.getElementById("playground-loader").style.display = "none";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
send(JSON.stringify({
|
send({
|
||||||
claim: data,
|
claim: data,
|
||||||
message: "fetch metadata",
|
message: "fetch metadata",
|
||||||
method: "claim_tip",
|
method: "claim_tip",
|
||||||
example: exampleNumber
|
example: exampleNumber
|
||||||
}));
|
});
|
||||||
|
|
||||||
document.getElementById("fetch-claim-uri").value = data;
|
document.getElementById("fetch-claim-uri").value = data;
|
||||||
document.getElementById("playground-results").innerHTML = playgroundResponseForExample3(data);
|
document.getElementById("playground-results").innerHTML = playgroundResponseForExample3(data);
|
||||||
|
@ -279,9 +279,9 @@ const handleExamples = debounce(event => {
|
||||||
document.getElementById("playground-loader").removeAttribute("style");
|
document.getElementById("playground-loader").removeAttribute("style");
|
||||||
document.getElementById("playground-results").removeAttribute("style");
|
document.getElementById("playground-results").removeAttribute("style");
|
||||||
|
|
||||||
send(JSON.stringify({
|
send({
|
||||||
message: `request for ${data.action}`
|
message: `request for ${data.action}`
|
||||||
}));
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -305,9 +305,9 @@ const handleExamples = debounce(event => {
|
||||||
document.getElementById("playground-loader").removeAttribute("style");
|
document.getElementById("playground-loader").removeAttribute("style");
|
||||||
document.getElementById("playground-results").removeAttribute("style");
|
document.getElementById("playground-results").removeAttribute("style");
|
||||||
|
|
||||||
send(JSON.stringify({
|
send({
|
||||||
message: `request for ${data.action}`
|
message: `request for ${data.action}`
|
||||||
}));
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -334,9 +334,9 @@ const handleExamples = debounce(event => {
|
||||||
document.getElementById("playground-loader").removeAttribute("style");
|
document.getElementById("playground-loader").removeAttribute("style");
|
||||||
document.getElementById("playground-results").removeAttribute("style");
|
document.getElementById("playground-results").removeAttribute("style");
|
||||||
|
|
||||||
send(JSON.stringify({
|
send({
|
||||||
message: `request for ${data.action}`
|
message: `request for ${data.action}`
|
||||||
}));
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
4
app/dist/scripts/app.js
vendored
4
app/dist/scripts/app.js
vendored
|
@ -63,10 +63,10 @@ document.querySelector("[data-action='subscribe to newsletter']").onclick = () =
|
||||||
|
|
||||||
document.getElementById("emailMessage").classList.remove("error");
|
document.getElementById("emailMessage").classList.remove("error");
|
||||||
|
|
||||||
send(JSON.stringify({
|
send({
|
||||||
email: email,
|
email: email,
|
||||||
message: "subscribe"
|
message: "subscribe"
|
||||||
}));
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -336,12 +336,21 @@ function generateUrl(type, event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGitHubUserToken() {
|
async function getGitHubUserToken() {
|
||||||
// const clientWithAuth = new Octokit({
|
// const clientWithAuth = new Octokit({
|
||||||
// auth: `token ${GITHUB_APP_TOKEN}`
|
// auth: `token ${process.env.GITHUB_APP_TOKEN}`
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// console.log(clientWithAuth);
|
const result = await octokit.oauthAuthorizations.createAuthorization({ // eslint-disable-line no-unused-vars
|
||||||
|
client_id: process.env.GITHUB_APP_ID,
|
||||||
|
client_secret: process.env.GITHUB_APP_TOKEN,
|
||||||
|
note: "LBRY Developer Auth",
|
||||||
|
scopes: [
|
||||||
|
"public_repo"
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log(result);
|
||||||
// console.log("—————");
|
// console.log("—————");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,8 +364,10 @@ function updateGithubFeed() {
|
||||||
const eventString = JSON.stringify(item);
|
const eventString = JSON.stringify(item);
|
||||||
|
|
||||||
client.zrank("events", eventString, (err, reply) => {
|
client.zrank("events", eventString, (err, reply) => {
|
||||||
if (reply === null) client.zadd("events", item.id, eventString, callback);
|
if (reply === null)
|
||||||
else callback();
|
client.zadd("events", item.id, eventString, callback);
|
||||||
|
else
|
||||||
|
callback();
|
||||||
});
|
});
|
||||||
}, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events
|
}, () => client.zremrangebyrank("events", 0, -51)); // Keep the latest 50 events
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,7 +10,7 @@ import html from "choo/html";
|
||||||
// U T I L S
|
// U T I L S
|
||||||
|
|
||||||
import fetchMetadata from "@helper/fetch-metadata";
|
import fetchMetadata from "@helper/fetch-metadata";
|
||||||
import { generateGitHubFeed } from "@helper/github";
|
import { generateGitHubFeed, getGitHubUserToken } from "@helper/github";
|
||||||
import messageSlack from "@helper/slack";
|
import messageSlack from "@helper/slack";
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,9 +21,11 @@ export default (socket, action) => {
|
||||||
if (typeof socket !== "object" && typeof action !== "object")
|
if (typeof socket !== "object" && typeof action !== "object")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
action = JSON.parse(action);
|
|
||||||
|
|
||||||
switch(true) {
|
switch(true) {
|
||||||
|
case action.message === "auth me with github":
|
||||||
|
getGitHubUserToken();
|
||||||
|
break;
|
||||||
|
|
||||||
case action.message === "fetch metadata":
|
case action.message === "fetch metadata":
|
||||||
fetchMetadata(action, socket);
|
fetchMetadata(action, socket);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// I M P O R T
|
|
||||||
|
|
||||||
import html from "choo/html";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// E X P O R T
|
|
||||||
|
|
||||||
export default () => html`
|
|
||||||
<article class="page" itemtype="http://schema.org/BlogPosting">
|
|
||||||
<header class="page__header">
|
|
||||||
<div class="page__header-wrap">
|
|
||||||
<div class="inner-wrap">
|
|
||||||
<h1 class="page__header__title" itemprop="name headline">Developer Program</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<section class="page__content page__markup" itemprop="articleBody">
|
|
||||||
<div class="inner-wrap">
|
|
||||||
<p>When developing for LBRY, having LBC (LBRY credits) makes it easier to develop applications and interface with our APIs.</p>
|
|
||||||
<p>To qualify for free LBC you must:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>have a GitHub account, and</li>
|
|
||||||
<li>have a public PR (pull request) in the past year</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>If this sounds like you, <a href="#" class="no-smooth" id="get-started">get started here</a>!</p>
|
|
||||||
|
|
||||||
<p><small>
|
|
||||||
If you have not downloaded our SDK yet, <a href="">you should</a> and generate a wallet address so we know where to send your LBC!
|
|
||||||
</small></p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</article>
|
|
||||||
`;
|
|
Loading…
Add table
Reference in a new issue