()
| 977 | } |
| 978 | |
| 979 | async loadMasterKey() { |
| 980 | if (typeof this.masterKey === 'function') { |
| 981 | const ttlIsEmpty = !this.masterKeyTtl; |
| 982 | const isExpired = this.masterKeyCache?.expiresAt && this.masterKeyCache.expiresAt < new Date(); |
| 983 | |
| 984 | if ((!isExpired || ttlIsEmpty) && this.masterKeyCache?.masterKey) { |
| 985 | return this.masterKeyCache.masterKey; |
| 986 | } |
| 987 | |
| 988 | const masterKey = await this.masterKey(); |
| 989 | |
| 990 | const expiresAt = this.masterKeyTtl ? new Date(Date.now() + 1000 * this.masterKeyTtl) : null |
| 991 | this.masterKeyCache = { masterKey, expiresAt }; |
| 992 | Config.put(this); |
| 993 | |
| 994 | return this.masterKeyCache.masterKey; |
| 995 | } |
| 996 | |
| 997 | return this.masterKey; |
| 998 | } |
| 999 | |
| 1000 | get pagesEndpoint() { |
| 1001 | return this.pages && this.pages.pagesEndpoint |
no test coverage detected