update mods
This commit is contained in:
@@ -675,7 +675,7 @@ class Logger {
|
|||||||
_debug: boolean = false;
|
_debug: boolean = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._debug = osEnv("LOGGER") === '*';
|
this._debug = osEnv("LOGGER") === "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
@@ -960,8 +960,11 @@ export function encodeBase64Url(
|
|||||||
export async function getKeyRingPassword(
|
export async function getKeyRingPassword(
|
||||||
service: string,
|
service: string,
|
||||||
user: string,
|
user: string,
|
||||||
): string | null {
|
): Promise<string | null> {
|
||||||
const keyRingArgs = ["-g", "--json", "-S", service, "-U", user];
|
const keyRingArgs = ["-g", "--json", "-U", user];
|
||||||
|
if (service) {
|
||||||
|
keyRingArgs.push(...["-S", service]);
|
||||||
|
}
|
||||||
const processOutput = await execCommand("keyring.rs", keyRingArgs);
|
const processOutput = await execCommand("keyring.rs", keyRingArgs);
|
||||||
const stdoutString = processOutput.getStdoutAsStringThenTrim();
|
const stdoutString = processOutput.getStdoutAsStringThenTrim();
|
||||||
const stderrString = processOutput.getStderrAsStringThenTrim();
|
const stderrString = processOutput.getStderrAsStringThenTrim();
|
||||||
@@ -983,8 +986,11 @@ export async function setKeyRingPassword(
|
|||||||
service: string,
|
service: string,
|
||||||
user: string,
|
user: string,
|
||||||
password: string,
|
password: string,
|
||||||
): void {
|
): Promise<void> {
|
||||||
const keyRingArgs = ["-s", "-S", service, "-U", user, "-P", password];
|
const keyRingArgs = ["-s", "-U", user, "-P", password];
|
||||||
|
if (service) {
|
||||||
|
keyRingArgs.push(...["-S", service]);
|
||||||
|
}
|
||||||
const processOutput = await execCommand("keyring.rs", keyRingArgs);
|
const processOutput = await execCommand("keyring.rs", keyRingArgs);
|
||||||
const stdoutString = processOutput.getStdoutAsStringThenTrim();
|
const stdoutString = processOutput.getStdoutAsStringThenTrim();
|
||||||
const stderrString = processOutput.getStderrAsStringThenTrim();
|
const stderrString = processOutput.getStderrAsStringThenTrim();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {execCommand} from "https://global.hatter.ink/script/get/@18/deno-commons-mod.ts";
|
import {execCommand, getKeyRingPassword,} from "https://global.hatter.ink/script/get/@47/deno-commons-mod.ts";
|
||||||
import {encodeHex} from "jsr:@std/encoding/hex";
|
import {encodeHex} from "jsr:@std/encoding/hex";
|
||||||
|
|
||||||
// example output
|
// example output
|
||||||
@@ -18,20 +18,37 @@ interface CardPivEcSignOutput {
|
|||||||
slot: string;
|
slot: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SignPivOptions {
|
||||||
|
pin?: string;
|
||||||
|
service?: string;
|
||||||
|
user?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function signPivString(
|
||||||
|
slot: string,
|
||||||
|
message: string,
|
||||||
|
options?: SignPivOptions,
|
||||||
|
): Promise<CardPivEcSignOutput> {
|
||||||
|
return await signPiv(slot, await sha256AndHexMessage(message), options);
|
||||||
|
}
|
||||||
|
|
||||||
export async function signPiv(
|
export async function signPiv(
|
||||||
slot: string,
|
slot: string,
|
||||||
digestSha256Hex: string,
|
digestSha256Hex: string,
|
||||||
|
options?: SignPivOptions,
|
||||||
): Promise<CardPivEcSignOutput> {
|
): Promise<CardPivEcSignOutput> {
|
||||||
const processOutput = await execCommand("card-cli", [
|
if (!options?.pin && options?.user) {
|
||||||
"piv-ecsign",
|
options.pin = await getKeyRingPassword(
|
||||||
"-s",
|
options.service,
|
||||||
slot,
|
options.user,
|
||||||
"-x",
|
);
|
||||||
digestSha256Hex,
|
}
|
||||||
"--json",
|
const args = ["piv-ecsign", "-s", slot, "-x", digestSha256Hex, "--json"];
|
||||||
]);
|
if (options?.pin) {
|
||||||
processOutput.assertSuccess();
|
args.push(...["--pin", options?.pin]);
|
||||||
return JSON.parse(processOutput.stdout) as CardPivEcSignOutput;
|
}
|
||||||
|
return (await execCommand("card-cli", args))
|
||||||
|
.assertSuccess().stdoutAsJson() as CardPivEcSignOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sha256AndHexMessage(message: string): Promise<string> {
|
export async function sha256AndHexMessage(message: string): Promise<string> {
|
||||||
|
|||||||
Reference in New Issue
Block a user