@vibe-assurance/cli 1.0.4 → 1.0.5
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/package.json +1 -1
- package/src/config/credentials.js +11 -3
package/package.json
CHANGED
|
@@ -90,7 +90,10 @@ async function deleteCredentials() {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
* Check if credentials exist and
|
|
93
|
+
* Check if credentials exist and can be used (valid or refreshable)
|
|
94
|
+
* Returns true if:
|
|
95
|
+
* - Access token exists and is not expired, OR
|
|
96
|
+
* - Access token is expired but refresh token exists (will auto-refresh on API call)
|
|
94
97
|
* @returns {Promise<boolean>}
|
|
95
98
|
*/
|
|
96
99
|
async function hasValidCredentials() {
|
|
@@ -99,14 +102,19 @@ async function hasValidCredentials() {
|
|
|
99
102
|
return false;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
// Check if token is expired (with 5 minute buffer)
|
|
105
|
+
// Check if access token is expired (with 5 minute buffer)
|
|
103
106
|
if (creds.expiresAt) {
|
|
104
107
|
const expiresAt = new Date(creds.expiresAt);
|
|
105
108
|
const now = new Date();
|
|
106
109
|
const bufferMs = 5 * 60 * 1000; // 5 minutes
|
|
107
110
|
|
|
108
111
|
if (expiresAt.getTime() - bufferMs < now.getTime()) {
|
|
109
|
-
|
|
112
|
+
// Access token expired - check if we have a refresh token
|
|
113
|
+
// If we do, the API client will auto-refresh on first request
|
|
114
|
+
if (creds.refreshToken) {
|
|
115
|
+
return true; // Can refresh, so credentials are usable
|
|
116
|
+
}
|
|
117
|
+
return false; // No refresh token, truly expired
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
|