npm package diff

Package: @forge/cli-shared

Versions: 8.3.1-next.1-experimental-b695d2e - 8.4.0-next.5

File: package/out/auth/personal/credential-store.js

Index: package/out/auth/personal/credential-store.js
===================================================================
--- package/out/auth/personal/credential-store.js
+++ package/out/auth/personal/credential-store.js
@@ -60,8 +60,9 @@
     keytar;
     cachedConfig;
     userRepository;
     keytarAccount;
+    cached = null;
     constructor(logger, instructionsURL, keytar, cachedConfig, userRepository) {
         this.logger = logger;
         this.instructionsURL = instructionsURL;
         this.keytar = keytar;
@@ -129,8 +130,12 @@
     deleteInsecurePlaintextCredentials() {
         this.cachedConfig.delete(CACHE_CREDENTIALS_KEY);
     }
     async getCredentials() {
+        if (this.cached) {
+            return this.cached;
+        }
+        let result;
         const plaintextCredentials = this.popInsecurePlaintextCredentials();
         if (plaintextCredentials) {
             if (this.keytar) {
                 await this.setCredentials(plaintextCredentials);
@@ -145,19 +150,21 @@
                 email: process.env[exports.EMAIL_KEY],
                 token: process.env[exports.API_TOKEN_KEY]
             };
             const { accountId } = await this.userRepository.getUser(credentials);
-            return { ...credentials, accountId };
+            result = { ...credentials, accountId };
         }
-        if (this.keytar) {
-            const result = await this.getCredentialsKeytar(this.keytar);
-            if (result) {
-                return result;
-            }
+        else if (this.keytar) {
+            result = await this.getCredentialsKeytar(this.keytar);
         }
+        if (result) {
+            this.cached = result;
+            return result;
+        }
         throw new NoTokenInStoreError();
     }
     async setCredentials(credentials) {
+        this.cached = null;
         if (this.keytar) {
             try {
                 await this.keytar.setPassword(KEYTAR_SERVICE, this.keytarAccount, JSON.stringify(credentials));
             }
@@ -169,8 +176,9 @@
             throw new NoKeytarError();
         }
     }
     async deleteCredentials() {
+        this.cached = null;
         if (this.keytar) {
             try {
                 await this.keytar.deletePassword(KEYTAR_SERVICE, this.keytarAccount);
             }