From 6f0d4cabcdd3cae8d25d15e3d2eb09306e38a11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Tue, 31 May 2022 20:32:48 +0200 Subject: [PATCH] scaffold --- .gitignore | 2 ++ .vscode/settings.json | 4 ++-- cli.ts | 2 +- config/run.flags | 1 + hashing.ts | 20 ++++++++++---------- run | 19 +++++++++++++++++++ 6 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 config/run.flags create mode 100755 run diff --git a/.gitignore b/.gitignore index d69a4c0..8b7abdc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ deno.d.ts .vscode .local +.output +web/*.js diff --git a/.vscode/settings.json b/.vscode/settings.json index b943dbc..cbac569 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "deno.enable": true -} \ No newline at end of file + "deno.enable": true +} diff --git a/cli.ts b/cli.ts index aca19db..2a2d863 100755 --- a/cli.ts +++ b/cli.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S deno run --allow-run --allow-read --allow-env +#!./run import { showZenityUI } from "./ui/zenity.ts"; if (import.meta.main) { diff --git a/config/run.flags b/config/run.flags new file mode 100644 index 0000000..c44892d --- /dev/null +++ b/config/run.flags @@ -0,0 +1 @@ +--allow-env=CWD,HOME --allow-read=.local/config.json --allow-run=zenity,xclip diff --git a/hashing.ts b/hashing.ts index 989e9b9..05f5834 100644 --- a/hashing.ts +++ b/hashing.ts @@ -53,15 +53,15 @@ export class Hasher { } /** - * Get the default params - */ + * Get the default params + */ static getDefaultParams(): HashParams { return { mode: HashOutputMode.ALNUM, length: 12 }; } /** - * Parse hashing params (character class and length) from a string - */ + * Parse hashing params (character class and length) from a string + */ static parseParams(input: string): HashParams { let params = this.getDefaultParams(); @@ -84,8 +84,8 @@ export class Hasher { } /** - * Try hashing an input string. - */ + * Try hashing an input string. + */ tryHashing(input: string): string | null { if (input.length > 1 && input.charAt(input.length - 1) == "#") { let base = input.substr(0, input.length - 1); @@ -112,8 +112,8 @@ export class Hasher { } /** - * Get a final hashed password, from a list of options. - */ + * Get a final hashed password, from a list of options. + */ getHash(base: string, site: string, params: HashParams): string { // Hash the site name against the private key, to obtain a site key let site_key = this.generateHashWord( @@ -268,7 +268,7 @@ export class Hasher { s += sInput.substring(i, i + j); } s += String.fromCharCode((seed + i) % 26 + 65); - i += (j + 1); + i += j + 1; } if (i < sInput.length) { @@ -296,7 +296,7 @@ export class Hasher { s += sInput.substring(i, i + j); } s += String.fromCharCode((seed + sInput.charCodeAt(i)) % 10 + 48); - i += (j + 1); + i += j + 1; } if (i < sInput.length) { diff --git a/run b/run new file mode 100755 index 0000000..74d1c6d --- /dev/null +++ b/run @@ -0,0 +1,19 @@ +#!/bin/sh +# Simplified run tool for deno commands + +if test $# -eq 0 +then + echo "Usage: $0 [file or command]" + exit 1 +elif echo $1 | grep -q '.*.ts' +then + denocmd=run + denoargs=$1 + shift +else + denocmd=$1 + shift +fi + +denoargs="$(cat config/$denocmd.flags 2> /dev/null) $denoargs $@" +exec deno $denocmd $denoargs