Skip to content

Commit d7eba6f

Browse files
committed
working gpg implementation (needs more testing)
check binary exists + more logging integrate gpg with postprocessing wrapper, standardise api bubble up error messages
1 parent eca5e2a commit d7eba6f

14 files changed

Lines changed: 598 additions & 578 deletions

File tree

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"date-fns": "^4.1.0",
5252
"debug": "^4.3.7",
5353
"hi-base32": "^0.5.1",
54+
"is-executable": "^2.0.1",
5455
"openpgp": "^6.2.2",
5556
"safe-stable-stringify": "^2.4.3",
5657
"toml": "^3.0.0",

src/config/Config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { ValidationRule } from "../validation/Validation";
1818
export namespace Config {
1919
export interface Column {
2020
name: string;
21-
alias: string;
21+
alias: string; // TODOL: make alias optional for programmatic usage
2222
default?: string | number | string[] | number[];
2323
}
2424
export interface ColumnMap {
@@ -47,7 +47,8 @@ export namespace Config {
4747
};
4848
post_processing?: {
4949
encryption?: {
50-
key_path: string;
50+
recipient: string;
51+
gpgBinaryPath?: string;
5152
}
5253
}
5354
}

src/config/validateConfig.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type ConfigValidator = (label: string, v: unknown) => ConfigValidatorResult;
3535

3636
const isTrue: ConfigValidator = (label: string, v: unknown) => (!v ? label : undefined);
3737
const isFalse: ConfigValidator = (label: string, v: unknown) => (!!v ? label : undefined);
38+
const isBoolean: ConfigValidator = (label: string, v: unknown) =>
39+
typeof v !== 'boolean' ? `${label} must be a boolean` : undefined;
3840
const isObject: ConfigValidator = (label: string, v: unknown) =>
3941
typeof v !== 'object' ? `Missing ${label}` : undefined;
4042
const isNumber: ConfigValidator = (label: string, v: unknown) =>
@@ -130,7 +132,8 @@ function checkPostProcessing(proc: Config.FileConfiguration["post_processing"])
130132

131133
const encryptionCheck =
132134
isOptional('[post_processing].encryption', proc.encryption, isObject) ||
133-
isString("[post_processing].encryption.key_path", proc.encryption?.key_path)
135+
isNotEmptyString("[post_processing].encryption.recipient", proc.encryption?.recipient) ||
136+
isOptional("[post_processing].encryption.gpgBinaryPath?", proc.encryption?.gpgBinaryPath, isNotEmptyString);
134137

135138
return encryptionCheck
136139
}

0 commit comments

Comments
 (0)