@dotenvx/dotenvx-vlt 0.49.0 → 0.49.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/CHANGELOG.md +9 -1
- package/package.json +1 -1
- package/src/db/session.js +60 -29
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.49.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx-ops/compare/v0.49.2...main)
|
|
6
|
+
|
|
7
|
+
## [0.49.2](https://github.com/dotenvx/dotenvx-ops/compare/v0.49.1...v0.49.2) (2026-05-25)
|
|
8
|
+
|
|
9
|
+
* Install vlt when installing ops ([#97](https://github.com/dotenvx/dotenvx-ops/pull/97))
|
|
10
|
+
|
|
11
|
+
## [0.49.1](https://github.com/dotenvx/dotenvx-ops/compare/v0.49.0...v0.49.1) (2026-05-25)
|
|
12
|
+
|
|
13
|
+
* Patch release mechanism ([#96](https://github.com/dotenvx/dotenvx-ops/pull/96))
|
|
6
14
|
|
|
7
15
|
## [0.49.0](https://github.com/dotenvx/dotenvx-ops/compare/v0.48.3...v0.49.0) (2026-05-25)
|
|
8
16
|
|
package/package.json
CHANGED
package/src/db/session.js
CHANGED
|
@@ -12,6 +12,26 @@ const GetVersion = require('./../lib/api/getVersion')
|
|
|
12
12
|
|
|
13
13
|
const HOURS_24 = 60 * 60 * 24 * 1000 // 24hrs in ms
|
|
14
14
|
|
|
15
|
+
const VLT = {
|
|
16
|
+
HOSTNAME: 'DOTENVX_VLT_HOSTNAME',
|
|
17
|
+
USER: 'DOTENVX_VLT_USER',
|
|
18
|
+
USERNAME: 'DOTENVX_VLT_USERNAME',
|
|
19
|
+
TOKEN: 'DOTENVX_VLT_TOKEN',
|
|
20
|
+
ON: 'DOTENVX_VLT_ON',
|
|
21
|
+
VERSION: 'DOTENVX_VLT_VERSION',
|
|
22
|
+
VERSION_LAST_CHECK: 'DOTENVX_VLT_VERSION_LAST_CHECK'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const OPS = {
|
|
26
|
+
HOSTNAME: 'DOTENVX_OPS_HOSTNAME',
|
|
27
|
+
USER: 'DOTENVX_OPS_USER',
|
|
28
|
+
USERNAME: 'DOTENVX_OPS_USERNAME',
|
|
29
|
+
TOKEN: 'DOTENVX_OPS_TOKEN',
|
|
30
|
+
ON: 'DOTENVX_OPS_ON',
|
|
31
|
+
VERSION: 'DOTENVX_OPS_VERSION',
|
|
32
|
+
VERSION_LAST_CHECK: 'DOTENVX_OPS_VERSION_LAST_CHECK'
|
|
33
|
+
}
|
|
34
|
+
|
|
15
35
|
class Session {
|
|
16
36
|
constructor () {
|
|
17
37
|
this.store = new Conf({
|
|
@@ -42,16 +62,20 @@ class Session {
|
|
|
42
62
|
//
|
|
43
63
|
// Get
|
|
44
64
|
//
|
|
65
|
+
getSetting (key) {
|
|
66
|
+
return this.store.get(VLT[key]) || this.store.get(OPS[key])
|
|
67
|
+
}
|
|
68
|
+
|
|
45
69
|
hostname () {
|
|
46
|
-
return this.
|
|
70
|
+
return this.getSetting('HOSTNAME') || 'https://ops.dotenvx.com'
|
|
47
71
|
}
|
|
48
72
|
|
|
49
73
|
username () {
|
|
50
|
-
return this.
|
|
74
|
+
return this.getSetting('USERNAME') || undefined
|
|
51
75
|
}
|
|
52
76
|
|
|
53
77
|
token () {
|
|
54
|
-
return this.
|
|
78
|
+
return this.getSetting('TOKEN') || undefined
|
|
55
79
|
}
|
|
56
80
|
|
|
57
81
|
devicePublicKey () {
|
|
@@ -63,11 +87,11 @@ class Session {
|
|
|
63
87
|
}
|
|
64
88
|
|
|
65
89
|
on () {
|
|
66
|
-
return (this.
|
|
90
|
+
return (this.getSetting('ON') || 'true') === 'true'
|
|
67
91
|
}
|
|
68
92
|
|
|
69
93
|
off () {
|
|
70
|
-
return (this.
|
|
94
|
+
return (this.getSetting('ON') || 'true') === 'false'
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
async systemInformation () {
|
|
@@ -88,7 +112,7 @@ class Session {
|
|
|
88
112
|
try {
|
|
89
113
|
logger.debug('checking if update available')
|
|
90
114
|
|
|
91
|
-
const lastCheck = Number(this.
|
|
115
|
+
const lastCheck = Number(this.getSetting('VERSION_LAST_CHECK') || 0)
|
|
92
116
|
const now = Date.now()
|
|
93
117
|
|
|
94
118
|
// 24 hours have passed
|
|
@@ -102,13 +126,13 @@ class Session {
|
|
|
102
126
|
logger.debug(`latest version: ${VERSION}`)
|
|
103
127
|
|
|
104
128
|
remote = VERSION
|
|
105
|
-
this.store.set(
|
|
129
|
+
this.store.set(VLT.VERSION, VERSION) // remote version
|
|
106
130
|
} catch (err) {
|
|
107
131
|
// noop
|
|
108
132
|
logger.debug(err.message)
|
|
109
133
|
}
|
|
110
134
|
|
|
111
|
-
this.store.set(
|
|
135
|
+
this.store.set(VLT.VERSION_LAST_CHECK, now) // record check
|
|
112
136
|
|
|
113
137
|
if (semver.gt(remote, local)) {
|
|
114
138
|
const diff = semver.diff(local, remote)
|
|
@@ -126,50 +150,57 @@ class Session {
|
|
|
126
150
|
//
|
|
127
151
|
login (hostname, id, username, accessToken) {
|
|
128
152
|
if (!hostname) {
|
|
129
|
-
throw new Error('
|
|
153
|
+
throw new Error('DOTENVX_VLT_HOSTNAME not set. Run [dotenvx-vlt login]')
|
|
130
154
|
}
|
|
131
155
|
|
|
132
156
|
if (!id) {
|
|
133
|
-
throw new Error('
|
|
157
|
+
throw new Error('DOTENVX_VLT_USER not set. Run [dotenvx-vlt login]')
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
if (!username) {
|
|
137
|
-
throw new Error('
|
|
161
|
+
throw new Error('DOTENVX_VLT_USERNAME not set. Run [dotenvx-vlt login]')
|
|
138
162
|
}
|
|
139
163
|
|
|
140
164
|
if (!accessToken) {
|
|
141
|
-
throw new Error('
|
|
165
|
+
throw new Error('DOTENVX_VLT_TOKEN not set. Run [dotenvx-vlt login]')
|
|
142
166
|
}
|
|
143
167
|
|
|
144
|
-
this.store.set(
|
|
145
|
-
this.store.set(
|
|
146
|
-
this.store.set(
|
|
147
|
-
this.store.set(
|
|
148
|
-
this.store.set(
|
|
168
|
+
this.store.set(VLT.USER, id)
|
|
169
|
+
this.store.set(VLT.USERNAME, username)
|
|
170
|
+
this.store.set(VLT.TOKEN, accessToken)
|
|
171
|
+
this.store.set(VLT.HOSTNAME, hostname)
|
|
172
|
+
this.store.set(VLT.ON, 'true')
|
|
149
173
|
|
|
150
174
|
return accessToken
|
|
151
175
|
}
|
|
152
176
|
|
|
153
177
|
logout (hostname, id, accessToken) {
|
|
154
178
|
if (!hostname) {
|
|
155
|
-
throw new Error('
|
|
179
|
+
throw new Error('DOTENVX_VLT_HOSTNAME not set. Run [dotenvx-vlt login]')
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
if (!id) {
|
|
159
|
-
throw new Error('
|
|
183
|
+
throw new Error('DOTENVX_VLT_USER not set. Run [dotenvx-vlt login]')
|
|
160
184
|
}
|
|
161
185
|
|
|
162
186
|
if (!accessToken) {
|
|
163
|
-
throw new Error('
|
|
187
|
+
throw new Error('DOTENVX_VLT_TOKEN not set. Run [dotenvx-vlt login]')
|
|
164
188
|
}
|
|
165
189
|
|
|
166
|
-
this.store.delete(
|
|
167
|
-
this.store.delete(
|
|
168
|
-
this.store.delete(
|
|
169
|
-
this.store.delete(
|
|
170
|
-
this.store.delete(
|
|
171
|
-
this.store.delete(
|
|
172
|
-
this.store.delete(
|
|
190
|
+
this.store.delete(VLT.USER)
|
|
191
|
+
this.store.delete(VLT.USERNAME)
|
|
192
|
+
this.store.delete(VLT.TOKEN)
|
|
193
|
+
this.store.delete(VLT.HOSTNAME)
|
|
194
|
+
this.store.delete(VLT.ON)
|
|
195
|
+
this.store.delete(VLT.VERSION)
|
|
196
|
+
this.store.delete(VLT.VERSION_LAST_CHECK)
|
|
197
|
+
this.store.delete(OPS.USER)
|
|
198
|
+
this.store.delete(OPS.USERNAME)
|
|
199
|
+
this.store.delete(OPS.TOKEN)
|
|
200
|
+
this.store.delete(OPS.HOSTNAME)
|
|
201
|
+
this.store.delete(OPS.ON)
|
|
202
|
+
this.store.delete(OPS.VERSION)
|
|
203
|
+
this.store.delete(OPS.VERSION_LAST_CHECK)
|
|
173
204
|
return true
|
|
174
205
|
}
|
|
175
206
|
|
|
@@ -177,7 +208,7 @@ class Session {
|
|
|
177
208
|
// on
|
|
178
209
|
//
|
|
179
210
|
turnOn () {
|
|
180
|
-
this.store.set(
|
|
211
|
+
this.store.set(VLT.ON, 'true')
|
|
181
212
|
return 'true'
|
|
182
213
|
}
|
|
183
214
|
|
|
@@ -185,7 +216,7 @@ class Session {
|
|
|
185
216
|
// off
|
|
186
217
|
//
|
|
187
218
|
turnOff () {
|
|
188
|
-
this.store.set(
|
|
219
|
+
this.store.set(VLT.ON, 'false')
|
|
189
220
|
return 'false'
|
|
190
221
|
}
|
|
191
222
|
}
|