npm package diff
Package: @forge/cli-shared
Versions: 8.4.0-next.5 - 8.4.0-next.6
File: package/out/auth/personal/user-repository.js
Index: package/out/auth/personal/user-repository.js
===================================================================
--- package/out/auth/personal/user-repository.js
+++ package/out/auth/personal/user-repository.js
@@ -5,18 +5,35 @@
const token_authenticator_1 = require("./token-authenticator");
class UserRepositoryImpl {
createGraphQLClient;
logger;
+ cache = null;
constructor(createGraphQLClient, logger) {
this.createGraphQLClient = createGraphQLClient;
this.logger = logger;
}
+ getCachedUser(credentials) {
+ if (this.cache === null) {
+ return null;
+ }
+ const [cachedCredentials, cachedUser] = this.cache;
+ if (cachedCredentials.email === credentials.email && cachedCredentials.token === credentials.token) {
+ return cachedUser;
+ }
+ return null;
+ }
async getUser(credentials) {
+ const cachedUser = this.getCachedUser(credentials);
+ if (cachedUser) {
+ return cachedUser;
+ }
const authenticator = new token_authenticator_1.PersonalTokenAuthenticator({
getCredentials: async () => ({ ...credentials, accountId: '' })
});
const graphqlClient = this.createGraphQLClient(authenticator);
const meClient = new me_graphql_client_1.MeGraphqlClient(graphqlClient, this.logger);
- return await meClient.getUser();
+ const user = await meClient.getUser();
+ this.cache = [credentials, user];
+ return user;
}
}
exports.UserRepositoryImpl = UserRepositoryImpl;