0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-31 22:51:25 -05:00

refactor: remove credentials cache

This commit is contained in:
Darcy Ye 2024-03-21 11:05:43 +08:00
parent 8513dae8af
commit 210bb298be
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610

View file

@ -36,24 +36,18 @@ const accessTokenExpirationMargin = 60;
export class CloudConnectionLibrary {
private client?: Client<typeof router>;
private accessTokenCache?: { expiresAt: number; accessToken: string };
private credentialsCache?: CloudConnection;
constructor(private readonly logtoConfigs: LogtoConfigLibrary) {}
public getCloudConnectionData = async (): Promise<CloudConnection> => {
if (this.credentialsCache) {
return this.credentialsCache;
}
const { getCloudConnectionData: getCloudServiceM2mCredentials } = this.logtoConfigs;
const credentials = await getCloudServiceM2mCredentials();
const { cloudUrlSet, adminUrlSet } = EnvSet.values;
this.credentialsCache = {
return {
...credentials,
tokenEndpoint: appendPath(adminUrlSet.endpoint, 'oidc/token').toString(),
endpoint: appendPath(cloudUrlSet.endpoint, 'api').toString(),
};
return this.credentialsCache;
};
/**