-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auth headers cmd for local dev (#3852)
- Loading branch information
1 parent
d9a7b36
commit e12947e
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters