dotsec 4.0.0-alpha.2 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.d.ts +2 -0
- package/dist/index.d.ts +210 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import Ajv from 'ajv';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
export { default as Table } from 'cli-table';
|
|
5
|
+
|
|
6
|
+
type DotsecCliPluginHandler<HandlerArgs extends Record<string, unknown>, HandlerResult, T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
7
|
+
encryptionEngineName?: string;
|
|
8
|
+
triggerOptionValue: string;
|
|
9
|
+
usage?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
summary?: string;
|
|
12
|
+
options?: {
|
|
13
|
+
[key in keyof T]: DotsecCliOption;
|
|
14
|
+
};
|
|
15
|
+
requiredOptions?: {
|
|
16
|
+
[key in keyof T]: DotsecCliOption;
|
|
17
|
+
};
|
|
18
|
+
handler: (options: HandlerArgs & T) => Promise<HandlerResult>;
|
|
19
|
+
};
|
|
20
|
+
type DotsecCliPluginEncryptHandler<HandlerPluginArgs extends Record<string, unknown> = Record<string, unknown>> = DotsecCliPluginHandler<{
|
|
21
|
+
plaintext: string;
|
|
22
|
+
}, string, HandlerPluginArgs>;
|
|
23
|
+
type DotsecCliPluginDecryptHandler<HandlerPluginArgs extends Record<string, unknown> = Record<string, unknown>> = DotsecCliPluginHandler<{
|
|
24
|
+
ciphertext: string;
|
|
25
|
+
}, string, HandlerPluginArgs>;
|
|
26
|
+
type DotsecCliPluginRunHandler<HandlerPluginArgs extends Record<string, unknown> = Record<string, unknown>> = DotsecCliPluginHandler<{
|
|
27
|
+
ciphertext: string;
|
|
28
|
+
}, string, HandlerPluginArgs>;
|
|
29
|
+
type DotsecCliPluginPushHandler<HandlerPluginArgs extends Record<string, unknown> = Record<string, unknown>> = DotsecCliPluginHandler<{
|
|
30
|
+
push: Record<string, string>;
|
|
31
|
+
yes?: boolean;
|
|
32
|
+
}, string, HandlerPluginArgs>;
|
|
33
|
+
type DotsecCliOption = [
|
|
34
|
+
flags: string,
|
|
35
|
+
description?: string,
|
|
36
|
+
defaultValue?: string | boolean | string[]
|
|
37
|
+
] | {
|
|
38
|
+
flags: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
defaultValue?: string | boolean | string[];
|
|
41
|
+
choices?: string[];
|
|
42
|
+
fn?: (value: string, previous: unknown) => unknown;
|
|
43
|
+
regexp?: RegExp;
|
|
44
|
+
env?: string;
|
|
45
|
+
};
|
|
46
|
+
type DotsecPluginConfig = {
|
|
47
|
+
name?: string;
|
|
48
|
+
config?: {
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
};
|
|
51
|
+
push?: {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type DotsecPlugins = {
|
|
56
|
+
plugins: DotsecPluginUserConfigWithNamespace;
|
|
57
|
+
};
|
|
58
|
+
type Meh<T extends DotsecPluginModuleConfig> = T extends DotsecPluginModuleConfig ? T : never;
|
|
59
|
+
type DotsecPluginModuleConfig = {
|
|
60
|
+
plugin: DotsecPluginUserConfigWithNamespace;
|
|
61
|
+
api?: Record<string, unknown>;
|
|
62
|
+
cliHandlersOptions?: {
|
|
63
|
+
encrypt?: Record<string, unknown>;
|
|
64
|
+
decrypt?: Record<string, unknown>;
|
|
65
|
+
run?: Record<string, unknown>;
|
|
66
|
+
push?: Record<string, unknown>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
type DotsecPluginModuleBuilderConfig = {
|
|
70
|
+
[key: string]: {
|
|
71
|
+
userConfig: DotsecPluginConfig;
|
|
72
|
+
api?: Record<string, unknown>;
|
|
73
|
+
cliHandlersOptions?: {
|
|
74
|
+
encrypt?: Record<string, unknown>;
|
|
75
|
+
decrypt?: Record<string, unknown>;
|
|
76
|
+
run?: Record<string, unknown>;
|
|
77
|
+
push?: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type DotsecPluginModule<T extends DotsecPluginModuleConfig = DotsecPluginModuleConfig> = (options: {
|
|
82
|
+
dotsecConfig: DotsecConfig<{
|
|
83
|
+
plugins: T["plugin"];
|
|
84
|
+
}>;
|
|
85
|
+
ajv: Ajv;
|
|
86
|
+
configFile: string;
|
|
87
|
+
}) => Promise<{
|
|
88
|
+
name: keyof T["plugin"] | string;
|
|
89
|
+
encryptionEngineName?: string;
|
|
90
|
+
api?: T["api"] extends Record<string, unknown> ? T["api"] : never;
|
|
91
|
+
addCliCommand?: (options: {
|
|
92
|
+
program: Command;
|
|
93
|
+
}) => Promise<void>;
|
|
94
|
+
cliHandlers?: {
|
|
95
|
+
encrypt?: DotsecCliPluginEncryptHandler<T["cliHandlersOptions"] extends {
|
|
96
|
+
encrypt: Record<string, unknown>;
|
|
97
|
+
} ? T["cliHandlersOptions"]["encrypt"] : Record<string, unknown>>;
|
|
98
|
+
decrypt?: DotsecCliPluginDecryptHandler<T["cliHandlersOptions"] extends {
|
|
99
|
+
decrypt: Record<string, unknown>;
|
|
100
|
+
} ? T["cliHandlersOptions"]["decrypt"] : Record<string, unknown>>;
|
|
101
|
+
run?: DotsecCliPluginRunHandler<T["cliHandlersOptions"] extends {
|
|
102
|
+
run: Record<string, unknown>;
|
|
103
|
+
} ? T["cliHandlersOptions"]["run"] : Record<string, unknown>>;
|
|
104
|
+
push?: DotsecCliPluginPushHandler<T["cliHandlersOptions"] extends {
|
|
105
|
+
push: Record<string, unknown>;
|
|
106
|
+
} ? T["cliHandlersOptions"]["push"] : Record<string, unknown>>;
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
type DotsecPluginModuleBuilder<T extends DotsecPluginModuleBuilderConfig = DotsecPluginModuleBuilderConfig> = {
|
|
110
|
+
[pluginName: string]: {
|
|
111
|
+
userConfig: T[keyof T]["userConfig"];
|
|
112
|
+
module: (options: {
|
|
113
|
+
dotsecConfig: DotsecConfig<{
|
|
114
|
+
plugins: {
|
|
115
|
+
[key in keyof T]: T[keyof T]["userConfig"];
|
|
116
|
+
};
|
|
117
|
+
}>;
|
|
118
|
+
ajv: Ajv;
|
|
119
|
+
configFile: string;
|
|
120
|
+
}) => Promise<{
|
|
121
|
+
name: keyof T["userConfig"] | string;
|
|
122
|
+
encryptionEngineName?: string;
|
|
123
|
+
api?: T["api"] extends Record<string, unknown> ? T["api"] : never;
|
|
124
|
+
addCliCommand?: (options: {
|
|
125
|
+
program: Command;
|
|
126
|
+
}) => Promise<void>;
|
|
127
|
+
cliHandlers?: {
|
|
128
|
+
encrypt?: DotsecCliPluginEncryptHandler<T["cliHandlersOptions"] extends {
|
|
129
|
+
encrypt: Record<string, unknown>;
|
|
130
|
+
} ? T["cliHandlersOptions"]["encrypt"] : Record<string, unknown>>;
|
|
131
|
+
decrypt?: DotsecCliPluginDecryptHandler<T["cliHandlersOptions"] extends {
|
|
132
|
+
decrypt: Record<string, unknown>;
|
|
133
|
+
} ? T["cliHandlersOptions"]["decrypt"] : Record<string, unknown>>;
|
|
134
|
+
run?: DotsecCliPluginRunHandler<T["cliHandlersOptions"] extends {
|
|
135
|
+
run: Record<string, unknown>;
|
|
136
|
+
} ? T["cliHandlersOptions"]["run"] : Record<string, unknown>>;
|
|
137
|
+
push?: DotsecCliPluginPushHandler<T["cliHandlersOptions"] extends {
|
|
138
|
+
push: Record<string, unknown>;
|
|
139
|
+
} ? T["cliHandlersOptions"]["push"] : Record<string, unknown>>;
|
|
140
|
+
};
|
|
141
|
+
}>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
type DotsecPluginUserConfigWithNamespace<T extends {
|
|
145
|
+
[key: string]: DotsecPluginConfig;
|
|
146
|
+
} = {
|
|
147
|
+
[key: string]: DotsecPluginConfig;
|
|
148
|
+
}> = T;
|
|
149
|
+
|
|
150
|
+
type DotsecConfig<T extends DotsecPlugins = DotsecPlugins> = {
|
|
151
|
+
plugins?: Array<keyof T["plugins"]>;
|
|
152
|
+
defaults?: {
|
|
153
|
+
encryptionEngine?: keyof T["plugins"];
|
|
154
|
+
plugins?: {
|
|
155
|
+
[PluginKey in keyof T["plugins"]]?: {
|
|
156
|
+
name?: T["plugins"][PluginKey]["name"];
|
|
157
|
+
} & T["plugins"][PluginKey]["config"];
|
|
158
|
+
};
|
|
159
|
+
options?: {
|
|
160
|
+
envFile?: string;
|
|
161
|
+
secFile?: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
push?: {
|
|
165
|
+
[key: string]: {
|
|
166
|
+
[PluginKey in keyof T["plugins"]]?: T["plugins"][PluginKey]["push"];
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
type DotsecEncryptionEngineFactoryProps = {
|
|
172
|
+
verbose?: boolean;
|
|
173
|
+
};
|
|
174
|
+
type DotsecEncryptionEngine<T = Record<string, unknown>> = {
|
|
175
|
+
encrypt(plaintext: string): Promise<string>;
|
|
176
|
+
decrypt(ciphertext: string): Promise<string>;
|
|
177
|
+
} & T;
|
|
178
|
+
type DotsecEncryptionEngineFactory<T = Record<string, unknown>, V extends Record<string, unknown> = Record<string, unknown>> = {
|
|
179
|
+
(options: DotsecEncryptionEngineFactoryProps & T): Promise<DotsecEncryptionEngine<V>>;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
type FromEnv<T extends string = string> = T | {
|
|
183
|
+
fromEnv: string;
|
|
184
|
+
required?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
declare const promptExecute: ({ skip, message, execute, }: {
|
|
188
|
+
skip?: boolean | undefined;
|
|
189
|
+
message: string;
|
|
190
|
+
execute: () => unknown | Promise<unknown>;
|
|
191
|
+
}) => Promise<void>;
|
|
192
|
+
|
|
193
|
+
declare const resolveFromEnv: (options: {
|
|
194
|
+
fromEnvValue?: string;
|
|
195
|
+
env: NodeJS.ProcessEnv;
|
|
196
|
+
variables: Record<string, string>;
|
|
197
|
+
}) => string | undefined;
|
|
198
|
+
|
|
199
|
+
declare const readContentsFromFile: (filePath: string) => Promise<string>;
|
|
200
|
+
declare const writeContentsToFile: (filePath: string, contents: string) => Promise<void>;
|
|
201
|
+
declare const promptOverwriteIfFileExists: ({ filePath, skip, }: {
|
|
202
|
+
filePath: string;
|
|
203
|
+
skip?: boolean | undefined;
|
|
204
|
+
}) => Promise<prompts.Answers<"overwrite"> | undefined>;
|
|
205
|
+
|
|
206
|
+
declare const writeLine: (str: string) => void;
|
|
207
|
+
declare const emphasis: (str: string) => string;
|
|
208
|
+
declare const strong: (str: string) => string;
|
|
209
|
+
|
|
210
|
+
export { DotsecConfig, DotsecEncryptionEngine, DotsecEncryptionEngineFactory, DotsecEncryptionEngineFactoryProps, DotsecPluginModule, DotsecPluginModuleBuilder, DotsecPluginModuleBuilderConfig, DotsecPluginUserConfigWithNamespace, FromEnv, Meh, emphasis, promptExecute, promptOverwriteIfFileExists, readContentsFromFile, resolveFromEnv, strong, writeContentsToFile, writeLine };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dotsec",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"typescript": "~4.9.3",
|
|
63
63
|
"yargs-parser": "^21.1.1"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "7424686ad3816cc16d138a3417533f33134d3b87"
|
|
66
66
|
}
|