@typinghare/trick 1.0.6 → 2.0.0

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.
Files changed (41) hide show
  1. package/README.md +86 -0
  2. package/dist/app.d.ts +1 -1
  3. package/dist/app.js +79 -89
  4. package/dist/config.d.ts +71 -14
  5. package/dist/config.js +62 -25
  6. package/dist/encrypt.d.ts +68 -14
  7. package/dist/encrypt.js +77 -28
  8. package/dist/error.d.ts +30 -0
  9. package/dist/error.js +69 -0
  10. package/dist/index.d.ts +1 -2
  11. package/dist/index.js +1 -2
  12. package/dist/passphrase.d.ts +13 -0
  13. package/dist/passphrase.js +26 -0
  14. package/eslint.config.js +41 -0
  15. package/package.json +23 -12
  16. package/src/app.ts +110 -125
  17. package/src/config.ts +96 -31
  18. package/src/encrypt.ts +89 -44
  19. package/src/error.ts +82 -0
  20. package/src/index.ts +1 -2
  21. package/src/passphrase.ts +39 -0
  22. package/test/resources/really.json +2 -2
  23. package/test/resources/task.yml +3 -4
  24. package/test/trick.config.json +13 -0
  25. package/.prettierrc.yaml +0 -6
  26. package/.wander/jameschan312.cn@gmail.com/.idea/codeStyles/Project.xml +0 -52
  27. package/.wander/jameschan312.cn@gmail.com/.idea/codeStyles/codeStyleConfig.xml +0 -5
  28. package/.wander/jameschan312.cn@gmail.com/.idea/jsLibraryMappings.xml +0 -6
  29. package/.wander/jameschan312.cn@gmail.com/.idea/misc.xml +0 -6
  30. package/.wander/jameschan312.cn@gmail.com/.idea/modules.xml +0 -8
  31. package/.wander/jameschan312.cn@gmail.com/.idea/prettier.xml +0 -6
  32. package/.wander/jameschan312.cn@gmail.com/.idea/trick.iml +0 -14
  33. package/.wander/jameschan312.cn@gmail.com/.idea/vcs.xml +0 -6
  34. package/.wander/jameschan312.cn@gmail.com/.idea/webResources.xml +0 -14
  35. package/dist/constant.d.ts +0 -2
  36. package/dist/constant.js +0 -3
  37. package/dist/secret.d.ts +0 -5
  38. package/dist/secret.js +0 -14
  39. package/src/constant.ts +0 -4
  40. package/src/secret.ts +0 -14
  41. package/trick.config.json +0 -20
package/src/encrypt.ts CHANGED
@@ -1,29 +1,29 @@
1
1
  import { execa } from 'execa'
2
2
  import * as path from 'node:path'
3
3
  import fsExtra from 'fs-extra'
4
+ import { FailToDecryptFileError, FailToEncryptFileError } from './error.js'
4
5
 
5
- export class FailToEncryptFileError extends Error {
6
- public constructor(
7
- public readonly srcFilePath: string,
8
- public readonly opensslErrMessage?: string
9
- ) {
10
- super(`Fail to encrypt source file: ${srcFilePath}`)
11
- }
12
- }
13
-
14
- export class FailToDecryptFileError extends Error {
15
- public constructor(
16
- public readonly destFilePath: string,
17
- public readonly opensslErrMessage?: string
18
- ) {
19
- super(`Fail to decrypt destination file: ${destFilePath}`)
20
- }
21
- }
22
-
6
+ /**
7
+ * Encrypts a file using OpenSSL with AES-256-CBC and PBKDF2 key derivation.
8
+ *
9
+ * This function checks whether the source file exists, constructs an OpenSSL
10
+ * command, ensures the destination directory exists, and then executes the
11
+ * encryption command.
12
+ *
13
+ * @param srcFilePath The path to the source file that needs to be encrypted.
14
+ * @param destFilePath The path where the encrypted file will be saved.
15
+ * @param passphrase The passphrase used for encryption.
16
+ * @param iteration_count The number of iterations to use for PBKDF2.
17
+ * @returns Resolves when the file is successfully encrypted.
18
+ * @throws {FailToEncryptFileError} If the source file does not exist or if
19
+ * OpenSSL returns an error during encryption.
20
+ * @throws {FailToDecryptFileError} If an unknown error occurs during
21
+ * encryption.
22
+ */
23
23
  export async function encryptFile(
24
24
  srcFilePath: string,
25
25
  destFilePath: string,
26
- secret: string,
26
+ passphrase: string,
27
27
  iteration_count: number
28
28
  ): Promise<void> {
29
29
  if (!(await fsExtra.pathExists(srcFilePath))) {
@@ -37,13 +37,13 @@ export async function encryptFile(
37
37
  '-salt',
38
38
  '-pbkdf2',
39
39
  '-iter',
40
- iteration_count,
40
+ Number(iteration_count),
41
41
  '-in',
42
42
  srcFilePath,
43
43
  '-out',
44
44
  destFilePath,
45
45
  '-pass',
46
- `'pass:${secret}'`,
46
+ `'pass:${passphrase}'`,
47
47
  ].join(' ')
48
48
 
49
49
  await fsExtra.ensureDir(path.dirname(destFilePath))
@@ -52,14 +52,8 @@ export async function encryptFile(
52
52
  await execa(`${command}`, { shell: true })
53
53
  } catch (err) {
54
54
  if (typeof err == 'object' && err && Object.hasOwn(err, 'stderr')) {
55
- throw new FailToEncryptFileError(
56
- srcFilePath,
57
- (
58
- err as {
59
- stderr: string
60
- }
61
- ).stderr
62
- )
55
+ const error = err as { stderr: string }
56
+ throw new FailToEncryptFileError(srcFilePath, error.stderr)
63
57
  } else {
64
58
  throw new FailToDecryptFileError(
65
59
  srcFilePath,
@@ -69,10 +63,27 @@ export async function encryptFile(
69
63
  }
70
64
  }
71
65
 
66
+ /**
67
+ * Decrypts a file using OpenSSL with AES-256-CBC and PBKDF2 key derivation.
68
+ *
69
+ * This function checks whether the encrypted file exists, constructs an OpenSSL
70
+ * decryption command, ensures the destination directory exists, and then
71
+ * executes the decryption command.
72
+ *
73
+ * @param srcFilePath The path where the decrypted file will be saved.
74
+ * @param destFilePath The path to the encrypted source file.
75
+ * @param passphrase The passphrase used for decryption.
76
+ * @param iteration_count The number of iterations used for PBKDF2.
77
+ * @returns Resolves when the file is successfully decrypted.
78
+ * @throws {FailToDecryptFileError} If the encrypted file does not exist or if
79
+ * OpenSSL returns an error during decryption.
80
+ * @throws {FailToDecryptFileError} If an unknown error occurs during
81
+ * decryption.
82
+ */
72
83
  export async function decryptFile(
73
84
  srcFilePath: string,
74
85
  destFilePath: string,
75
- secret: string,
86
+ passphrase: string,
76
87
  iteration_count: number
77
88
  ): Promise<void> {
78
89
  if (!(await fsExtra.pathExists(destFilePath))) {
@@ -87,13 +98,13 @@ export async function decryptFile(
87
98
  '-salt',
88
99
  '-pbkdf2',
89
100
  '-iter',
90
- iteration_count,
101
+ Number(iteration_count),
91
102
  '-in',
92
103
  destFilePath,
93
104
  '-out',
94
105
  srcFilePath,
95
106
  '-pass',
96
- `'pass:${secret}'`,
107
+ `'pass:${passphrase}'`,
97
108
  ].join(' ')
98
109
 
99
110
  await fsExtra.ensureDir(path.dirname(srcFilePath))
@@ -102,14 +113,8 @@ export async function decryptFile(
102
113
  await execa(`${command}`, { shell: true })
103
114
  } catch (err) {
104
115
  if (typeof err == 'object' && err && Object.hasOwn(err, 'stderr')) {
105
- throw new FailToDecryptFileError(
106
- srcFilePath,
107
- (
108
- err as {
109
- stderr: string
110
- }
111
- )['stderr']
112
- )
116
+ const error = err as { stderr: string }
117
+ throw new FailToDecryptFileError(srcFilePath, error.stderr)
113
118
  } else {
114
119
  throw new FailToDecryptFileError(
115
120
  srcFilePath,
@@ -119,28 +124,68 @@ export async function decryptFile(
119
124
  }
120
125
  }
121
126
 
127
+ /**
128
+ * Encrypts multiple files using OpenSSL with AES-256-CBC and PBKDF2 key
129
+ * derivation.
130
+ *
131
+ * For each source file path provided, this function constructs the destination
132
+ * file path by appending `.enc`, then calls `encryptFile` and logs the
133
+ * operation.
134
+ *
135
+ * @param srcFilePaths An array of file paths to be encrypted.
136
+ * @param destDir The directory where the encrypted files will be saved.
137
+ * @param passphrase The passphrase used for encryption.
138
+ * @param iteration_count The number of iterations to use for PBKDF2.
139
+ * @returns Resolves when all files are successfully encrypted.
140
+ * @throws {FailToEncryptFileError} If any file fails to encrypt.
141
+ */
122
142
  export async function encryptFiles(
123
143
  srcFilePaths: string[],
124
144
  destDir: string,
125
- secret: string,
145
+ passphrase: string,
126
146
  iteration_count: number
127
147
  ): Promise<void> {
128
148
  for (const srcFilePath of srcFilePaths) {
129
149
  const destFilePath: string = path.join(destDir, srcFilePath + '.enc')
130
- await encryptFile(srcFilePath, destFilePath, secret, iteration_count)
150
+ await encryptFile(
151
+ srcFilePath,
152
+ destFilePath,
153
+ passphrase,
154
+ iteration_count
155
+ )
131
156
  console.log(`[ENCRYPTED] ${srcFilePath} -> ${destFilePath}`)
132
157
  }
133
158
  }
134
159
 
160
+ /**
161
+ * Decrypts multiple files using OpenSSL with AES-256-CBC and PBKDF2 key
162
+ * derivation.
163
+ *
164
+ * For each source file path provided, this function assumes the corresponding
165
+ * encrypted file has the `.enc` extension and calls `decryptFile`, logging the
166
+ * operation.
167
+ *
168
+ * @param srcFilePaths An array of original file paths that were encrypted.
169
+ * @param destDir The directory containing the encrypted files.
170
+ * @param passphrase The passphrase used for decryption.
171
+ * @param iteration_count The number of iterations used for PBKDF2.
172
+ * @returns Resolves when all files are successfully decrypted.
173
+ * @throws {FailToDecryptFileError} If any file fails to decrypt.
174
+ */
135
175
  export async function decryptFiles(
136
176
  srcFilePaths: string[],
137
177
  destDir: string,
138
- secret: string,
178
+ passphrase: string,
139
179
  iteration_count: number
140
180
  ): Promise<void> {
141
181
  for (const srcFilePath of srcFilePaths) {
142
182
  const destFilePath: string = path.join(destDir, srcFilePath + '.enc')
143
- await decryptFile(srcFilePath, destFilePath, secret, iteration_count)
183
+ await decryptFile(
184
+ srcFilePath,
185
+ destFilePath,
186
+ passphrase,
187
+ iteration_count
188
+ )
144
189
  console.log(`[DECRYPTED] ${destFilePath} -> ${srcFilePath}`)
145
190
  }
146
191
  }
package/src/error.ts ADDED
@@ -0,0 +1,82 @@
1
+ import chalk from 'chalk'
2
+
3
+ export class WriteConfigError extends Error {
4
+ public constructor(err: any) {
5
+ super(`Fail to write the configuration file. ${err}`)
6
+ }
7
+ }
8
+
9
+ export class ReadConfigError extends Error {
10
+ public constructor(err: any) {
11
+ super(`Fail to read the configuration file: ${err}`)
12
+ }
13
+ }
14
+
15
+ export class TargetNotFoundError extends Error {
16
+ public constructor(public readonly targetName: string) {
17
+ super(`Target not found: ${targetName}`)
18
+ }
19
+ }
20
+
21
+ export class FailToEncryptFileError extends Error {
22
+ public constructor(
23
+ public readonly srcFilePath: string,
24
+ public readonly opensslErrMessage?: string
25
+ ) {
26
+ super(`Fail to encrypt source file: ${srcFilePath}`)
27
+ }
28
+ }
29
+
30
+ export class FailToDecryptFileError extends Error {
31
+ public constructor(
32
+ public readonly destFilePath: string,
33
+ public readonly opensslErrMessage?: string
34
+ ) {
35
+ super(`Fail to decrypt destination file: ${destFilePath}`)
36
+ }
37
+ }
38
+
39
+ export class PassphraseFileNotFoundError extends Error {
40
+ public constructor(public readonly passphraseFilePath: string) {
41
+ super(`Passphrase file not found: ${passphraseFilePath}`)
42
+ }
43
+ }
44
+
45
+ export class PassphraseNotFoundError extends Error {
46
+ public constructor(
47
+ public readonly passphraseFilePath: string,
48
+ public readonly targetName: string
49
+ ) {
50
+ super(
51
+ `Passphrase for target ${targetName} is not found in the passphrase file: ${passphraseFilePath}`
52
+ )
53
+ }
54
+ }
55
+
56
+ export function resolve_error(err: any): void {
57
+ if (!(err instanceof Error)) {
58
+ console.error(`Unknown error: ${err}`)
59
+ process.exit(2)
60
+ }
61
+
62
+ if (err.message) {
63
+ console.log(chalk.red(err.message))
64
+ }
65
+
66
+ if (
67
+ err instanceof FailToEncryptFileError ||
68
+ err instanceof FailToDecryptFileError
69
+ ) {
70
+ if (err.opensslErrMessage) {
71
+ console.error(chalk.red(err.opensslErrMessage))
72
+ }
73
+
74
+ console.error(
75
+ chalk.yellow(
76
+ 'Make sure the file exists and you have enough permission to access it.'
77
+ )
78
+ )
79
+ }
80
+
81
+ process.exit(1)
82
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './app.js'
2
2
  export * from './config.js'
3
- export * from './constant.js'
4
3
  export * from './encrypt.js'
5
- export * from './secret.js'
4
+ export * from './passphrase.js'
@@ -0,0 +1,39 @@
1
+ import { Config } from './config.js'
2
+ import fsExtra from 'fs-extra'
3
+ import {
4
+ PassphraseFileNotFoundError,
5
+ PassphraseNotFoundError,
6
+ } from './error.js'
7
+ import os from 'node:os'
8
+
9
+ /**
10
+ * Retrieves the passphrase from the passphrase file.
11
+ *
12
+ * First, gets the passphrase object from the passphrase file path specified in
13
+ * the configuration object. Second, gets and returns the passphrase associated
14
+ * with the given target name.
15
+ *
16
+ * @param config The configuration to use.
17
+ * @param targetName The name of the target.
18
+ * @return The passphrase associated with the target name.
19
+ */
20
+ export function getPassphrase(config: Config, targetName: string): string {
21
+ const passphraseFilePath = config.passphrase_file_path.replaceAll(
22
+ /~/g,
23
+ os.homedir()
24
+ )
25
+ if (!fsExtra.existsSync(passphraseFilePath)) {
26
+ throw new PassphraseFileNotFoundError(passphraseFilePath)
27
+ }
28
+
29
+ const passphraseObject = fsExtra.readJsonSync(passphraseFilePath) as {
30
+ [name: string]: string
31
+ }
32
+ const passphrase = passphraseObject[targetName] || null
33
+
34
+ if (passphrase === null) {
35
+ throw new PassphraseNotFoundError(passphraseFilePath, targetName)
36
+ }
37
+
38
+ return passphrase
39
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
- "message": "Ok",
3
- "userId": 123
2
+ "message": "Ok",
3
+ "userId": 123456
4
4
  }
@@ -1,4 +1,3 @@
1
- my_task:
2
- name: My Task
3
- time_unit: milliseconds
4
- time: 350
1
+ response:
2
+ message: Ok
3
+ userId: 123456
@@ -0,0 +1,13 @@
1
+ {
2
+ "targets": {
3
+ "MyTestTarget": {
4
+ "files": ["resources/really.json", "resources/task.yml"]
5
+ }
6
+ },
7
+ "default_target_name": "MyTestTarget",
8
+ "root_directory": ".trick",
9
+ "passphrase_file_path": "~/.config/trick_passphrase.json",
10
+ "encryption": {
11
+ "iteration_count": 100000
12
+ }
13
+ }
package/.prettierrc.yaml DELETED
@@ -1,6 +0,0 @@
1
- trailingComma: es5
2
- tabWidth: 4
3
- semi: false
4
- singleQuote: true
5
- endOfLine: lf
6
- printWidth: 80
@@ -1,52 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <option name="LINE_SEPARATOR" value="&#10;" />
4
- <option name="RIGHT_MARGIN" value="80" />
5
- <HTMLCodeStyleSettings>
6
- <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
7
- </HTMLCodeStyleSettings>
8
- <JSCodeStyleSettings version="0">
9
- <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
10
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
11
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
12
- <option name="USE_DOUBLE_QUOTES" value="false" />
13
- <option name="FORCE_QUOTE_STYlE" value="true" />
14
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
15
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
16
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
17
- </JSCodeStyleSettings>
18
- <TypeScriptCodeStyleSettings version="0">
19
- <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
20
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
21
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
22
- <option name="USE_DOUBLE_QUOTES" value="false" />
23
- <option name="FORCE_QUOTE_STYlE" value="true" />
24
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
25
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
26
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
27
- </TypeScriptCodeStyleSettings>
28
- <VueCodeStyleSettings>
29
- <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
30
- <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
31
- </VueCodeStyleSettings>
32
- <codeStyleSettings language="HTML">
33
- <option name="SOFT_MARGINS" value="80" />
34
- <indentOptions>
35
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
36
- </indentOptions>
37
- </codeStyleSettings>
38
- <codeStyleSettings language="JavaScript">
39
- <option name="SOFT_MARGINS" value="80" />
40
- </codeStyleSettings>
41
- <codeStyleSettings language="TypeScript">
42
- <option name="SOFT_MARGINS" value="80" />
43
- </codeStyleSettings>
44
- <codeStyleSettings language="Vue">
45
- <option name="SOFT_MARGINS" value="80" />
46
- <indentOptions>
47
- <option name="INDENT_SIZE" value="4" />
48
- <option name="TAB_SIZE" value="4" />
49
- </indentOptions>
50
- </codeStyleSettings>
51
- </code_scheme>
52
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="Node.js Core" />
5
- </component>
6
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="MarkdownSettingsMigration">
4
- <option name="stateVersion" value="1" />
5
- </component>
6
- </project>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/trick.iml" filepath="$PROJECT_DIR$/.idea/trick.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myConfigurationMode" value="AUTOMATIC" />
5
- </component>
6
- </project>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
6
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
- <excludeFolder url="file://$MODULE_DIR$/dist" />
8
- <excludeFolder url="file://$MODULE_DIR$/temp" />
9
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
10
- </content>
11
- <orderEntry type="inheritedJdk" />
12
- <orderEntry type="sourceFolder" forTests="false" />
13
- </component>
14
- </module>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="WebResourcesPaths">
4
- <contentEntries>
5
- <entry url="file://$PROJECT_DIR$">
6
- <entryData>
7
- <resourceRoots>
8
- <path value="file://$PROJECT_DIR$/src" />
9
- </resourceRoots>
10
- </entryData>
11
- </entry>
12
- </contentEntries>
13
- </component>
14
- </project>
@@ -1,2 +0,0 @@
1
- export declare const TRICK_ROOT_DIR = ".trick";
2
- export declare const TRICK_ENCRYPTED_DIR: string;
package/dist/constant.js DELETED
@@ -1,3 +0,0 @@
1
- import * as path from 'node:path';
2
- export const TRICK_ROOT_DIR = '.trick';
3
- export const TRICK_ENCRYPTED_DIR = path.join(TRICK_ROOT_DIR, 'encrypted');
package/dist/secret.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare class SecretNotFoundError extends Error {
2
- readonly secretName: string;
3
- constructor(secretName: string);
4
- }
5
- export declare function getSecret(secretName: string): string;
package/dist/secret.js DELETED
@@ -1,14 +0,0 @@
1
- export class SecretNotFoundError extends Error {
2
- secretName;
3
- constructor(secretName) {
4
- super(`Secret ${secretName} is not presented in the environment`);
5
- this.secretName = secretName;
6
- }
7
- }
8
- export function getSecret(secretName) {
9
- const secret = process.env[secretName];
10
- if (secret === undefined) {
11
- throw new SecretNotFoundError(secretName);
12
- }
13
- return secret;
14
- }
package/src/constant.ts DELETED
@@ -1,4 +0,0 @@
1
- import * as path from 'node:path'
2
-
3
- export const TRICK_ROOT_DIR = '.trick'
4
- export const TRICK_ENCRYPTED_DIR = path.join(TRICK_ROOT_DIR, 'encrypted')
package/src/secret.ts DELETED
@@ -1,14 +0,0 @@
1
- export class SecretNotFoundError extends Error {
2
- public constructor(public readonly secretName: string) {
3
- super(`Secret ${secretName} is not presented in the environment`)
4
- }
5
- }
6
-
7
- export function getSecret(secretName: string): string {
8
- const secret = process.env[secretName]
9
- if (secret === undefined) {
10
- throw new SecretNotFoundError(secretName)
11
- }
12
-
13
- return secret
14
- }
package/trick.config.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "iteration_count": 114514,
3
- "targets": [
4
- {
5
- "secret_name": "TRICK_SECRET_NAME",
6
- "files": [
7
- "test/resources/really.json",
8
- "test/resources/task.yml"
9
- ]
10
- },
11
- {
12
- "secret_name": "SUPERVISOR_SERVER_TRICK_SECRET_NAME",
13
- "files": [
14
- "test/main/resources/database.properties",
15
- "test/main/resources/password.properties"
16
- ]
17
- }
18
- ],
19
- "default_secret_name": "SUPERVISOR_SERVER_TRICK_SECRET_NAME"
20
- }