@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
package/src/db/device.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const { Conf } = require('@dotenvx/tooling')
|
|
2
|
-
const { derive, keypair } = require('@dotenvx/primitives')
|
|
3
|
-
|
|
4
|
-
const encryptDeviceValue = require('./../lib/helpers/encryptDeviceValue')
|
|
5
|
-
const decryptDeviceValue = require('./../lib/helpers/decryptDeviceValue')
|
|
6
|
-
|
|
7
|
-
class Device {
|
|
8
|
-
constructor () {
|
|
9
|
-
this.store = new Conf({
|
|
10
|
-
cwd: process.env.DOTENVX_CONFIG || undefined,
|
|
11
|
-
projectName: 'dotenvx',
|
|
12
|
-
configName: '.device-key',
|
|
13
|
-
projectSuffix: '',
|
|
14
|
-
fileExtension: '',
|
|
15
|
-
encryptionKey: 'dotenvxpro dotenvxpro dotenvxpro' // backwards compatible
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
touch () {
|
|
20
|
-
const _privateKey = this.privateKey()
|
|
21
|
-
const _publicKey = this.publicKey()
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
privateKey: _privateKey,
|
|
25
|
-
publicKey: _publicKey
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
configPath () {
|
|
30
|
-
return this.store.path
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
privateKey () {
|
|
34
|
-
const currentPrivateKey = this.store.get('private_key/1')
|
|
35
|
-
if (currentPrivateKey && currentPrivateKey.length > 0) {
|
|
36
|
-
this.store.set('private_key/1', currentPrivateKey)
|
|
37
|
-
|
|
38
|
-
return currentPrivateKey
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const _privateKey = keypair().privateKey
|
|
42
|
-
|
|
43
|
-
this.store.set('private_key/1', _privateKey)
|
|
44
|
-
|
|
45
|
-
return _privateKey
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
publicKey () {
|
|
49
|
-
// must have private key to try and get public key
|
|
50
|
-
const privateKeyHex = this.privateKey()
|
|
51
|
-
if (!privateKeyHex || privateKeyHex.length < 1) {
|
|
52
|
-
return ''
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return derive(privateKeyHex)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
encrypt (value) {
|
|
59
|
-
return encryptDeviceValue(value, this.publicKey())
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
decrypt (value) {
|
|
63
|
-
return decryptDeviceValue(value, this.privateKey())
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = Device
|
package/src/db/session.js
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const { Conf, dotenv, envPaths } = require('@dotenvx/tooling')
|
|
4
|
-
|
|
5
|
-
const jsonToEnv = require('./../lib/helpers/jsonToEnv')
|
|
6
|
-
const packageJson = require('./../lib/helpers/packageJson')
|
|
7
|
-
const { http } = require('./../lib/helpers/http')
|
|
8
|
-
const nativeProvider = require('./../lib/custodians/local/native/backend')
|
|
9
|
-
const { logger } = require('./../shared/logger')
|
|
10
|
-
|
|
11
|
-
const HOURS_24 = 60 * 60 * 24 * 1000
|
|
12
|
-
const VERSION_URL = 'https://dotenvx.sh/VERSION'
|
|
13
|
-
|
|
14
|
-
const ARMOR = {
|
|
15
|
-
HOSTNAME: 'DOTENVX_ARMOR_HOSTNAME',
|
|
16
|
-
USER: 'DOTENVX_ARMOR_USER',
|
|
17
|
-
USERNAME: 'DOTENVX_ARMOR_USERNAME',
|
|
18
|
-
TOKEN: 'DOTENVX_ARMOR_TOKEN',
|
|
19
|
-
ON: 'DOTENVX_ARMOR_ON'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const DOTENVX = {
|
|
23
|
-
VERSION: 'DOTENVX_VERSION',
|
|
24
|
-
VERSION_LAST_CHECK: 'DOTENVX_VERSION_LAST_CHECK'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function normalizeVersion (version) {
|
|
28
|
-
return String(version || '').trim().replace(/^v/, '')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function parseVersion (version) {
|
|
32
|
-
return normalizeVersion(version).split('.').map(part => Number.parseInt(part, 10) || 0)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function versionGreaterThan (left, right) {
|
|
36
|
-
const leftParts = parseVersion(left)
|
|
37
|
-
const rightParts = parseVersion(right)
|
|
38
|
-
|
|
39
|
-
for (let i = 0; i < Math.max(leftParts.length, rightParts.length); i++) {
|
|
40
|
-
const leftPart = leftParts[i] || 0
|
|
41
|
-
const rightPart = rightParts[i] || 0
|
|
42
|
-
|
|
43
|
-
if (leftPart > rightPart) return true
|
|
44
|
-
if (leftPart < rightPart) return false
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return false
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class Session {
|
|
51
|
-
constructor () {
|
|
52
|
-
this._store = null
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_configPath () {
|
|
56
|
-
const cwd = process.env.DOTENVX_CONFIG || this._defaultConfigCwd()
|
|
57
|
-
return path.resolve(cwd, '.env')
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_defaultConfigCwd () {
|
|
61
|
-
return envPaths('dotenvx', { suffix: '' }).config
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
_configExists () {
|
|
65
|
-
return fs.existsSync(this._configPath())
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
_newStore () {
|
|
69
|
-
return new Conf({
|
|
70
|
-
cwd: process.env.DOTENVX_CONFIG || undefined,
|
|
71
|
-
projectName: 'dotenvx',
|
|
72
|
-
configName: '.env',
|
|
73
|
-
projectSuffix: '',
|
|
74
|
-
fileExtension: '',
|
|
75
|
-
serialize: function (json) {
|
|
76
|
-
return jsonToEnv(json)
|
|
77
|
-
},
|
|
78
|
-
// Convert .env format to an object
|
|
79
|
-
deserialize: function (env) {
|
|
80
|
-
return dotenv.parse(env)
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
createStore () {
|
|
86
|
-
if (!this._store) this._store = this._newStore()
|
|
87
|
-
return this._store
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
openStore () {
|
|
91
|
-
if (!this._store && !this._configExists()) {
|
|
92
|
-
return null
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!this._store) this._store = this._newStore()
|
|
96
|
-
return this._store
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
get store () {
|
|
100
|
-
return this.openStore()
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
status () {
|
|
104
|
-
// if logged in
|
|
105
|
-
if (this.username() && this.token() && this.on()) {
|
|
106
|
-
return 'on'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return 'off'
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
// Get
|
|
114
|
-
//
|
|
115
|
-
readSetting (key) {
|
|
116
|
-
const store = this.openStore()
|
|
117
|
-
if (!store) return undefined
|
|
118
|
-
|
|
119
|
-
return store.get(ARMOR[key])
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
readDotenvxSetting (key) {
|
|
123
|
-
const store = this.openStore()
|
|
124
|
-
if (!store) return undefined
|
|
125
|
-
|
|
126
|
-
return store.get(DOTENVX[key])
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
hostname () {
|
|
130
|
-
return this.readSetting('HOSTNAME') || 'https://armor.dotenvx.com'
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
username () {
|
|
134
|
-
return this.readSetting('USERNAME') || undefined
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
token () {
|
|
138
|
-
return this.getFromSecretStore(ARMOR.TOKEN) || undefined
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
on () {
|
|
142
|
-
return (this.readSetting('ON') || 'true') === 'true'
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
off () {
|
|
146
|
-
return (this.readSetting('ON') || 'true') === 'false'
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
devicePublicKey () {
|
|
150
|
-
const Device = require('./device')
|
|
151
|
-
return new Device().publicKey()
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
path () {
|
|
155
|
-
return this._store ? this._store.path : this._configPath()
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async systemInformation () {
|
|
159
|
-
const { systeminformation } = require('@dotenvx/tooling')
|
|
160
|
-
const system = await systeminformation.system()
|
|
161
|
-
const osInfo = await systeminformation.osInfo()
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
system_uuid: system.uuid,
|
|
165
|
-
os_platform: osInfo.platform,
|
|
166
|
-
os_arch: osInfo.arch
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
// Notify Update
|
|
172
|
-
//
|
|
173
|
-
async notifyUpdate () {
|
|
174
|
-
try {
|
|
175
|
-
const store = this.openStore()
|
|
176
|
-
if (!store) return
|
|
177
|
-
|
|
178
|
-
logger.debug('checking if update available')
|
|
179
|
-
|
|
180
|
-
const lastCheck = Number(this.readDotenvxSetting('VERSION_LAST_CHECK') || 0)
|
|
181
|
-
const now = Date.now()
|
|
182
|
-
|
|
183
|
-
if ((lastCheck + HOURS_24) >= now) return
|
|
184
|
-
|
|
185
|
-
let remote = packageJson.version
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
logger.debug('fetching latest available dotenvx version')
|
|
189
|
-
const response = await http(VERSION_URL)
|
|
190
|
-
remote = normalizeVersion(await response.body.text())
|
|
191
|
-
logger.debug(`latest dotenvx version: ${remote}`)
|
|
192
|
-
store.set(DOTENVX.VERSION, remote)
|
|
193
|
-
} catch (error) {
|
|
194
|
-
logger.debug(error.message)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
store.set(DOTENVX.VERSION_LAST_CHECK, now)
|
|
198
|
-
|
|
199
|
-
if (versionGreaterThan(remote, packageJson.version)) {
|
|
200
|
-
console.error('⛆ update available [curl -sfS https://dotenvx.sh | sh]')
|
|
201
|
-
}
|
|
202
|
-
} catch (error) {
|
|
203
|
-
logger.debug(error.message)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
//
|
|
208
|
-
// armor status helpers
|
|
209
|
-
//
|
|
210
|
-
async noArmor () {
|
|
211
|
-
if (process.env.DOTENVX_NO_ARMOR === 'true') {
|
|
212
|
-
logger.debug('armor: off')
|
|
213
|
-
return true
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const status = this.status()
|
|
217
|
-
logger.debug(`armor: ${status}`)
|
|
218
|
-
return status === 'off'
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
noArmorSync () {
|
|
222
|
-
if (process.env.DOTENVX_NO_ARMOR === 'true') {
|
|
223
|
-
logger.debug('armor: off')
|
|
224
|
-
return true
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const status = this.status()
|
|
228
|
-
logger.debug(`armor: ${status}`)
|
|
229
|
-
return status === 'off'
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
// Set/Delete
|
|
234
|
-
//
|
|
235
|
-
getFromSecretStore (key) {
|
|
236
|
-
try {
|
|
237
|
-
const value = nativeProvider.get(key)
|
|
238
|
-
if (value) return value
|
|
239
|
-
} catch {}
|
|
240
|
-
|
|
241
|
-
const store = this.openStore()
|
|
242
|
-
if (!store) return undefined
|
|
243
|
-
|
|
244
|
-
return store.get(key)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
setInSecretStore (key, value) {
|
|
248
|
-
try {
|
|
249
|
-
nativeProvider.set(key, value)
|
|
250
|
-
return value
|
|
251
|
-
} catch {
|
|
252
|
-
this.createStore().set(key, value)
|
|
253
|
-
return value
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
deleteFromSecretStore (key) {
|
|
258
|
-
try {
|
|
259
|
-
nativeProvider.delete(key)
|
|
260
|
-
} catch {}
|
|
261
|
-
|
|
262
|
-
const store = this.openStore()
|
|
263
|
-
if (store) store.delete(key)
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
turnOn () {
|
|
267
|
-
this.createStore().set(ARMOR.ON, 'true')
|
|
268
|
-
return 'true'
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
turnOff () {
|
|
272
|
-
this.createStore().set(ARMOR.ON, 'false')
|
|
273
|
-
return 'false'
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
login (hostname, id, username, accessToken) {
|
|
277
|
-
if (!hostname) {
|
|
278
|
-
throw new Error('DOTENVX_ARMOR_HOSTNAME not set. Run [dotenvx armor login]')
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (!id) {
|
|
282
|
-
throw new Error('DOTENVX_ARMOR_USER not set. Run [dotenvx armor login]')
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
if (!username) {
|
|
286
|
-
throw new Error('DOTENVX_ARMOR_USERNAME not set. Run [dotenvx armor login]')
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (!accessToken) {
|
|
290
|
-
throw new Error('DOTENVX_ARMOR_TOKEN not set. Run [dotenvx armor login]')
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const store = this.createStore()
|
|
294
|
-
store.set(ARMOR.USER, id)
|
|
295
|
-
store.set(ARMOR.USERNAME, username)
|
|
296
|
-
this.setInSecretStore(ARMOR.TOKEN, accessToken)
|
|
297
|
-
store.set(ARMOR.HOSTNAME, hostname)
|
|
298
|
-
store.set(ARMOR.ON, 'true')
|
|
299
|
-
|
|
300
|
-
return accessToken
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
logout (hostname, id, accessToken) {
|
|
304
|
-
if (!hostname) {
|
|
305
|
-
throw new Error('DOTENVX_ARMOR_HOSTNAME not set. Run [dotenvx armor login]')
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (!id) {
|
|
309
|
-
throw new Error('DOTENVX_ARMOR_USER not set. Run [dotenvx armor login]')
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (!accessToken) {
|
|
313
|
-
throw new Error('DOTENVX_ARMOR_TOKEN not set. Run [dotenvx armor login]')
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
this.deleteFromSecretStore(ARMOR.TOKEN)
|
|
317
|
-
|
|
318
|
-
const store = this.openStore()
|
|
319
|
-
if (!store) return true
|
|
320
|
-
store.delete(ARMOR.USER)
|
|
321
|
-
store.delete(ARMOR.USERNAME)
|
|
322
|
-
store.delete(ARMOR.HOSTNAME)
|
|
323
|
-
store.delete(ARMOR.ON)
|
|
324
|
-
store.delete(DOTENVX.VERSION)
|
|
325
|
-
store.delete(DOTENVX.VERSION_LAST_CHECK)
|
|
326
|
-
return true
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
module.exports = Session
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
|
|
4
|
-
class GetAccount {
|
|
5
|
-
constructor (hostname, token) {
|
|
6
|
-
this.hostname = hostname
|
|
7
|
-
this.token = token
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run () {
|
|
11
|
-
const token = this.token
|
|
12
|
-
const url = `${this.hostname}/api/account`
|
|
13
|
-
|
|
14
|
-
const resp = await http(url, {
|
|
15
|
-
method: 'GET',
|
|
16
|
-
headers: {
|
|
17
|
-
Authorization: `Bearer ${token}`,
|
|
18
|
-
'Content-Type': 'application/json'
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const json = await resp.body.json()
|
|
23
|
-
|
|
24
|
-
if (resp.statusCode >= 400) {
|
|
25
|
-
throw buildApiError(resp.statusCode, json)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return json
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = GetAccount
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class GetConnectionResources {
|
|
6
|
-
constructor (hostname, token, team, connectionId) {
|
|
7
|
-
this.url = `${hostname}/api/teams/${encodeURIComponent(team)}/connections/${encodeURIComponent(connectionId)}/resources`
|
|
8
|
-
this.token = token
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async run (query = '') {
|
|
12
|
-
const response = await http(`${this.url}?${new URLSearchParams({ q: query })}`, {
|
|
13
|
-
method: 'GET', headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
|
|
14
|
-
})
|
|
15
|
-
const json = await response.body.json()
|
|
16
|
-
if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
|
|
17
|
-
return json
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = GetConnectionResources
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const { http } = require('../helpers/http')
|
|
2
|
-
const buildApiError = require('../helpers/buildApiError')
|
|
3
|
-
const normalizeToken = require('../helpers/normalizeToken')
|
|
4
|
-
|
|
5
|
-
class GetTeamConnections {
|
|
6
|
-
constructor (hostname, token, team, service) {
|
|
7
|
-
Object.assign(this, { hostname, token, team, service })
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async run () {
|
|
11
|
-
const connections = []
|
|
12
|
-
let page = 1
|
|
13
|
-
while (page) {
|
|
14
|
-
const query = new URLSearchParams({ service: this.service, page })
|
|
15
|
-
const response = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/connections?${query}`, {
|
|
16
|
-
method: 'GET', headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
|
|
17
|
-
})
|
|
18
|
-
const json = await response.body.json()
|
|
19
|
-
if (response.statusCode >= 400) throw buildApiError(response.statusCode, json)
|
|
20
|
-
connections.push(...json.connections)
|
|
21
|
-
page = json.meta && json.meta.next_page
|
|
22
|
-
}
|
|
23
|
-
return { connections }
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = GetTeamConnections
|
|
@@ -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 GetTeamServices {
|
|
6
|
-
constructor (hostname, token, team) {
|
|
7
|
-
this.hostname = hostname
|
|
8
|
-
this.token = token
|
|
9
|
-
this.team = team
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async run () {
|
|
13
|
-
const resp = await http(`${this.hostname}/api/teams/${encodeURIComponent(this.team)}/services`, {
|
|
14
|
-
method: 'GET',
|
|
15
|
-
headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
|
|
16
|
-
})
|
|
17
|
-
const json = await resp.body.json()
|
|
18
|
-
if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
|
|
19
|
-
return json
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = GetTeamServices
|
package/src/lib/api/getTeams.js
DELETED
|
@@ -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 GetTeams {
|
|
6
|
-
constructor (hostname, token) {
|
|
7
|
-
this.hostname = hostname
|
|
8
|
-
this.token = token
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async run () {
|
|
12
|
-
const teams = []
|
|
13
|
-
let page = 1
|
|
14
|
-
while (page) {
|
|
15
|
-
const resp = await http(`${this.hostname}/api/teams?page=${page}`, {
|
|
16
|
-
method: 'GET',
|
|
17
|
-
headers: { Authorization: `Bearer ${normalizeToken(this.token)}` }
|
|
18
|
-
})
|
|
19
|
-
const json = await resp.body.json()
|
|
20
|
-
if (resp.statusCode >= 400) throw buildApiError(resp.statusCode, json)
|
|
21
|
-
teams.push(...json.teams)
|
|
22
|
-
page = json.meta && json.meta.next_page
|
|
23
|
-
}
|
|
24
|
-
return { teams }
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = GetTeams
|
|
@@ -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 PostArmorDown {
|
|
7
|
-
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.token = token
|
|
10
|
-
this.devicePublicKey = devicePublicKey
|
|
11
|
-
this.publicKey = publicKey
|
|
12
|
-
this.team = team
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run () {
|
|
16
|
-
const token = normalizeToken(this.token)
|
|
17
|
-
const devicePublicKey = this.devicePublicKey
|
|
18
|
-
const publicKey = this.publicKey
|
|
19
|
-
const team = this.team
|
|
20
|
-
const url = `${this.hostname}/api/armor/down`
|
|
21
|
-
|
|
22
|
-
const body = {
|
|
23
|
-
device_public_key: devicePublicKey,
|
|
24
|
-
cli_version: packageJson.version,
|
|
25
|
-
public_key: publicKey,
|
|
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 = PostArmorDown
|
|
@@ -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 PostArmorMove {
|
|
7
|
-
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.token = token
|
|
10
|
-
this.devicePublicKey = devicePublicKey
|
|
11
|
-
this.publicKey = publicKey
|
|
12
|
-
this.team = team
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run () {
|
|
16
|
-
const token = normalizeToken(this.token)
|
|
17
|
-
const devicePublicKey = this.devicePublicKey
|
|
18
|
-
const publicKey = this.publicKey
|
|
19
|
-
const team = this.team
|
|
20
|
-
const url = `${this.hostname}/api/armor/move`
|
|
21
|
-
|
|
22
|
-
const body = {
|
|
23
|
-
device_public_key: devicePublicKey,
|
|
24
|
-
cli_version: packageJson.version,
|
|
25
|
-
public_key: publicKey,
|
|
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 = PostArmorMove
|
|
@@ -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 PostArmorPull {
|
|
7
|
-
constructor (hostname, token, devicePublicKey, publicKey, team) {
|
|
8
|
-
this.hostname = hostname
|
|
9
|
-
this.token = token
|
|
10
|
-
this.devicePublicKey = devicePublicKey
|
|
11
|
-
this.publicKey = publicKey
|
|
12
|
-
this.team = team
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async run () {
|
|
16
|
-
const token = normalizeToken(this.token)
|
|
17
|
-
const devicePublicKey = this.devicePublicKey
|
|
18
|
-
const publicKey = this.publicKey
|
|
19
|
-
const team = this.team
|
|
20
|
-
const url = `${this.hostname}/api/armor/pull`
|
|
21
|
-
|
|
22
|
-
const body = {
|
|
23
|
-
device_public_key: devicePublicKey,
|
|
24
|
-
cli_version: packageJson.version,
|
|
25
|
-
public_key: publicKey,
|
|
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 = PostArmorPull
|