dotsec 4.0.0-beta.f6d5ebb.0 → 5.0.0-beta.04208ad
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/bin/dotsec.js +43 -1
- package/package.json +34 -66
- package/CHANGELOG.md +0 -176
- package/README.md +0 -266
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -1504
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs +0 -1493
- package/dist/cli/index.mjs.map +0 -1
- package/dist/index.d.ts +0 -232
- package/dist/index.js +0 -211
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -189
- package/dist/index.mjs.map +0 -1
- package/src/templates/dotsec.config.ts +0 -3
package/bin/dotsec.js
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
require("
|
|
3
|
+
const { execFileSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const PLATFORMS = {
|
|
7
|
+
"linux-x64": "@dotsec/linux-x64-gnu",
|
|
8
|
+
"linux-arm64": "@dotsec/linux-arm64-gnu",
|
|
9
|
+
"darwin-x64": "@dotsec/darwin-x64",
|
|
10
|
+
"darwin-arm64": "@dotsec/darwin-arm64",
|
|
11
|
+
"win32-x64": "@dotsec/win32-x64-msvc",
|
|
12
|
+
"win32-arm64": "@dotsec/win32-arm64-msvc",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const key = `${process.platform}-${process.arch}`;
|
|
16
|
+
const pkg = PLATFORMS[key];
|
|
17
|
+
|
|
18
|
+
if (!pkg) {
|
|
19
|
+
console.error(
|
|
20
|
+
`dotsec: unsupported platform ${process.platform} ${process.arch}\n` +
|
|
21
|
+
`Supported: ${Object.keys(PLATFORMS).join(", ")}`
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let binPath;
|
|
27
|
+
try {
|
|
28
|
+
const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
|
|
29
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
30
|
+
binPath = path.join(pkgDir, `dotsec${ext}`);
|
|
31
|
+
} catch {
|
|
32
|
+
console.error(
|
|
33
|
+
`dotsec: could not find package "${pkg}"\n\n` +
|
|
34
|
+
`This usually means the optional dependency was not installed.\n` +
|
|
35
|
+
`Try reinstalling with: npm install dotsec`
|
|
36
|
+
);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e.status !== null) process.exit(e.status);
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,68 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
"typedoc": {
|
|
38
|
-
"entryPoint": "./src/index.ts",
|
|
39
|
-
"readmeFile": "./README.md",
|
|
40
|
-
"displayName": "dotsec"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@types/cli-table": "^0.3.1",
|
|
44
|
-
"@types/node": "^18.14.6",
|
|
45
|
-
"@types/prompts": "^2.0.14",
|
|
46
|
-
"@types/yargs-parser": "^21.0.0",
|
|
47
|
-
"tsup": "^6.7.0"
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@npmcli/arborist": "^6.1.4",
|
|
51
|
-
"ajv": "^8.11.2",
|
|
52
|
-
"bundle-require": "^3.0.4",
|
|
53
|
-
"camel-case": "^4.1.2",
|
|
54
|
-
"chalk": "^4.1.2",
|
|
55
|
-
"cli-table": "^0.3.11",
|
|
56
|
-
"commander": "^9.4.1",
|
|
57
|
-
"constant-case": "^3.0.4",
|
|
58
|
-
"cross-spawn": "^7.0.3",
|
|
59
|
-
"dotenv": "^16.0.0",
|
|
60
|
-
"dotenv-expand": "^10.0.0",
|
|
61
|
-
"esbuild": "~0.16",
|
|
62
|
-
"joycon": "^3.1.1",
|
|
63
|
-
"prompts": "^2.4.2",
|
|
64
|
-
"typescript": "~4.9.3",
|
|
65
|
-
"yargs-parser": "^21.1.1"
|
|
66
|
-
},
|
|
67
|
-
"gitHead": "f6d5ebb20f64585758baf398a9f6728c155dddbf"
|
|
2
|
+
"name": "dotsec",
|
|
3
|
+
"version": "5.0.0-beta.04208ad",
|
|
4
|
+
"description": "Encrypt and manage environment variables with AWS KMS",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dotsec": "bin/dotsec.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/dotsec.js",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"optionalDependencies": {
|
|
14
|
+
"@dotsec/linux-x64-gnu": "5.0.0-beta.04208ad",
|
|
15
|
+
"@dotsec/linux-arm64-gnu": "5.0.0-beta.04208ad",
|
|
16
|
+
"@dotsec/darwin-x64": "5.0.0-beta.04208ad",
|
|
17
|
+
"@dotsec/darwin-arm64": "5.0.0-beta.04208ad",
|
|
18
|
+
"@dotsec/win32-x64-msvc": "5.0.0-beta.04208ad",
|
|
19
|
+
"@dotsec/win32-arm64-msvc": "5.0.0-beta.04208ad"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/jpwesselink/dotsec-rs.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/jpwesselink/dotsec-rs",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/jpwesselink/dotsec-rs/issues"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
|
+
}
|
|
68
36
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [4.0.0-alpha.35](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.34...v4.0.0-alpha.35) (2023-08-17)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package dotsec
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# [4.0.0-alpha.34](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.33...v4.0.0-alpha.34) (2023-08-17)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Bug Fixes
|
|
18
|
-
|
|
19
|
-
* **dotsec:** removed default background color value ([365d774](https://github.com/jpwesselink/dotsec/commit/365d77470a5b33509d2c65ab20853c65a758be80))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# [4.0.0-alpha.33](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.32...v4.0.0-alpha.33) (2023-08-17)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Bug Fixes
|
|
29
|
-
|
|
30
|
-
* **dotsec:** booleans are hard ([e6624f4](https://github.com/jpwesselink/dotsec/commit/e6624f4f8ea46a2af154fb08903a8e02087f9b8e))
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# [4.0.0-alpha.32](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.31...v4.0.0-alpha.32) (2023-08-17)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* **dotsec:** docs, output background color options ([2dd7d74](https://github.com/jpwesselink/dotsec/commit/2dd7d747ac3cf55165ebc410eaceb584d3978849))
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
# [4.0.0-alpha.31](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.30...v4.0.0-alpha.31) (2023-08-17)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### Features
|
|
51
|
-
|
|
52
|
-
* **dotsec:** docs, output background color options ([328445e](https://github.com/jpwesselink/dotsec/commit/328445e7c067a532ab27b3f0667aabd060ba5109))
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# [4.0.0-alpha.30](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.29...v4.0.0-alpha.30) (2023-08-17)
|
|
59
|
-
|
|
60
|
-
**Note:** Version bump only for package dotsec
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# [4.0.0-alpha.29](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.28...v4.0.0-alpha.29) (2023-08-17)
|
|
67
|
-
|
|
68
|
-
**Note:** Version bump only for package dotsec
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# [4.0.0-alpha.28](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.27...v4.0.0-alpha.28) (2023-08-17)
|
|
75
|
-
|
|
76
|
-
**Note:** Version bump only for package dotsec
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
# [4.0.0-alpha.25](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.24...v4.0.0-alpha.25) (2023-08-16)
|
|
83
|
-
|
|
84
|
-
**Note:** Version bump only for package dotsec
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
# [4.0.0-alpha.24](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.23...v4.0.0-alpha.24) (2023-08-16)
|
|
91
|
-
|
|
92
|
-
**Note:** Version bump only for package dotsec
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# [4.0.0-alpha.22](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.21...v4.0.0-alpha.22) (2023-06-26)
|
|
99
|
-
|
|
100
|
-
**Note:** Version bump only for package dotsec
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
# [4.0.0-alpha.20](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.19...v4.0.0-alpha.20) (2023-06-02)
|
|
107
|
-
|
|
108
|
-
**Note:** Version bump only for package dotsec
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# [4.0.0-alpha.18](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.17...v4.0.0-alpha.18) (2023-05-24)
|
|
115
|
-
|
|
116
|
-
**Note:** Version bump only for package dotsec
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
# [4.0.0-alpha.16](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.15...v4.0.0-alpha.16) (2023-05-22)
|
|
123
|
-
|
|
124
|
-
**Note:** Version bump only for package dotsec
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
# [4.0.0-alpha.14](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.13...v4.0.0-alpha.14) (2023-05-22)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
### Features
|
|
134
|
-
|
|
135
|
-
* test ([f6398b0](https://github.com/jpwesselink/dotsec/commit/f6398b0f6a5829be93640421aba28dd73e012df4))
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
# [4.0.0-alpha.13](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.12...v4.0.0-alpha.13) (2023-05-22)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
### Features
|
|
145
|
-
|
|
146
|
-
* test ([535c584](https://github.com/jpwesselink/dotsec/commit/535c5844c06fda4b8bdd6d359e080f42033ef3a4))
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# [4.0.0-alpha.12](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.11...v4.0.0-alpha.12) (2023-05-22)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
### Features
|
|
156
|
-
|
|
157
|
-
* test ([0694639](https://github.com/jpwesselink/dotsec/commit/06946392e67b69f6bf7e29417a29784871f6c0fe))
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
# [4.0.0-alpha.11](https://github.com/jpwesselink/dotsec/compare/v4.0.0-alpha.10...v4.0.0-alpha.11) (2023-05-22)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
### Features
|
|
167
|
-
|
|
168
|
-
* test ([fd59d34](https://github.com/jpwesselink/dotsec/commit/fd59d34bc06d148557b3a97dfc5869b239b4f08c))
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
# [4.0.0-alpha.10](https://github.com/jpwesselink/dotsec/compare/v2.0.0-alpha.1...v4.0.0-alpha.10) (2023-05-22)
|
|
175
|
-
|
|
176
|
-
**Note:** Version bump only for package dotsec
|
package/README.md
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
# dotsec
|
|
2
|
-
|
|
3
|
-
The solution offers encryption and decryption of `.env` files to and from `.sec` files, the ability to run a command with the values of a `.env`/`.sec` file in its environment. The AWS plugin adds the ability to push selected `.env`/`.sec` entries to AWS Systems Manager Parameter Store and AWS Secrets Manager.
|
|
4
|
-
|
|
5
|
-
Currently there are two methods of encryption supported:
|
|
6
|
-
|
|
7
|
-
- [`@dotsec/plugin-pke`](./packages/plugin-pke/README.md) - Using Public Key Encryption
|
|
8
|
-
- [`@dotsec/plugin-aws`](./packages/plugin-aws/README.md) - Using AWS Key Management Service (AWS KMS)
|
|
9
|
-
|
|
10
|
-
## Why?
|
|
11
|
-
|
|
12
|
-
Environment variables are a great way to configure your application. However, they shouldn't be committed to your repository. This is because they often contain sensitive information, like passwords, API keys, and other secrets. This is where `dotsec` comes in. It allows you to encrypt your environment variables, and store them in a `.sec` file, which can be committed to your repository.
|
|
13
|
-
|
|
14
|
-
## Features
|
|
15
|
-
|
|
16
|
-
- Encryption of `.env` files to `.sec` files.
|
|
17
|
-
- Decryption of `.sec` files to `.env` files.
|
|
18
|
-
- Run a command with the values of a `.env` file in its environment.
|
|
19
|
-
- Run a command with the values of a `.sec` file in its environment.
|
|
20
|
-
- Push selected `.env`/`.sec` entries to AWS Systems Manager Parameter Store.
|
|
21
|
-
- Push selected `.env`/`.sec` entries to AWS Secrets Manager.
|
|
22
|
-
- Holds no opinion on how you should manage your organization's user roles and permissions, you know best.
|
|
23
|
-
|
|
24
|
-
### AWS plugin
|
|
25
|
-
|
|
26
|
-
- Supported KMS key types: symmetric and assymetric:
|
|
27
|
-
- `SYMMETRIC_DEFAULT`
|
|
28
|
-
- `RSA_2048`
|
|
29
|
-
- `RSAES_OAEP_SHA_256`
|
|
30
|
-
- `RSA_3072`
|
|
31
|
-
- `RSAES_OAEP_SHA_256`
|
|
32
|
-
- `RSA_4096`
|
|
33
|
-
- `RSAES_OAEP_SHA_256`
|
|
34
|
-
- `SM2PKE`
|
|
35
|
-
|
|
36
|
-
## Requirements
|
|
37
|
-
|
|
38
|
-
- For initialisation enough credentials for creating a KMS key, and alias.
|
|
39
|
-
- For usage enough credentials for using the KMS key to encrypt and/or decrypt.
|
|
40
|
-
- An AWS KMS key with an alias.
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
npm install --save-dev dotsec @dotsec/plugin-aws
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Add the folowing to dotsec.config.ts:
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import { DotsecPluginAws } from "@dotsec/plugin-aws";
|
|
52
|
-
import { DotsecConfig } from "dotsec";
|
|
53
|
-
|
|
54
|
-
export const dotsec: DotsecConfig<{ plugins: DotsecPluginAws }> = {
|
|
55
|
-
defaults: {
|
|
56
|
-
encryptionEngine: "aws",
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
If you don't have a .env file, create one:
|
|
64
|
-
|
|
65
|
-
```sh
|
|
66
|
-
I_CAN_SEE="clearly now"
|
|
67
|
-
SINGING="in the rain"
|
|
68
|
-
I_BLESS_THE_RAINS="down in Africa"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Execute a command and use the values of a .env file in its environment
|
|
72
|
-
|
|
73
|
-
```sh
|
|
74
|
-
npx dotsec run --with-env node -e "console.log(process.env.I_BLESS_THE_RAINS)"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Encrypt a .env file to .sec
|
|
78
|
-
|
|
79
|
-
```sh
|
|
80
|
-
npx dotsec encrypt
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Execute a command and use the values of a .sec file in its environment
|
|
84
|
-
|
|
85
|
-
```sh
|
|
86
|
-
npx dotsec run --with-sec node -e "console.log(process.env.I_BLESS_THE_RAINS)"
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Decrypt a .sec file to .env
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
npx dotsec decrypt
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Push selected .env entries to AWS Systems Manager Parameter Store
|
|
96
|
-
|
|
97
|
-
Edit the `dotsec.config.ts` file. Add the following to the `aws` object:
|
|
98
|
-
|
|
99
|
-
```ts
|
|
100
|
-
{
|
|
101
|
-
...
|
|
102
|
-
variables: {
|
|
103
|
-
"I_BLESS_THE_RAINS": {
|
|
104
|
-
push: {
|
|
105
|
-
aws: {
|
|
106
|
-
ssm: true
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Run the following command:
|
|
115
|
-
|
|
116
|
-
```sh
|
|
117
|
-
npx dotsec push
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
> You might want to set AWS_REGION before running the command. If you don't, the region will be set to `eu-west-1`.
|
|
121
|
-
|
|
122
|
-
<!--
|
|
123
|
-
## Usage
|
|
124
|
-
|
|
125
|
-
If you don't have an AWS KMS key with an alias, you can create one with the following command:
|
|
126
|
-
|
|
127
|
-
```sh
|
|
128
|
-
aws kms create-key --description "Dotsec key" --region eu-west-1
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Take not of the `KeyMetadata.KeyId` value, and create an alias for it:
|
|
132
|
-
|
|
133
|
-
> Note: You are free to pick any allowed alias name.
|
|
134
|
-
|
|
135
|
-
```sh
|
|
136
|
-
aws kms create-alias --alias-name alias/dotsec --target-key-id <key-id>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Execute a command and use the values of a .env file in its environment
|
|
140
|
-
|
|
141
|
-
Create a .env file if you don't have one already, and add some values:
|
|
142
|
-
|
|
143
|
-
```sh
|
|
144
|
-
echo "MY_FANCY_ENV_VAR='yes yes yallzies'\nHEY_HO='Let\'s go'" > .env
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
The following command will create an encrypted version of the `.env` file, and store it in a file called `.sec`. It will also create a config file called `dotsec.config.ts` which contains the KMS key alias, and AWS region. (Note: you don't have to add the key alias and region to the config file, you can also pass them as options to the dotsec aws sub command. See `dotsec init aws --help` for more information.)
|
|
148
|
-
|
|
149
|
-
```sh
|
|
150
|
-
npx dotsec init --aws-region eu-west-1 [--aws-key-alias alias/dotsec]
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
The following files will be created:
|
|
154
|
-
|
|
155
|
-
- `.sec` - The encrypted version of the `.env` file.
|
|
156
|
-
- `dotsec.config.ts` - The config file containing the KMS key alias and AWS region.
|
|
157
|
-
|
|
158
|
-
### Add files to Git
|
|
159
|
-
|
|
160
|
-
Add the `.sec` and `dotsec.config.ts` files to your repository, and commit these accordingly.
|
|
161
|
-
|
|
162
|
-
### Run a process with your .env file
|
|
163
|
-
|
|
164
|
-
```sh
|
|
165
|
-
npx dotsec run --env .env command env
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Run a process with your .sec file
|
|
169
|
-
|
|
170
|
-
```sh
|
|
171
|
-
npx dotsec run --sec .sec command env
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
For more options see `dotsec run --help`.
|
|
175
|
-
|
|
176
|
-
### Decrypt a .sec file to .env
|
|
177
|
-
|
|
178
|
-
```sh
|
|
179
|
-
npx dotsec decrypt
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
For more options see `dotsec decrypt --help`.
|
|
183
|
-
|
|
184
|
-
### Encrypt a .env file to .sec
|
|
185
|
-
|
|
186
|
-
```sh
|
|
187
|
-
npx dotsec encrypt
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
For more options see `dotsec encrypt --help`.
|
|
191
|
-
|
|
192
|
-
### Push selected .env/.sec entries to AWS Systems Manager Parameter Store
|
|
193
|
-
|
|
194
|
-
Take your favorite editor, and edit the `dotsec.config.ts` file. Add the following to the `aws` object:
|
|
195
|
-
|
|
196
|
-
```ts
|
|
197
|
-
{
|
|
198
|
-
variables: {
|
|
199
|
-
"NAME_OF_ENV_VAR_YOU_WANT_TO_PUSH": {
|
|
200
|
-
push: {
|
|
201
|
-
aws: {
|
|
202
|
-
ssm: true
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
> Take a look at the DotsecConfig type for more options on how to configure SSM pushes.
|
|
211
|
-
|
|
212
|
-
```sh
|
|
213
|
-
npx dotsec push --env --to-aws-ssm
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Push selected .env/.sec entries to AWS Secrets Manager
|
|
217
|
-
|
|
218
|
-
Take your favorite editor, and edit the `dotsec.config.ts` file. Add the following to the `aws` object:
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
|
-
{
|
|
222
|
-
variables: {
|
|
223
|
-
"NAME_OF_ENV_VAR_YOU_WANT_TO_PUSH": {
|
|
224
|
-
push: {
|
|
225
|
-
aws: {
|
|
226
|
-
secretsManager: true
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
> Take a look at the DotsecConfig type for more options on how to configure Secrets Manager pushes.
|
|
235
|
-
|
|
236
|
-
```sh
|
|
237
|
-
npx dotsec push --env --to-aws-secrets-manager
|
|
238
|
-
``` -->
|
|
239
|
-
|
|
240
|
-
### FAQ
|
|
241
|
-
|
|
242
|
-
#### Is it safe to commit a `.sec` and `dotsec.config.ts` file alongside your code?
|
|
243
|
-
|
|
244
|
-
Yes it is. But it is up to you to make sure that access to the KMS key is restricted to the people who need to decrypt and/or encrypt the `.sec` file.
|
|
245
|
-
|
|
246
|
-
#### Should I use this in production?
|
|
247
|
-
|
|
248
|
-
We do, however, since this package is relatively new, I don't think you should.
|
|
249
|
-
|
|
250
|
-
## Roadmap
|
|
251
|
-
|
|
252
|
-
- Write some tests already.
|
|
253
|
-
- Add support in-code use like `dotsec.config()`
|
|
254
|
-
- Add support for Node preload modules like `node -r dotsec/register index.js`
|
|
255
|
-
- Add watcher for `.env` file changes and automatically encrypt
|
|
256
|
-
- Write guide on postinstall for npm/yarn/pnpm
|
|
257
|
-
- ~~Add chunking for encoding larger files with assymetric keys. Current limit is 4kb.~~
|
|
258
|
-
- Add support for other encryption SDKs like GCP KMS, Azure Key Vault, etc.
|
|
259
|
-
- ~~Split up dotsec package in multiple packages, one for each encryption SDK.~~
|
|
260
|
-
- Add support for pulling entries to GitHub actions secrets.
|
|
261
|
-
|
|
262
|
-
## Limitations
|
|
263
|
-
|
|
264
|
-
- The only supported encryption SDK is the AWS Encryption SDK. For now.
|
|
265
|
-
- ~~Assymetric keys are supported, but the encrypted file size is limited to the payload size of the key. Until chunking is implemented, that is.~~
|
|
266
|
-
- AWS Secrets Manager secrets which are marked for deletion **cannot** be updated until the deletion is complete. As of writing, the minimum deletion time is 7 days. This means that if you want to update a deleted AWS Secrets Manager secret, you have to wait at least 7 days before you can update it again. This is a limitation of AWS Secrets Manager, not dotsec
|
package/dist/cli/index.d.ts
DELETED