@dotenvx/dotenvx 2.38.2 → 3.0.0-beta.2
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/README.md +197 -3314
- package/bin/dotenvx.cjs +34 -0
- package/config.cjs +1 -0
- package/config.d.ts +1 -0
- package/config.mjs +2 -0
- package/index.cjs +141 -0
- package/index.d.ts +66 -0
- package/index.mjs +3 -0
- package/lib/cli.cjs +43 -0
- package/lib/native-package.cjs +21 -0
- package/lib/platforms.cjs +18 -0
- package/{src/lib/helpers/redactOutput.js → lib/redactOutput.cjs} +2 -48
- package/lib/redaction.cjs +64 -0
- package/lib/validateOptions.cjs +57 -0
- package/native.cjs +23 -0
- package/package.json +57 -65
- package/CHANGELOG.md +0 -2733
- package/src/cli/actions/armor/down.js +0 -38
- package/src/cli/actions/armor/invite.js +0 -21
- package/src/cli/actions/armor/move.js +0 -43
- package/src/cli/actions/armor/open.js +0 -28
- package/src/cli/actions/armor/pull.js +0 -38
- package/src/cli/actions/armor/push.js +0 -38
- package/src/cli/actions/armor/status.js +0 -7
- package/src/cli/actions/armor/up.js +0 -38
- package/src/cli/actions/check.js +0 -78
- package/src/cli/actions/curl.js +0 -71
- package/src/cli/actions/decrypt.js +0 -119
- package/src/cli/actions/del.js +0 -54
- package/src/cli/actions/doctor.js +0 -22
- package/src/cli/actions/encrypt.js +0 -104
- package/src/cli/actions/ext/genexample.js +0 -36
- package/src/cli/actions/ext/gitignore.js +0 -106
- package/src/cli/actions/ext/prebuild.js +0 -7
- package/src/cli/actions/ext/precommit.js +0 -38
- package/src/cli/actions/ext/scan.js +0 -33
- package/src/cli/actions/feedback.js +0 -42
- package/src/cli/actions/get.js +0 -128
- package/src/cli/actions/init.js +0 -67
- package/src/cli/actions/keychain/down.js +0 -30
- package/src/cli/actions/keychain/pull.js +0 -30
- package/src/cli/actions/keychain/push.js +0 -30
- package/src/cli/actions/keychain/up.js +0 -30
- package/src/cli/actions/keypair.js +0 -84
- package/src/cli/actions/login.js +0 -64
- package/src/cli/actions/logout.js +0 -37
- package/src/cli/actions/ls.js +0 -76
- package/src/cli/actions/policy.js +0 -14
- package/src/cli/actions/primitivesCheck.js +0 -32
- package/src/cli/actions/primitivesProfile.js +0 -15
- package/src/cli/actions/primitivesRedact.js +0 -19
- package/src/cli/actions/protect.js +0 -75
- package/src/cli/actions/protectDocker.js +0 -30
- package/src/cli/actions/protectProcess.js +0 -126
- package/src/cli/actions/protectStdin.js +0 -80
- package/src/cli/actions/run.js +0 -203
- package/src/cli/actions/set.js +0 -103
- package/src/cli/actions/settings/device.js +0 -23
- package/src/cli/actions/settings/hostname.js +0 -20
- package/src/cli/actions/settings/off.js +0 -14
- package/src/cli/actions/settings/on.js +0 -14
- package/src/cli/actions/settings/path.js +0 -20
- package/src/cli/actions/settings/token.js +0 -23
- package/src/cli/actions/settings/username.js +0 -20
- package/src/cli/actions/update.js +0 -15
- package/src/cli/commandAction.js +0 -16
- package/src/cli/commands/armor.js +0 -129
- package/src/cli/commands/custody.js +0 -45
- package/src/cli/commands/ext.js +0 -88
- package/src/cli/commands/fileOptions.js +0 -22
- package/src/cli/commands/native.js +0 -54
- package/src/cli/commands/primitives.js +0 -73
- package/src/cli/commands/settings.js +0 -63
- package/src/cli/dotenvx.js +0 -443
- package/src/cli/help.js +0 -179
- package/src/db/device.js +0 -67
- package/src/db/session.js +0 -330
- package/src/lib/api/getAccount.js +0 -32
- package/src/lib/api/getConnectionResources.js +0 -21
- package/src/lib/api/getTeamConnections.js +0 -27
- package/src/lib/api/getTeamServices.js +0 -23
- package/src/lib/api/getTeams.js +0 -28
- package/src/lib/api/postArmorDown.js +0 -48
- package/src/lib/api/postArmorMove.js +0 -48
- package/src/lib/api/postArmorPull.js +0 -48
- package/src/lib/api/postArmorPush.js +0 -48
- package/src/lib/api/postArmorUp.js +0 -53
- package/src/lib/api/postConnectionKeypair.js +0 -23
- package/src/lib/api/postFeedback.js +0 -31
- package/src/lib/api/postLogout.js +0 -34
- package/src/lib/api/postOauthDeviceCode.js +0 -38
- package/src/lib/api/postOauthToken.js +0 -35
- package/src/lib/api/postTeamInvitation.js +0 -28
- package/src/lib/api/teamConnectionSetup.js +0 -31
- package/src/lib/config.d.ts +0 -1
- package/src/lib/config.js +0 -1
- package/src/lib/conventions/environment.js +0 -27
- package/src/lib/conventions/filepaths.js +0 -9
- package/src/lib/conventions/keynames.js +0 -38
- package/src/lib/custodians/index.js +0 -75
- package/src/lib/custodians/local/bitwarden.js +0 -165
- package/src/lib/custodians/local/file.js +0 -18
- package/src/lib/custodians/local/native/backend.js +0 -56
- package/src/lib/custodians/local/native/index.js +0 -28
- package/src/lib/custodians/local/native/store.js +0 -24
- package/src/lib/custodians/local/onepassword.js +0 -149
- package/src/lib/custodians/managed/armor/index.js +0 -14
- package/src/lib/custodians/managed/armor/store.js +0 -48
- package/src/lib/custodians/resolveLocalKey.js +0 -67
- package/src/lib/decryptors/armor/index.js +0 -23
- package/src/lib/decryptors/decryptor-worker.js +0 -6
- package/src/lib/decryptors/index.js +0 -69
- package/src/lib/envfile/discovery/discoverEnvFiles.js +0 -29
- package/src/lib/envfile/discovery/extractEnvKeys.js +0 -173
- package/src/lib/envfile/discovery/scanSource.js +0 -79
- package/src/lib/envfile/parsing/formatEnvfileSyntaxError.js +0 -24
- package/src/lib/envfile/parsing/readEnvfile.js +0 -43
- package/src/lib/envfile/parsing/resolveEnvfilePath.js +0 -5
- package/src/lib/envfile/rendering/normalizeEnvfile.js +0 -53
- package/src/lib/envfile/rendering/previewEnvfile.js +0 -43
- package/src/lib/envfile/rendering/renderEnvfile.js +0 -30
- package/src/lib/envfile/validation/diagnosticLocation.js +0 -29
- package/src/lib/envfile/validation/protectEnvfile.js +0 -40
- package/src/lib/envfile/validation/validateEnvfile.js +0 -14
- package/src/lib/events/backends/armor.js +0 -31
- package/src/lib/events/background.js +0 -59
- package/src/lib/events/catalog.js +0 -14
- package/src/lib/events/cli.js +0 -40
- package/src/lib/events/delivery.js +0 -89
- package/src/lib/events/index.js +0 -73
- package/src/lib/events/metadata.js +0 -25
- package/src/lib/events/sdk.js +0 -44
- package/src/lib/events/worker.js +0 -29
- package/src/lib/events/workerEnvironment.js +0 -14
- package/src/lib/helpers/armoredKeyDisplay.js +0 -10
- package/src/lib/helpers/arrayToTree.js +0 -27
- package/src/lib/helpers/buildApiError.js +0 -19
- package/src/lib/helpers/buildCommandEnvs.js +0 -40
- package/src/lib/helpers/buildConfigEnvs.js +0 -13
- package/src/lib/helpers/buildEnvs.js +0 -24
- package/src/lib/helpers/buildOauthError.js +0 -14
- package/src/lib/helpers/canonicalEnvFilename.js +0 -13
- package/src/lib/helpers/catchAndLog.js +0 -16
- package/src/lib/helpers/checklist.js +0 -50
- package/src/lib/helpers/chomp.js +0 -5
- package/src/lib/helpers/colorDepth.js +0 -23
- package/src/lib/helpers/conventions.js +0 -28
- package/src/lib/helpers/createElapsedStatus.js +0 -17
- package/src/lib/helpers/createProtectSpinner.js +0 -13
- package/src/lib/helpers/createSpinner.js +0 -40
- package/src/lib/helpers/cryptography/decryptKeyValue.js +0 -50
- package/src/lib/helpers/cryptography/index.js +0 -7
- package/src/lib/helpers/cryptography/isDotenvPublicKey.js +0 -7
- package/src/lib/helpers/cryptography/isPlainKey.js +0 -7
- package/src/lib/helpers/cryptography/mutateKeysSrc.js +0 -22
- package/src/lib/helpers/cryptography/mutateSrc.js +0 -24
- package/src/lib/helpers/custodySelect.js +0 -25
- package/src/lib/helpers/decryptDeviceValue.js +0 -7
- package/src/lib/helpers/detectEncoding.js +0 -22
- package/src/lib/helpers/detectEncodingSync.js +0 -22
- package/src/lib/helpers/dotenvOptionPaths.js +0 -25
- package/src/lib/helpers/dotenvPrivateKeyNames.js +0 -7
- package/src/lib/helpers/enclavedHint.js +0 -11
- package/src/lib/helpers/encryptDeviceValue.js +0 -7
- package/src/lib/helpers/envResolution/determine.js +0 -49
- package/src/lib/helpers/envResolution/index.js +0 -8
- package/src/lib/helpers/errors.js +0 -374
- package/src/lib/helpers/escape.js +0 -6
- package/src/lib/helpers/execute.js +0 -12
- package/src/lib/helpers/executeCommand.js +0 -208
- package/src/lib/helpers/executeDynamic.js +0 -86
- package/src/lib/helpers/executeExtension.js +0 -39
- package/src/lib/helpers/filterKeys.js +0 -15
- package/src/lib/helpers/findEnvFiles.js +0 -25
- package/src/lib/helpers/formatCode.js +0 -11
- package/src/lib/helpers/fsx.js +0 -110
- package/src/lib/helpers/guessPrivateKeyFilename.js +0 -15
- package/src/lib/helpers/hasPlaintextSecrets.js +0 -7
- package/src/lib/helpers/http.js +0 -14
- package/src/lib/helpers/installPrecommitHook.js +0 -82
- package/src/lib/helpers/installProtectFilter.js +0 -57
- package/src/lib/helpers/installProtectIgnore.js +0 -27
- package/src/lib/helpers/isPublicKey.js +0 -3
- package/src/lib/helpers/isTeamRequiredError.js +0 -10
- package/src/lib/helpers/jsonToEnv.js +0 -7
- package/src/lib/helpers/keypairMetadata.js +0 -90
- package/src/lib/helpers/kits/sample.js +0 -5
- package/src/lib/helpers/linuxSecretService.js +0 -52
- package/src/lib/helpers/listenForOpenKey.js +0 -46
- package/src/lib/helpers/logProtectedFiles.js +0 -9
- package/src/lib/helpers/logSetSummary.js +0 -21
- package/src/lib/helpers/macosKeychain.js +0 -52
- package/src/lib/helpers/mask.js +0 -22
- package/src/lib/helpers/maskEnvSrc.js +0 -15
- package/src/lib/helpers/maskProcessedEnvs.js +0 -29
- package/src/lib/helpers/matchesStoredKey.js +0 -5
- package/src/lib/helpers/nativeStoreError.js +0 -10
- package/src/lib/helpers/normalizeDotenvConfigConvention.js +0 -13
- package/src/lib/helpers/normalizeDotenvConfigIgnore.js +0 -18
- package/src/lib/helpers/normalizeDotenvConfigPath.js +0 -14
- package/src/lib/helpers/normalizeDotenvConfigQuiet.js +0 -13
- package/src/lib/helpers/normalizeToken.js +0 -5
- package/src/lib/helpers/openUrl.js +0 -7
- package/src/lib/helpers/packageJson.js +0 -3
- package/src/lib/helpers/parseWithDecryptor.js +0 -115
- package/src/lib/helpers/plaintextKeys.js +0 -9
- package/src/lib/helpers/precommitEnvPatterns.js +0 -1
- package/src/lib/helpers/prependPublicKey.js +0 -17
- package/src/lib/helpers/preserveShebang.js +0 -16
- package/src/lib/helpers/prompts.js +0 -169
- package/src/lib/helpers/protectSettings.js +0 -64
- package/src/lib/helpers/ptyCommand.js +0 -27
- package/src/lib/helpers/readEnvKey.js +0 -32
- package/src/lib/helpers/redact.js +0 -9
- package/src/lib/helpers/redactProcessOutput.js +0 -58
- package/src/lib/helpers/redactedValues.js +0 -29
- package/src/lib/helpers/removeDynamicHelpSection.js +0 -21
- package/src/lib/helpers/removeEnvKey.js +0 -51
- package/src/lib/helpers/removeLegacyProtectFilter.js +0 -43
- package/src/lib/helpers/removeOptionsHelpParts.js +0 -59
- package/src/lib/helpers/resolveBitwardenPassword.js +0 -165
- package/src/lib/helpers/resolveDirectoryFilepath.js +0 -16
- package/src/lib/helpers/resolveEnvKeysFile.js +0 -11
- package/src/lib/helpers/resolveHome.js +0 -12
- package/src/lib/helpers/resolveOnePassword.js +0 -82
- package/src/lib/helpers/sanitizeCommandForMetadata.js +0 -64
- package/src/lib/helpers/selectConnection.js +0 -51
- package/src/lib/helpers/selectConnectionResource.js +0 -41
- package/src/lib/helpers/selectEnvfileEnvs.js +0 -29
- package/src/lib/helpers/selectKeyStorage.js +0 -140
- package/src/lib/helpers/statusReporter.js +0 -8
- package/src/lib/helpers/storeKeyStorage.js +0 -39
- package/src/lib/helpers/teamChoicesFromMeta.js +0 -8
- package/src/lib/helpers/truncate.js +0 -10
- package/src/lib/helpers/uninstallPrecommitHook.js +0 -67
- package/src/lib/helpers/upsertEnvKey.js +0 -62
- package/src/lib/helpers/windowsCredentialManager.js +0 -166
- package/src/lib/main.d.ts +0 -509
- package/src/lib/main.js +0 -468
- package/src/lib/providers/index.js +0 -86
- package/src/lib/providers/native/index.js +0 -2
- package/src/lib/resolvers/envs.js +0 -416
- package/src/lib/resolvers/get.js +0 -87
- package/src/lib/resolvers/keypair.js +0 -135
- package/src/lib/resolvers/ls.js +0 -69
- package/src/lib/services/armorDown.js +0 -73
- package/src/lib/services/armorInvite.js +0 -36
- package/src/lib/services/armorMove.js +0 -55
- package/src/lib/services/armorOpen.js +0 -26
- package/src/lib/services/armorPull.js +0 -73
- package/src/lib/services/armorPush.js +0 -66
- package/src/lib/services/armorUp.js +0 -71
- package/src/lib/services/custodyTransfer.js +0 -50
- package/src/lib/services/doctor.js +0 -93
- package/src/lib/services/genexample.js +0 -112
- package/src/lib/services/init.js +0 -83
- package/src/lib/services/keychainDown.js +0 -60
- package/src/lib/services/keychainPull.js +0 -46
- package/src/lib/services/keychainPush.js +0 -51
- package/src/lib/services/keychainUp.js +0 -72
- package/src/lib/services/login.js +0 -51
- package/src/lib/services/logout.js +0 -26
- package/src/lib/services/prebuild.js +0 -91
- package/src/lib/services/precommit.js +0 -144
- package/src/lib/services/validate.js +0 -57
- package/src/lib/transforms/decrypt.js +0 -98
- package/src/lib/transforms/del.js +0 -58
- package/src/lib/transforms/encrypt.js +0 -164
- package/src/lib/transforms/set.js +0 -144
- package/src/shared/colors.js +0 -67
- package/src/shared/logger.js +0 -148
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const packageJson = require('../helpers/packageJson')
|
|
4
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
-
|
|
6
|
-
class PostArmorPush {
|
|
7
|
-
constructor (hostname, token, devicePublicKey, privateKey, team) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.token = token
|
|
10
|
-
this.devicePublicKey = devicePublicKey
|
|
11
|
-
this.privateKey = privateKey
|
|
12
|
-
this.team = team
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run () {
|
|
16
|
-
const token = normalizeToken(this.token)
|
|
17
|
-
const devicePublicKey = this.devicePublicKey
|
|
18
|
-
const privateKey = this.privateKey
|
|
19
|
-
const team = this.team
|
|
20
|
-
const url = `${this.hostname}/api/armor/push`
|
|
21
|
-
|
|
22
|
-
const body = {
|
|
23
|
-
device_public_key: devicePublicKey,
|
|
24
|
-
cli_version: packageJson.version,
|
|
25
|
-
private_key: privateKey,
|
|
26
|
-
team
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const resp = await http(url, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: {
|
|
32
|
-
Authorization: `Bearer ${token}`,
|
|
33
|
-
'Content-Type': 'application/json'
|
|
34
|
-
},
|
|
35
|
-
body: JSON.stringify(body)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const json = await resp.body.json()
|
|
39
|
-
|
|
40
|
-
if (resp.statusCode >= 400) {
|
|
41
|
-
throw buildApiError(resp.statusCode, json)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return json
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
module.exports = PostArmorPush
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const packageJson = require('../helpers/packageJson')
|
|
4
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
5
|
-
|
|
6
|
-
class PostArmorUp {
|
|
7
|
-
constructor (hostname, token, devicePublicKey, publicKey, privateKey, team, metadata) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.token = token
|
|
10
|
-
this.devicePublicKey = devicePublicKey
|
|
11
|
-
this.publicKey = publicKey
|
|
12
|
-
this.privateKey = privateKey
|
|
13
|
-
this.team = team
|
|
14
|
-
this.metadata = metadata
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async run () {
|
|
18
|
-
const token = normalizeToken(this.token)
|
|
19
|
-
const devicePublicKey = this.devicePublicKey
|
|
20
|
-
const publicKey = this.publicKey
|
|
21
|
-
const privateKey = this.privateKey
|
|
22
|
-
const team = this.team
|
|
23
|
-
const url = `${this.hostname}/api/armor/up`
|
|
24
|
-
|
|
25
|
-
const body = {
|
|
26
|
-
device_public_key: devicePublicKey,
|
|
27
|
-
cli_version: packageJson.version,
|
|
28
|
-
public_key: publicKey,
|
|
29
|
-
private_key: privateKey,
|
|
30
|
-
team,
|
|
31
|
-
metadata: this.metadata
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const resp = await http(url, {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
headers: {
|
|
37
|
-
Authorization: `Bearer ${token}`,
|
|
38
|
-
'Content-Type': 'application/json'
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify(body)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
const json = await resp.body.json()
|
|
44
|
-
|
|
45
|
-
if (resp.statusCode >= 400) {
|
|
46
|
-
throw buildApiError(resp.statusCode, json)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return json
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = PostArmorUp
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class PostConnectionKeypair {
|
|
6
|
-
constructor (hostname, token, selection, privateKeyName) {
|
|
7
|
-
Object.assign(this, { hostname, token, selection, privateKeyName })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run () {
|
|
11
|
-
const { team, connectionId, resourceId } = this.selection
|
|
12
|
-
const response = await http(`${this.hostname}/api/teams/${encodeURIComponent(team)}/connections/${encodeURIComponent(connectionId)}/keypairs`, {
|
|
13
|
-
method: 'POST',
|
|
14
|
-
headers: { Authorization: `Bearer ${normalizeToken(this.token)}`, 'Content-Type': 'application/json' },
|
|
15
|
-
body: JSON.stringify({ resource_id: resourceId, private_key_name: this.privateKeyName })
|
|
16
|
-
})
|
|
17
|
-
const json = await response.body.json()
|
|
18
|
-
if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
|
|
19
|
-
return json
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = PostConnectionKeypair
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
|
|
4
|
-
class PostFeedback {
|
|
5
|
-
constructor (hostname, body) {
|
|
6
|
-
this.hostname = hostname
|
|
7
|
-
this.body = body
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run () {
|
|
11
|
-
const url = `${this.hostname}/api/feedback`
|
|
12
|
-
|
|
13
|
-
const resp = await http(url, {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/json'
|
|
17
|
-
},
|
|
18
|
-
body: JSON.stringify({ body: this.body })
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const json = await resp.body.json()
|
|
22
|
-
|
|
23
|
-
if (resp.statusCode >= 400) {
|
|
24
|
-
throw buildApiError(resp.statusCode, json)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return json
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = PostFeedback
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class PostLogout {
|
|
6
|
-
constructor (hostname, token) {
|
|
7
|
-
this.hostname = hostname
|
|
8
|
-
this.token = token
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async run () {
|
|
12
|
-
const token = normalizeToken(this.token)
|
|
13
|
-
const url = `${this.hostname}/api/logout`
|
|
14
|
-
|
|
15
|
-
const resp = await http(url, {
|
|
16
|
-
method: 'POST',
|
|
17
|
-
headers: {
|
|
18
|
-
Authorization: `Bearer ${token}`,
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
},
|
|
21
|
-
body: JSON.stringify({})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const json = await resp.body.json()
|
|
25
|
-
|
|
26
|
-
if (resp.statusCode >= 400) {
|
|
27
|
-
throw buildApiError(resp.statusCode, json)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return json
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = PostLogout
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildOauthError = require('../helpers/buildOauthError')
|
|
3
|
-
|
|
4
|
-
const OAUTH_CLIENT_ID = 'oac_dotenvxcli'
|
|
5
|
-
|
|
6
|
-
class PostOauthDeviceCode {
|
|
7
|
-
constructor (hostname, devicePublicKey, systemInformation, dotenvxProjectId = null) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.devicePublicKey = devicePublicKey
|
|
10
|
-
this.systemInformation = systemInformation
|
|
11
|
-
this.dotenvxProjectId = dotenvxProjectId
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async run () {
|
|
15
|
-
const resp = await http(`${this.hostname}/oauth/device/code`, {
|
|
16
|
-
method: 'POST',
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json'
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify({
|
|
21
|
-
client_id: OAUTH_CLIENT_ID,
|
|
22
|
-
device_public_key: this.devicePublicKey,
|
|
23
|
-
system_information: this.systemInformation,
|
|
24
|
-
dotenvx_project_id: this.dotenvxProjectId
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const json = await resp.body.json()
|
|
29
|
-
|
|
30
|
-
if (resp.statusCode >= 400) {
|
|
31
|
-
throw buildOauthError(resp.statusCode, json)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return json
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = PostOauthDeviceCode
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildOauthError = require('../helpers/buildOauthError')
|
|
3
|
-
|
|
4
|
-
const OAUTH_CLIENT_ID = 'oac_dotenvxcli'
|
|
5
|
-
|
|
6
|
-
class PostOauthToken {
|
|
7
|
-
constructor (hostname, deviceCode) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.deviceCode = deviceCode
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async run () {
|
|
13
|
-
const resp = await http(`${this.hostname}/oauth/token`, {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/json'
|
|
17
|
-
},
|
|
18
|
-
body: JSON.stringify({
|
|
19
|
-
client_id: OAUTH_CLIENT_ID,
|
|
20
|
-
device_code: this.deviceCode,
|
|
21
|
-
grant_type: 'urn:ietf:params:oauth:grant-type:device_code'
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const json = await resp.body.json()
|
|
26
|
-
|
|
27
|
-
if (resp.statusCode >= 400) {
|
|
28
|
-
throw buildOauthError(resp.statusCode, json)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return json
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = PostOauthToken
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class PostTeamInvitation {
|
|
6
|
-
constructor (hostname, token, team, email) {
|
|
7
|
-
this.hostname = hostname
|
|
8
|
-
this.token = token
|
|
9
|
-
this.team = team
|
|
10
|
-
this.email = email
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async run () {
|
|
14
|
-
const resp = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/invitations`, {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
headers: {
|
|
17
|
-
Authorization: `Bearer ${normalizeToken(this.token)}`,
|
|
18
|
-
'Content-Type': 'application/json'
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify({ email: this.email, role: 'member' })
|
|
21
|
-
})
|
|
22
|
-
const json = await resp.body.json()
|
|
23
|
-
if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
|
|
24
|
-
return json
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = PostTeamInvitation
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class TeamConnectionSetup {
|
|
6
|
-
constructor (hostname, token, team) {
|
|
7
|
-
this.url = `${hostname}/api/teams/${encodeURIComponent(team)}/connections/setup`
|
|
8
|
-
this.token = token
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async request (suffix, options) {
|
|
12
|
-
const response = await http(`${this.url}${suffix}`, {
|
|
13
|
-
...options,
|
|
14
|
-
headers: { Authorization: `Bearer ${normalizeToken(this.token)}`, 'Content-Type': 'application/json' },
|
|
15
|
-
signal: AbortSignal.timeout(30000)
|
|
16
|
-
})
|
|
17
|
-
const json = await response.body.json()
|
|
18
|
-
if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
|
|
19
|
-
return json
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
create (service) {
|
|
23
|
-
return this.request('', { method: 'POST', body: JSON.stringify({ service }) })
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
status (id) {
|
|
27
|
-
return this.request(`/${encodeURIComponent(id)}`, { method: 'GET' })
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = TeamConnectionSetup
|
package/src/lib/config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/lib/config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('./main.js').config()
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const canonicalEnvFilename = require('../helpers/canonicalEnvFilename')
|
|
2
|
-
|
|
3
|
-
function environment (filepath) {
|
|
4
|
-
const filename = canonicalEnvFilename(filepath)
|
|
5
|
-
|
|
6
|
-
const parts = filename.split('.')
|
|
7
|
-
const possibleEnvironmentList = [...parts.slice(2)]
|
|
8
|
-
|
|
9
|
-
if (possibleEnvironmentList.length === 0) {
|
|
10
|
-
// handle .env1 -> development1
|
|
11
|
-
const environment = filename.replace('.env', 'development')
|
|
12
|
-
|
|
13
|
-
return environment
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (possibleEnvironmentList.length === 1) {
|
|
17
|
-
return possibleEnvironmentList[0]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (possibleEnvironmentList.length === 2) {
|
|
21
|
-
return possibleEnvironmentList.join('_')
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return possibleEnvironmentList.slice(0, 2).join('_')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = environment
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { scan } = require('@dotenvx/primitives')
|
|
2
|
-
const canonicalEnvFilename = require('../helpers/canonicalEnvFilename')
|
|
3
|
-
const environment = require('./environment')
|
|
4
|
-
|
|
5
|
-
function keynames (filepath = '.env', src = '') {
|
|
6
|
-
const { parsed } = scan(src)
|
|
7
|
-
|
|
8
|
-
// src public key name wins
|
|
9
|
-
for (const publicKeyName in parsed) {
|
|
10
|
-
if (publicKeyName.startsWith('DOTENV_PUBLIC_KEY')) {
|
|
11
|
-
return {
|
|
12
|
-
publicKeyName,
|
|
13
|
-
privateKeyName: publicKeyName.replace('DOTENV_PUBLIC_KEY', 'DOTENV_PRIVATE_KEY')
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const filename = canonicalEnvFilename(filepath)
|
|
19
|
-
|
|
20
|
-
// .env
|
|
21
|
-
if (filename === '.env') {
|
|
22
|
-
return {
|
|
23
|
-
publicKeyName: 'DOTENV_PUBLIC_KEY',
|
|
24
|
-
privateKeyName: 'DOTENV_PRIVATE_KEY'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// .env.ENVIRONMENT
|
|
29
|
-
const resolvedEnvironment = environment(filename).toUpperCase()
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
publicKeyName: `DOTENV_PUBLIC_KEY_${resolvedEnvironment}`,
|
|
33
|
-
privateKeyName: `DOTENV_PRIVATE_KEY_${resolvedEnvironment}`
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = keynames
|
|
38
|
-
module.exports.keynames = keynames
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const nativeProviders = { darwin: 'macosKeychain', win32: 'windowsCredentialManager', linux: 'linuxSecretService' }
|
|
2
|
-
|
|
3
|
-
// Explicit registration keeps bundling predictable and avoids executing
|
|
4
|
-
// arbitrary modules discovered in a project's working directory.
|
|
5
|
-
const builtins = [
|
|
6
|
-
require('./local/native'),
|
|
7
|
-
require('./local/onepassword'),
|
|
8
|
-
require('./local/bitwarden'),
|
|
9
|
-
require('./local/file'),
|
|
10
|
-
require('./managed/armor')
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
function createRegistry (custodians) {
|
|
14
|
-
const entries = new Map()
|
|
15
|
-
for (const custodian of custodians) {
|
|
16
|
-
if (!custodian || typeof custodian.id !== 'string' || !custodian.id || entries.has(custodian.id)) {
|
|
17
|
-
throw new Error('custodians must have unique, nonempty ids')
|
|
18
|
-
}
|
|
19
|
-
for (const method of ['enabled', 'available', 'store']) {
|
|
20
|
-
if (typeof custodian[method] !== 'function') throw new Error(`custodian ${custodian.id} requires ${method}()`)
|
|
21
|
-
}
|
|
22
|
-
entries.set(custodian.id, custodian)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function get (id) {
|
|
26
|
-
const custodian = entries.get(id)
|
|
27
|
-
if (!custodian) throw new Error(`unknown custodian: ${id}`)
|
|
28
|
-
return custodian
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
get,
|
|
33
|
-
async choices (options = {}, custody = 'local') {
|
|
34
|
-
const choices = []
|
|
35
|
-
for (const custodian of entries.values()) {
|
|
36
|
-
if ((custodian.custody || 'local') !== custody) continue
|
|
37
|
-
choices.push({ name: custodian.name, value: custodian.id, disabled: !custodian.enabled(options) || !await custodian.available() })
|
|
38
|
-
}
|
|
39
|
-
return choices
|
|
40
|
-
},
|
|
41
|
-
providers (options = {}, sync = false) {
|
|
42
|
-
const providers = []
|
|
43
|
-
for (const custodian of entries.values()) {
|
|
44
|
-
if (custodian.custody === 'managed') continue
|
|
45
|
-
const method = sync ? 'getSync' : 'get'
|
|
46
|
-
if (!custodian.enabled(options) || !custodian.get || (custodian.configured && !custodian.configured())) continue
|
|
47
|
-
if (typeof custodian[method] !== 'function') throw new Error(`custodian ${custodian.id} does not support synchronous reads`)
|
|
48
|
-
function found (publicKey, ring) {
|
|
49
|
-
if (ring && ring[publicKey] && options.onProvider) {
|
|
50
|
-
const name = custodian.id === 'native' ? nativeProviders[process.platform] || custodian.id : custodian.id
|
|
51
|
-
options.onProvider(name, publicKey)
|
|
52
|
-
}
|
|
53
|
-
return ring
|
|
54
|
-
}
|
|
55
|
-
const provider = sync
|
|
56
|
-
? publicKey => found(publicKey, custodian[method](publicKey))
|
|
57
|
-
: async publicKey => found(publicKey, await custodian[method](publicKey))
|
|
58
|
-
providers.push(provider)
|
|
59
|
-
}
|
|
60
|
-
return providers
|
|
61
|
-
},
|
|
62
|
-
async store (selection, publicKey, privateKey, context = {}) {
|
|
63
|
-
const { id } = typeof selection === 'string' ? { id: selection } : selection
|
|
64
|
-
const custodian = get(id)
|
|
65
|
-
const result = await custodian.store(publicKey, privateKey, context) || {}
|
|
66
|
-
// Only the native custodian's unavailable-write path requests fallback.
|
|
67
|
-
// Authentication and verification errors propagate without writing a file.
|
|
68
|
-
if (result.fallback) return get(result.fallback).store(publicKey, privateKey, context)
|
|
69
|
-
return result
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = createRegistry(builtins)
|
|
75
|
-
module.exports.createRegistry = createRegistry
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
const { bitwarden } = require('@dotenvx/providers')
|
|
2
|
-
const { execFile } = require('child_process')
|
|
3
|
-
const matchesStoredKey = require('../../helpers/matchesStoredKey')
|
|
4
|
-
const Session = require('../../../db/session')
|
|
5
|
-
const prompts = require('../../helpers/prompts')
|
|
6
|
-
const createSpinner = require('../../helpers/createSpinner')
|
|
7
|
-
let unlockedSession
|
|
8
|
-
|
|
9
|
-
const armoredKeyDisplay = require('../../helpers/armoredKeyDisplay')
|
|
10
|
-
|
|
11
|
-
const PREFIX = 'DOTENVX_BITWARDEN_'
|
|
12
|
-
const ID = /^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i
|
|
13
|
-
const COMMAND_OPTIONS = { encoding: 'utf8', windowsHide: true, timeout: 120000, killSignal: 'SIGKILL', maxBuffer: 1024 * 1024 }
|
|
14
|
-
|
|
15
|
-
function failure (message) {
|
|
16
|
-
const error = new Error(message)
|
|
17
|
-
error.code = 'BITWARDEN_FAILED'
|
|
18
|
-
return error
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function commandFailure () {
|
|
22
|
-
return failure('Bitwarden CLI operation failed; check sign-in and unlock your vault with BW_SESSION')
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function run (args, input, timeout = COMMAND_OPTIONS.timeout, env = commandEnv()) {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
const child = execFile('bw', [...args, '--nointeraction'], { ...COMMAND_OPTIONS, timeout, env }, (error, stdout) => {
|
|
28
|
-
if (error) reject(commandFailure())
|
|
29
|
-
else resolve(stdout)
|
|
30
|
-
})
|
|
31
|
-
if (child.stdin) {
|
|
32
|
-
child.stdin.on('error', () => {})
|
|
33
|
-
child.stdin.end(input)
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parse (value) {
|
|
39
|
-
try { return JSON.parse(value) } catch {
|
|
40
|
-
throw failure('Bitwarden CLI returned an invalid response')
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function available () {
|
|
45
|
-
try { return /^\d+\.\d+\.\d+/.test((await run(['--version'], undefined, 2000)).trim()) } catch { return false }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function configured () {
|
|
49
|
-
const store = new Session().openStore()
|
|
50
|
-
return !!store && Object.keys(store.store).some(key => key.startsWith(PREFIX))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function location (publicKey) {
|
|
54
|
-
const store = new Session().openStore()
|
|
55
|
-
const value = store && store.get(`${PREFIX}${publicKey}`)
|
|
56
|
-
if (!value) return null
|
|
57
|
-
// Base64 keeps the nonsecret JSON locator safe in the dotenv settings file.
|
|
58
|
-
const loc = parse(Buffer.from(String(value), 'base64').toString('utf8'))
|
|
59
|
-
if (!loc || !ID.test(loc.item || '') || !ID.test(loc.userId || '') || typeof loc.serverUrl !== 'string') {
|
|
60
|
-
throw failure('invalid Bitwarden private-key reference in dotenvx settings')
|
|
61
|
-
}
|
|
62
|
-
return loc
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function commandEnv () {
|
|
66
|
-
return { ...process.env, ...(unlockedSession ? { BW_SESSION: unlockedSession } : {}) }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function authenticate (loc) {
|
|
70
|
-
let status = parse(await run(['status']))
|
|
71
|
-
if (loc && status && status.userId && (status.userId !== loc.userId || (status.serverUrl || '') !== loc.serverUrl)) {
|
|
72
|
-
throw failure('Bitwarden account or server does not match the stored private-key reference')
|
|
73
|
-
}
|
|
74
|
-
if (status && status.status === 'unlocked') return checkIdentity(status, loc)
|
|
75
|
-
unlockedSession = undefined
|
|
76
|
-
if (status && status.status === 'unauthenticated') throw failure('Sign in to Bitwarden once with bw login, then retry; dotenvx will prompt to unlock your vault')
|
|
77
|
-
if (!status || status.status !== 'locked') throw commandFailure()
|
|
78
|
-
if (!process.stdin.isTTY || !process.stderr.isTTY || process.env.CI) {
|
|
79
|
-
throw failure('Bitwarden is locked; set an unlocked BW_SESSION for noninteractive use')
|
|
80
|
-
}
|
|
81
|
-
let password
|
|
82
|
-
createSpinner.pause()
|
|
83
|
-
try {
|
|
84
|
-
password = await prompts.password({ message: 'Bitwarden master password', prefix: '◇', separator: '=' }, { input: process.stdin, output: process.stderr })
|
|
85
|
-
} finally {
|
|
86
|
-
createSpinner.resume()
|
|
87
|
-
}
|
|
88
|
-
const passwordEnv = 'DOTENVX_BITWARDEN_PASSWORD'
|
|
89
|
-
const session = (await run(['unlock', '--passwordenv', passwordEnv, '--raw'], undefined, COMMAND_OPTIONS.timeout, { ...process.env, [passwordEnv]: password })).trim()
|
|
90
|
-
if (!session) throw commandFailure()
|
|
91
|
-
unlockedSession = session
|
|
92
|
-
try {
|
|
93
|
-
status = parse(await run(['status']))
|
|
94
|
-
return checkIdentity(status, loc)
|
|
95
|
-
} catch (error) {
|
|
96
|
-
unlockedSession = undefined
|
|
97
|
-
throw error
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function checkIdentity (status, loc) {
|
|
102
|
-
if (!status || status.status !== 'unlocked' || !ID.test(status.userId || '')) throw commandFailure()
|
|
103
|
-
if (loc && (status.userId !== loc.userId || (status.serverUrl || '') !== loc.serverUrl)) {
|
|
104
|
-
throw failure('Bitwarden account or server does not match the stored private-key reference')
|
|
105
|
-
}
|
|
106
|
-
return status
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function verified (publicKey, privateKey) {
|
|
110
|
-
try { if (matchesStoredKey(publicKey, privateKey)) return { [publicKey]: privateKey } } catch {}
|
|
111
|
-
throw failure('Bitwarden private key does not match the .env public key')
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function get (publicKey) {
|
|
115
|
-
const loc = location(publicKey)
|
|
116
|
-
if (!loc) return {}
|
|
117
|
-
await authenticate(loc)
|
|
118
|
-
return bitwarden({ processEnv: commandEnv() }).get(publicKey)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getSync (publicKey) {
|
|
122
|
-
return bitwarden({ processEnv: commandEnv() }).getSync(publicKey)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function set (publicKey, privateKey) {
|
|
126
|
-
verified(publicKey, privateKey)
|
|
127
|
-
if (location(publicKey)) {
|
|
128
|
-
await get(publicKey)
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
const status = await authenticate()
|
|
132
|
-
const template = {
|
|
133
|
-
organizationId: null,
|
|
134
|
-
collectionIds: [],
|
|
135
|
-
folderId: null,
|
|
136
|
-
type: 1,
|
|
137
|
-
name: `dotenvx (${armoredKeyDisplay(publicKey)})`,
|
|
138
|
-
notes: null,
|
|
139
|
-
favorite: false,
|
|
140
|
-
fields: [{ name: 'public_key', value: publicKey, type: 0 }],
|
|
141
|
-
login: { username: 'private_key', password: privateKey, totp: null, uris: [] }
|
|
142
|
-
}
|
|
143
|
-
// Pass encoded JSON on stdin, never secrets in command arguments or files.
|
|
144
|
-
const item = parse(await run(['create', 'item'], Buffer.from(JSON.stringify(template)).toString('base64')))
|
|
145
|
-
if (!item || !ID.test(item.id || '') || item.organizationId) throw failure('Bitwarden did not return a personal vault item')
|
|
146
|
-
const saved = (await run(['get', 'password', item.id])).trim()
|
|
147
|
-
verified(publicKey, saved)
|
|
148
|
-
if (saved !== privateKey) throw failure('could not verify private key in Bitwarden')
|
|
149
|
-
const loc = { item: item.id, userId: status.userId, serverUrl: status.serverUrl || '' }
|
|
150
|
-
new Session().createStore().set(`${PREFIX}${publicKey}`, Buffer.from(JSON.stringify(loc)).toString('base64'))
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function remove (publicKey) {
|
|
154
|
-
const loc = location(publicKey)
|
|
155
|
-
if (!loc) return
|
|
156
|
-
await authenticate(loc)
|
|
157
|
-
await run(['delete', 'item', loc.item])
|
|
158
|
-
new Session().openStore().delete(`${PREFIX}${publicKey}`)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function enabled (options = {}) {
|
|
162
|
-
return options.noBitwarden !== true && process.env.DOTENVX_NO_BITWARDEN !== 'true'
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
module.exports = { id: 'bitwarden', name: 'Bitwarden', enabled, store: set, available, configured, get, getSync, set, delete: remove, commandEnv }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { mutateKeysSrc } = require('../../helpers/cryptography')
|
|
2
|
-
|
|
3
|
-
// File keys are loaded by envResolution before provider lookup. Creation is
|
|
4
|
-
// staged here so the caller can commit .env.keys with the encrypted env files.
|
|
5
|
-
module.exports = {
|
|
6
|
-
id: 'file',
|
|
7
|
-
name: 'File (.env.keys)',
|
|
8
|
-
enabled: () => true,
|
|
9
|
-
available: () => true,
|
|
10
|
-
store (publicKey, privateKey, context) {
|
|
11
|
-
return mutateKeysSrc({
|
|
12
|
-
keysSrc: context.keysSrc,
|
|
13
|
-
privateKeyName: context.privateKeyName,
|
|
14
|
-
privateKeyValue: privateKey,
|
|
15
|
-
comment: context.comment
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|