Skip to content

Commit

Permalink
Add auth headers cmd for local dev (#3852)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheran-senthil authored Sep 19, 2022
1 parent d9a7b36 commit e12947e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dev-tools/commands/src/auth-headers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import chalk from "chalk";
import { program } from "commander";

import { initializeAudiusLibs } from "./utils.mjs";

program.command("auth-headers")
.description("Output auth headers (for use with curl: `curl -H @<(audius-cmd auth-headers)`)")
.option("[account]", "The account to for which to generate auth headers")
.action(async (account) => {
const audiusLibs = await initializeAudiusLibs(account);

try {
const unixTimestamp = Math.round(new Date.getTime() / 1000);
const message = `Click sign to authenticate with identity service: ${unixTimestamp}`;
const signature = audiusLibs.web3Manager.sign(message);

console.log(chalk.yellow("Encoded-Data-Message:"), message);
console.log(chalk.yellow("Encoded-Data-Signature:"), signature);
} catch (err) {
program.error(err.message);
}

process.exit(0);
});
1 change: 1 addition & 0 deletions dev-tools/commands/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "./repost-track.mjs";
import "./repost-playlist.mjs";
import "./tip-audio.mjs";
import "./unfollow.mjs";
import "./auth-headers.mjs";

async function main() {
program.parseAsync(process.argv);
Expand Down

0 comments on commit e12947e

Please sign in to comment.