Skip to content

Commit

Permalink
Merge pull request #21 from pinax-network/feature/simply-auth
Browse files Browse the repository at this point in the history
expose keypair as HTTP endpoint
  • Loading branch information
DenisCarriere authored Feb 13, 2024
2 parents a361450 + d76e9a9 commit c5ef148
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ command.action(action);

program
.command("keypair")
.description("Generate TweetNaCl keypair")
.description("Generate random Ed25519 private & public keys")
.action(() => {
const { publicKey, privateKey } = keyPair();
console.log(`PUBLIC_KEY=${publicKey}`);
Expand Down
5 changes: 3 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { postWebhook } from "./src/postWebhook.js";
import type { SessionInit } from "@substreams/core/proto";
import type { WebhookRunOptions } from "./bin/cli.js";
import { banner } from "./src/banner.js";
import { toText } from "./src/http.js";
import { toJSON, toText } from "./src/http.js";
import { ping } from "./src/ping.js";
import { checkKey } from "./index.js";
import { checkKey, keyPair } from "./src/auth/ed25519.js";

export * from "./src/auth/ed25519.js";
export * from "./src/schemas.js";
Expand Down Expand Up @@ -73,6 +73,7 @@ export async function action(options: WebhookRunOptions) {
http.listen(options);
http.server.on("request", (req, res) => {
if (req.url === "/") return toText(res, banner());
if (req.url === "/keypair") return toJSON(res, keyPair());
});

emitter.on("close", () => {
Expand Down
5 changes: 4 additions & 1 deletion src/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export function banner() {
░░░╚═╝░░░╚═╝░░╚══════╝╚═════╝░╚═╝░░╚═╝░╚════╝░░╚════╝░╚═╝░░╚═╝╚═════╝░
`;
text += ` ${pkg.name} v${pkg.version}\n`;
text += ` ${pkg.name} v${pkg.version}\n\n`;
text += `HTTP routes\n`;
text += `GET /metrics\tPrometheus Metrics\n`;
text += `GET /keypair\tGenerate random Ed25519 private & public keys\n`;
return text;
}

0 comments on commit c5ef148

Please sign in to comment.