@clipdone/cli 0.1.1 → 0.1.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/bin/clipdone.js +12 -1
- package/package.json +1 -1
package/bin/clipdone.js
CHANGED
|
@@ -241,6 +241,13 @@ function clearStoredAuth() {
|
|
|
241
241
|
delete config.token;
|
|
242
242
|
delete config.tokenExpiresAt;
|
|
243
243
|
delete config.oauth;
|
|
244
|
+
delete config.oauthClient;
|
|
245
|
+
writeConfig(config);
|
|
246
|
+
}
|
|
247
|
+
function clearStoredOAuthClientRegistration() {
|
|
248
|
+
const config = readConfig();
|
|
249
|
+
if (!config.oauthClient) return;
|
|
250
|
+
delete config.oauthClient;
|
|
244
251
|
writeConfig(config);
|
|
245
252
|
}
|
|
246
253
|
function readStoredOAuthClientRegistration(scope, resource) {
|
|
@@ -558,10 +565,14 @@ async function oauthRegisterClient({ scope }) {
|
|
|
558
565
|
return { clientId };
|
|
559
566
|
}
|
|
560
567
|
async function resolveOAuthClient(authConfig) {
|
|
568
|
+
const activeSession = readStoredOAuthSession();
|
|
561
569
|
const cached = readStoredOAuthClientRegistration(authConfig?.scope, authConfig?.resource);
|
|
562
|
-
if (cached) {
|
|
570
|
+
if (cached && activeSession?.clientId === cached.clientId) {
|
|
563
571
|
return cached;
|
|
564
572
|
}
|
|
573
|
+
if (cached) {
|
|
574
|
+
clearStoredOAuthClientRegistration();
|
|
575
|
+
}
|
|
565
576
|
const registered = await oauthRegisterClient({ scope: authConfig.scope });
|
|
566
577
|
writeStoredOAuthClientRegistration(registered.clientId, authConfig.scope, authConfig.resource);
|
|
567
578
|
return registered;
|