@velaro/cli 1.4.126 → 1.4.128
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/lib/api.js +12 -0
- package/package.json +1 -1
package/lib/api.js
CHANGED
|
@@ -25,6 +25,18 @@ export async function getCredentials(envOverride) {
|
|
|
25
25
|
return { ...creds, env };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** Forces one token refresh now (used after a 401/403 says the stored staff token went stale) and stores it. Returns the new credentials or throws. */
|
|
29
|
+
export async function forceRefreshCredentials(envOverride) {
|
|
30
|
+
const cfg = readConfig();
|
|
31
|
+
const env = envOverride || cfg.activeEnv || 'prod';
|
|
32
|
+
const creds = cfg.envs?.[env];
|
|
33
|
+
if (!creds?.entraRefreshToken) throw new Error(`No refresh token for ${env}. Run: velaro login${env === 'staging' ? ' --staging' : ''}`);
|
|
34
|
+
const refreshed = await refreshVelaroToken({ ...creds, apiBase: creds.adminApiBase });
|
|
35
|
+
const updated = { ...creds, ...refreshed };
|
|
36
|
+
setEnvCredentials(env, updated);
|
|
37
|
+
return { ...updated, env };
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
function joinUrl(base, path) {
|
|
29
41
|
return `${base.replace(/\/+$/, '')}/${String(path).replace(/^\/+/, '')}`;
|
|
30
42
|
}
|
package/package.json
CHANGED