@snapcommit/cli 3.8.0 → 3.8.1
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/dist/lib/auth.js +29 -1
- package/package.json +1 -1
package/dist/lib/auth.js
CHANGED
|
@@ -163,9 +163,37 @@ async function promptAuth() {
|
|
|
163
163
|
* Ensure user is authenticated (prompt if not)
|
|
164
164
|
*/
|
|
165
165
|
async function ensureAuth() {
|
|
166
|
+
// Check if we have a locally stored token
|
|
166
167
|
if (isAuthenticated()) {
|
|
167
|
-
|
|
168
|
+
const config = getAuthConfig();
|
|
169
|
+
if (config) {
|
|
170
|
+
// CRITICAL: Verify token with server on every launch
|
|
171
|
+
try {
|
|
172
|
+
const result = await verifyToken(config.token);
|
|
173
|
+
if (result.valid) {
|
|
174
|
+
// Token is still valid!
|
|
175
|
+
return config;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// Token is invalid (user deleted, subscription expired, etc.)
|
|
179
|
+
console.log(chalk_1.default.yellow('\n⚠️ Your authentication token is no longer valid.'));
|
|
180
|
+
console.log(chalk_1.default.gray('This could mean:'));
|
|
181
|
+
console.log(chalk_1.default.gray(' • Your subscription has expired'));
|
|
182
|
+
console.log(chalk_1.default.gray(' • Your account was deleted'));
|
|
183
|
+
console.log(chalk_1.default.gray(' • The token was revoked\n'));
|
|
184
|
+
clearAuth();
|
|
185
|
+
// Fall through to re-prompt
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// Network error - allow offline usage with cached token
|
|
190
|
+
console.log(chalk_1.default.yellow('\n⚠️ Could not verify token (offline mode)'));
|
|
191
|
+
console.log(chalk_1.default.gray('Using cached credentials. Some features may be limited.\n'));
|
|
192
|
+
return config;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
168
195
|
}
|
|
196
|
+
// No valid token - prompt for authentication
|
|
169
197
|
const success = await promptAuth();
|
|
170
198
|
if (success) {
|
|
171
199
|
return getAuthConfig();
|