UNPKG

proca

Version:
35 lines (29 loc) 906 B
import crypto from "node:crypto"; import { Args, Flags } from "@oclif/core"; import { error, stdout, ux } from "@oclif/core/ux"; import Command from "#src/procaCommand.mjs"; export default class UserList extends Command { static description = "convert between token and sql value"; static flags = { token: Flags.string({ exactlyOne: ["token"], description: "the token in your config", helpValue: "API-xxx", }), }; async run() { const { args, flags } = await this.parse(); if (flags.token) { const token = flags.token .replace("API-", "") .replace(/-/g, "+") .replace(/_/g, "/"); const decoded = Buffer.from(token, "base64").toString("utf-8"); const hexa = crypto.createHash("sha256").update(decoded).digest("hex"); console.log(token, decoded, hexa); return this.output({ hexa: `\\x${hexa}` }); } const data = flags; return this.output(data); } }