securenow 7.6.5 → 7.6.6
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/cli/auth.js +2 -2
- package/cli/config.js +20 -5
- package/cli/credentials.js +5 -1
- package/cli/init.js +1 -1
- package/package.json +1 -1
package/cli/auth.js
CHANGED
|
@@ -237,7 +237,7 @@ async function login(args, flags) {
|
|
|
237
237
|
const email = payload?.email || 'unknown';
|
|
238
238
|
const exp = payload?.exp ? payload.exp * 1000 : null;
|
|
239
239
|
|
|
240
|
-
config.setAuth(token, email, exp, { local });
|
|
240
|
+
config.setAuth(token, email, exp, { local, enableFirewall: true });
|
|
241
241
|
if (local) config.ensureLocalGitignore();
|
|
242
242
|
console.log('');
|
|
243
243
|
ui.success(`Logged in as ${ui.c.bold(email)}`);
|
|
@@ -255,7 +255,7 @@ async function login(args, flags) {
|
|
|
255
255
|
const email = payload?.email || 'unknown';
|
|
256
256
|
const exp = payload?.exp ? payload.exp * 1000 : null;
|
|
257
257
|
|
|
258
|
-
config.setAuth(token, email, exp, { local, app });
|
|
258
|
+
config.setAuth(token, email, exp, { local, app, enableFirewall: true });
|
|
259
259
|
if (apiKey) config.setApiKey(apiKey, { local });
|
|
260
260
|
if (local) config.ensureLocalGitignore();
|
|
261
261
|
console.log('');
|
package/cli/config.js
CHANGED
|
@@ -101,11 +101,22 @@ function saveCredentials(creds, { local = false } = {}) {
|
|
|
101
101
|
saveJSON(targetFile, appConfig.withCredentialDefaults(creds) || {});
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function
|
|
104
|
+
function withOnboardingFirewallEnabled(creds) {
|
|
105
|
+
const payload = appConfig.withCredentialDefaults(creds || {}) || {};
|
|
106
|
+
payload.config = payload.config || {};
|
|
107
|
+
payload.config.firewall = payload.config.firewall || {};
|
|
108
|
+
payload.config.firewall.enabled = true;
|
|
109
|
+
return payload;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function ensureCredentialDefaults({ local, enableFirewall = false } = {}) {
|
|
105
113
|
const useLocal = local === true || (local == null && hasLocalCredentials());
|
|
106
114
|
const targetFile = credentialsFileForLocal(useLocal);
|
|
107
115
|
const existing = loadJSON(targetFile);
|
|
108
|
-
|
|
116
|
+
const payload = enableFirewall
|
|
117
|
+
? withOnboardingFirewallEnabled(existing || {})
|
|
118
|
+
: appConfig.withCredentialDefaults(existing || {}) || {};
|
|
119
|
+
saveJSON(targetFile, payload);
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
function clearCredentials({ local } = {}) {
|
|
@@ -132,7 +143,7 @@ function getToken() {
|
|
|
132
143
|
return creds.token;
|
|
133
144
|
}
|
|
134
145
|
|
|
135
|
-
function setAuth(token, email, expiresAt, { local = false, app = null } = {}) {
|
|
146
|
+
function setAuth(token, email, expiresAt, { local = false, app = null, enableFirewall = false } = {}) {
|
|
136
147
|
const targetFile = credentialsFileForLocal(local);
|
|
137
148
|
const payload = { ...loadJSON(targetFile), token, email, expiresAt };
|
|
138
149
|
if (app && (app.key || app.name || app.instance)) {
|
|
@@ -142,7 +153,10 @@ function setAuth(token, email, expiresAt, { local = false, app = null } = {}) {
|
|
|
142
153
|
instance: app.instance || null,
|
|
143
154
|
};
|
|
144
155
|
}
|
|
145
|
-
|
|
156
|
+
saveJSON(
|
|
157
|
+
targetFile,
|
|
158
|
+
enableFirewall ? withOnboardingFirewallEnabled(payload) : appConfig.withCredentialDefaults(payload) || {}
|
|
159
|
+
);
|
|
146
160
|
}
|
|
147
161
|
|
|
148
162
|
function getApp() {
|
|
@@ -154,7 +168,7 @@ function setApiKey(apiKey, { local } = {}) {
|
|
|
154
168
|
const useLocal = local === true || (local == null && hasLocalCredentials());
|
|
155
169
|
const targetFile = credentialsFileForLocal(useLocal);
|
|
156
170
|
const existing = loadJSON(targetFile);
|
|
157
|
-
saveJSON(targetFile,
|
|
171
|
+
saveJSON(targetFile, withOnboardingFirewallEnabled({ ...existing, apiKey }));
|
|
158
172
|
}
|
|
159
173
|
|
|
160
174
|
function clearApiKey({ local } = {}) {
|
|
@@ -238,6 +252,7 @@ module.exports = {
|
|
|
238
252
|
getAuthSource,
|
|
239
253
|
hasLocalCredentials,
|
|
240
254
|
ensureCredentialDefaults,
|
|
255
|
+
withOnboardingFirewallEnabled,
|
|
241
256
|
ensureLocalGitignore,
|
|
242
257
|
getApiUrl,
|
|
243
258
|
getAppUrl,
|
package/cli/credentials.js
CHANGED
|
@@ -20,7 +20,7 @@ function buildRuntimeCredentials(options = {}) {
|
|
|
20
20
|
options.env ||
|
|
21
21
|
appConfig.resolveDeploymentEnvironment() ||
|
|
22
22
|
'production';
|
|
23
|
-
const runtime =
|
|
23
|
+
const runtime = config.withOnboardingFirewallEnabled({
|
|
24
24
|
apiKey: creds.apiKey || null,
|
|
25
25
|
app: {
|
|
26
26
|
key: creds.app?.key || null,
|
|
@@ -33,6 +33,10 @@ function buildRuntimeCredentials(options = {}) {
|
|
|
33
33
|
...(creds.config?.runtime || {}),
|
|
34
34
|
deploymentEnvironment,
|
|
35
35
|
},
|
|
36
|
+
firewall: {
|
|
37
|
+
...(creds.config?.firewall || {}),
|
|
38
|
+
enabled: true,
|
|
39
|
+
},
|
|
36
40
|
},
|
|
37
41
|
_securenow: {
|
|
38
42
|
...(creds._securenow || {}),
|
package/cli/init.js
CHANGED
|
@@ -86,7 +86,7 @@ async function init(_args, flags) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function initCredentials(flags) {
|
|
89
|
-
config.ensureCredentialDefaults({ local: true });
|
|
89
|
+
config.ensureCredentialDefaults({ local: true, enableFirewall: true });
|
|
90
90
|
config.ensureLocalGitignore();
|
|
91
91
|
const creds = config.loadCredentials();
|
|
92
92
|
creds.config = creds.config || {};
|
package/package.json
CHANGED