@azure/msal-common 14.0.2 → 14.0.3

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.
Files changed (269) hide show
  1. package/dist/account/AuthToken.d.ts +14 -17
  2. package/dist/account/AuthToken.d.ts.map +1 -1
  3. package/dist/account/AuthToken.mjs +48 -39
  4. package/dist/account/AuthToken.mjs.map +1 -1
  5. package/dist/account/CcsCredential.mjs +1 -1
  6. package/dist/account/CcsCredential.mjs.map +1 -1
  7. package/dist/account/ClientInfo.d.ts.map +1 -1
  8. package/dist/account/ClientInfo.mjs +3 -4
  9. package/dist/account/ClientInfo.mjs.map +1 -1
  10. package/dist/authority/Authority.mjs +1 -1
  11. package/dist/authority/Authority.mjs.map +1 -1
  12. package/dist/authority/AuthorityFactory.d.ts.map +1 -1
  13. package/dist/authority/AuthorityFactory.mjs +2 -3
  14. package/dist/authority/AuthorityFactory.mjs.map +1 -1
  15. package/dist/authority/AuthorityMetadata.mjs +1 -1
  16. package/dist/authority/AuthorityMetadata.mjs.map +1 -1
  17. package/dist/authority/AuthorityOptions.mjs +1 -1
  18. package/dist/authority/AuthorityOptions.mjs.map +1 -1
  19. package/dist/authority/AuthorityType.mjs +1 -1
  20. package/dist/authority/AuthorityType.mjs.map +1 -1
  21. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  22. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs.map +1 -1
  23. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  24. package/dist/authority/CloudInstanceDiscoveryResponse.mjs.map +1 -1
  25. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  26. package/dist/authority/OpenIdConfigResponse.mjs.map +1 -1
  27. package/dist/authority/ProtocolMode.mjs +1 -1
  28. package/dist/authority/ProtocolMode.mjs.map +1 -1
  29. package/dist/authority/RegionDiscovery.mjs +1 -1
  30. package/dist/authority/RegionDiscovery.mjs.map +1 -1
  31. package/dist/cache/CacheManager.d.ts.map +1 -1
  32. package/dist/cache/CacheManager.mjs +5 -5
  33. package/dist/cache/CacheManager.mjs.map +1 -1
  34. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  35. package/dist/cache/entities/AccessTokenEntity.mjs +4 -7
  36. package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
  37. package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
  38. package/dist/cache/entities/AccountEntity.mjs +2 -4
  39. package/dist/cache/entities/AccountEntity.mjs.map +1 -1
  40. package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
  41. package/dist/cache/entities/AppMetadataEntity.mjs.map +1 -1
  42. package/dist/cache/entities/AuthorityMetadataEntity.mjs +1 -1
  43. package/dist/cache/entities/AuthorityMetadataEntity.mjs.map +1 -1
  44. package/dist/cache/entities/CacheRecord.mjs +1 -1
  45. package/dist/cache/entities/CacheRecord.mjs.map +1 -1
  46. package/dist/cache/entities/CredentialEntity.mjs +1 -1
  47. package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
  48. package/dist/cache/entities/IdTokenEntity.mjs +1 -1
  49. package/dist/cache/entities/IdTokenEntity.mjs.map +1 -1
  50. package/dist/cache/entities/RefreshTokenEntity.mjs +1 -1
  51. package/dist/cache/entities/RefreshTokenEntity.mjs.map +1 -1
  52. package/dist/cache/entities/ServerTelemetryEntity.mjs +1 -1
  53. package/dist/cache/entities/ServerTelemetryEntity.mjs.map +1 -1
  54. package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
  55. package/dist/cache/entities/ThrottlingEntity.mjs.map +1 -1
  56. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  57. package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
  58. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  59. package/dist/client/AuthorizationCodeClient.mjs +10 -39
  60. package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
  61. package/dist/client/BaseClient.d.ts +1 -1
  62. package/dist/client/BaseClient.d.ts.map +1 -1
  63. package/dist/client/BaseClient.mjs +8 -2
  64. package/dist/client/BaseClient.mjs.map +1 -1
  65. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  66. package/dist/client/RefreshTokenClient.mjs +2 -11
  67. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  68. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  69. package/dist/client/SilentFlowClient.mjs +7 -7
  70. package/dist/client/SilentFlowClient.mjs.map +1 -1
  71. package/dist/config/ClientConfiguration.mjs +1 -1
  72. package/dist/config/ClientConfiguration.mjs.map +1 -1
  73. package/dist/crypto/ICrypto.mjs +1 -1
  74. package/dist/crypto/ICrypto.mjs.map +1 -1
  75. package/dist/crypto/JoseHeader.mjs +1 -1
  76. package/dist/crypto/JoseHeader.mjs.map +1 -1
  77. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  78. package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
  79. package/dist/error/AuthError.mjs +1 -1
  80. package/dist/error/AuthError.mjs.map +1 -1
  81. package/dist/error/ClientAuthError.mjs +1 -1
  82. package/dist/error/ClientAuthError.mjs.map +1 -1
  83. package/dist/error/ClientConfigurationError.mjs +1 -1
  84. package/dist/error/ClientConfigurationError.mjs.map +1 -1
  85. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  86. package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
  87. package/dist/error/JoseHeaderError.mjs +1 -1
  88. package/dist/error/JoseHeaderError.mjs.map +1 -1
  89. package/dist/error/ServerError.mjs +1 -1
  90. package/dist/error/ServerError.mjs.map +1 -1
  91. package/dist/index.cjs +1641 -1560
  92. package/dist/index.cjs.map +1 -1
  93. package/dist/index.d.ts +3 -3
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.mjs +5 -3
  96. package/dist/index.mjs.map +1 -1
  97. package/dist/logger/Logger.d.ts.map +1 -1
  98. package/dist/logger/Logger.mjs +2 -12
  99. package/dist/logger/Logger.mjs.map +1 -1
  100. package/dist/network/INetworkModule.mjs +1 -1
  101. package/dist/network/INetworkModule.mjs.map +1 -1
  102. package/dist/network/NetworkManager.mjs +1 -1
  103. package/dist/network/NetworkManager.mjs.map +1 -1
  104. package/dist/network/ThrottlingUtils.mjs +1 -1
  105. package/dist/network/ThrottlingUtils.mjs.map +1 -1
  106. package/dist/packageMetadata.d.ts +1 -1
  107. package/dist/packageMetadata.mjs +2 -2
  108. package/dist/packageMetadata.mjs.map +1 -1
  109. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  110. package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
  111. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  112. package/dist/request/RequestParameterBuilder.mjs +6 -7
  113. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  114. package/dist/request/RequestValidator.d.ts.map +1 -1
  115. package/dist/request/RequestValidator.mjs +4 -6
  116. package/dist/request/RequestValidator.mjs.map +1 -1
  117. package/dist/request/ScopeSet.mjs +4 -4
  118. package/dist/request/ScopeSet.mjs.map +1 -1
  119. package/dist/response/AuthenticationResult.d.ts +3 -1
  120. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  121. package/dist/response/ResponseHandler.d.ts +4 -3
  122. package/dist/response/ResponseHandler.d.ts.map +1 -1
  123. package/dist/response/ResponseHandler.mjs +57 -39
  124. package/dist/response/ResponseHandler.mjs.map +1 -1
  125. package/dist/response/ServerAuthorizationTokenResponse.d.ts +2 -0
  126. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  127. package/dist/telemetry/performance/IPerformanceClient.d.ts +4 -4
  128. package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
  129. package/dist/telemetry/performance/PerformanceClient.d.ts +2 -2
  130. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  131. package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
  132. package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
  133. package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -1
  134. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  135. package/dist/telemetry/performance/PerformanceEvent.mjs +9 -1
  136. package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
  137. package/dist/telemetry/performance/StubPerformanceClient.d.ts +3 -3
  138. package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
  139. package/dist/telemetry/performance/StubPerformanceClient.mjs +23 -3
  140. package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
  141. package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
  142. package/dist/telemetry/server/ServerTelemetryManager.mjs +3 -4
  143. package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
  144. package/dist/url/UrlString.d.ts.map +1 -1
  145. package/dist/url/UrlString.mjs +10 -12
  146. package/dist/url/UrlString.mjs.map +1 -1
  147. package/dist/utils/Constants.d.ts +10 -0
  148. package/dist/utils/Constants.d.ts.map +1 -1
  149. package/dist/utils/Constants.mjs +11 -2
  150. package/dist/utils/Constants.mjs.map +1 -1
  151. package/dist/utils/FunctionWrappers.d.ts +28 -0
  152. package/dist/utils/FunctionWrappers.d.ts.map +1 -0
  153. package/dist/utils/FunctionWrappers.mjs +90 -0
  154. package/dist/utils/FunctionWrappers.mjs.map +1 -0
  155. package/dist/utils/ProtocolUtils.d.ts.map +1 -1
  156. package/dist/utils/ProtocolUtils.mjs +4 -7
  157. package/dist/utils/ProtocolUtils.mjs.map +1 -1
  158. package/dist/utils/StringUtils.d.ts +0 -13
  159. package/dist/utils/StringUtils.d.ts.map +1 -1
  160. package/dist/utils/StringUtils.mjs +3 -34
  161. package/dist/utils/StringUtils.mjs.map +1 -1
  162. package/dist/utils/TimeUtils.mjs +1 -1
  163. package/dist/utils/TimeUtils.mjs.map +1 -1
  164. package/package.json +6 -4
  165. package/src/account/AccountInfo.ts +44 -0
  166. package/src/account/AuthToken.ts +70 -0
  167. package/src/account/CcsCredential.ts +16 -0
  168. package/src/account/ClientCredentials.ts +20 -0
  169. package/src/account/ClientInfo.ts +64 -0
  170. package/src/account/TokenClaims.ts +70 -0
  171. package/src/authority/Authority.ts +1225 -0
  172. package/src/authority/AuthorityFactory.ts +106 -0
  173. package/src/authority/AuthorityMetadata.ts +953 -0
  174. package/src/authority/AuthorityOptions.ts +40 -0
  175. package/src/authority/AuthorityType.ts +15 -0
  176. package/src/authority/AzureRegion.ts +7 -0
  177. package/src/authority/AzureRegionConfiguration.ts +16 -0
  178. package/src/authority/CloudDiscoveryMetadata.ts +10 -0
  179. package/src/authority/CloudInstanceDiscoveryErrorResponse.ts +26 -0
  180. package/src/authority/CloudInstanceDiscoveryResponse.ts +21 -0
  181. package/src/authority/ImdsOptions.ts +10 -0
  182. package/src/authority/OIDCOptions.ts +14 -0
  183. package/src/authority/OpenIdConfigResponse.ts +24 -0
  184. package/src/authority/ProtocolMode.ts +13 -0
  185. package/src/authority/RegionDiscovery.ts +193 -0
  186. package/src/authority/RegionDiscoveryMetadata.ts +15 -0
  187. package/src/broker/nativeBroker/INativeBrokerPlugin.ts +29 -0
  188. package/src/cache/CacheManager.ts +1619 -0
  189. package/src/cache/entities/AccessTokenEntity.ts +162 -0
  190. package/src/cache/entities/AccountEntity.ts +309 -0
  191. package/src/cache/entities/AppMetadataEntity.ts +91 -0
  192. package/src/cache/entities/AuthorityMetadataEntity.ts +112 -0
  193. package/src/cache/entities/CacheRecord.ts +33 -0
  194. package/src/cache/entities/CredentialEntity.ts +215 -0
  195. package/src/cache/entities/IdTokenEntity.ts +74 -0
  196. package/src/cache/entities/RefreshTokenEntity.ts +78 -0
  197. package/src/cache/entities/ServerTelemetryEntity.ts +38 -0
  198. package/src/cache/entities/ThrottlingEntity.ts +36 -0
  199. package/src/cache/interface/ICacheManager.ts +218 -0
  200. package/src/cache/interface/ICachePlugin.ts +11 -0
  201. package/src/cache/interface/ISerializableTokenCache.ts +9 -0
  202. package/src/cache/persistence/TokenCacheContext.ts +39 -0
  203. package/src/cache/utils/CacheTypes.ts +93 -0
  204. package/src/client/AuthorizationCodeClient.ts +714 -0
  205. package/src/client/BaseClient.ts +205 -0
  206. package/src/client/RefreshTokenClient.ts +442 -0
  207. package/src/client/SilentFlowClient.ts +186 -0
  208. package/src/config/AppTokenProvider.ts +47 -0
  209. package/src/config/ClientConfiguration.ts +287 -0
  210. package/src/crypto/ICrypto.ts +127 -0
  211. package/src/crypto/IGuidGenerator.ts +9 -0
  212. package/src/crypto/JoseHeader.ts +55 -0
  213. package/src/crypto/PopTokenGenerator.ts +155 -0
  214. package/src/crypto/SignedHttpRequest.ts +16 -0
  215. package/src/error/AuthError.ts +85 -0
  216. package/src/error/ClientAuthError.ts +738 -0
  217. package/src/error/ClientConfigurationError.ts +396 -0
  218. package/src/error/InteractionRequiredAuthError.ts +134 -0
  219. package/src/error/JoseHeaderError.ts +52 -0
  220. package/src/error/ServerError.ts +18 -0
  221. package/src/index.ts +215 -0
  222. package/src/logger/Logger.ts +272 -0
  223. package/src/network/INetworkModule.ts +57 -0
  224. package/src/network/NetworkManager.ts +76 -0
  225. package/src/network/RequestThumbprint.ts +22 -0
  226. package/src/network/ThrottlingUtils.ts +156 -0
  227. package/src/packageMetadata.ts +3 -0
  228. package/src/request/AuthenticationHeaderParser.ts +89 -0
  229. package/src/request/BaseAuthRequest.ts +46 -0
  230. package/src/request/CommonAuthorizationCodeRequest.ts +33 -0
  231. package/src/request/CommonAuthorizationUrlRequest.ts +56 -0
  232. package/src/request/CommonClientCredentialRequest.ts +23 -0
  233. package/src/request/CommonDeviceCodeRequest.ts +31 -0
  234. package/src/request/CommonEndSessionRequest.ts +27 -0
  235. package/src/request/CommonOnBehalfOfRequest.ts +19 -0
  236. package/src/request/CommonRefreshTokenRequest.ts +25 -0
  237. package/src/request/CommonSilentFlowRequest.ts +24 -0
  238. package/src/request/CommonUsernamePasswordRequest.ts +23 -0
  239. package/src/request/NativeRequest.ts +25 -0
  240. package/src/request/NativeSignOutRequest.ts +10 -0
  241. package/src/request/RequestParameterBuilder.ts +606 -0
  242. package/src/request/RequestValidator.ts +103 -0
  243. package/src/request/ScopeSet.ts +230 -0
  244. package/src/request/StoreInCache.ts +16 -0
  245. package/src/response/AuthenticationResult.ts +47 -0
  246. package/src/response/AuthorizationCodePayload.ts +18 -0
  247. package/src/response/DeviceCodeResponse.ts +31 -0
  248. package/src/response/ExternalTokenResponse.ts +24 -0
  249. package/src/response/IMDSBadResponse.ts +9 -0
  250. package/src/response/ResponseHandler.ts +614 -0
  251. package/src/response/ServerAuthorizationCodeResponse.ts +33 -0
  252. package/src/response/ServerAuthorizationTokenResponse.ts +54 -0
  253. package/src/telemetry/performance/IPerformanceClient.ts +71 -0
  254. package/src/telemetry/performance/IPerformanceMeasurement.ts +10 -0
  255. package/src/telemetry/performance/PerformanceClient.ts +635 -0
  256. package/src/telemetry/performance/PerformanceEvent.ts +542 -0
  257. package/src/telemetry/performance/StubPerformanceClient.ts +101 -0
  258. package/src/telemetry/server/ServerTelemetryManager.ts +274 -0
  259. package/src/telemetry/server/ServerTelemetryRequest.ts +13 -0
  260. package/src/url/IUri.ts +17 -0
  261. package/src/url/UrlString.ts +363 -0
  262. package/src/utils/Constants.ts +436 -0
  263. package/src/utils/FunctionWrappers.ts +105 -0
  264. package/src/utils/MsalTypes.ts +9 -0
  265. package/src/utils/ProtocolUtils.ts +124 -0
  266. package/src/utils/StringUtils.ts +106 -0
  267. package/src/utils/TimeUtils.ts +51 -0
  268. package/dist/account/DecodedAuthToken.d.ts +0 -9
  269. package/dist/account/DecodedAuthToken.d.ts.map +0 -1
@@ -0,0 +1,1619 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ AccountFilter,
8
+ CredentialFilter,
9
+ ValidCredentialType,
10
+ AppMetadataFilter,
11
+ AppMetadataCache,
12
+ TokenKeys,
13
+ } from "./utils/CacheTypes";
14
+ import { CacheRecord } from "./entities/CacheRecord";
15
+ import {
16
+ CredentialType,
17
+ APP_METADATA,
18
+ THE_FAMILY_ID,
19
+ AUTHORITY_METADATA_CONSTANTS,
20
+ AuthenticationScheme,
21
+ Separators,
22
+ } from "../utils/Constants";
23
+ import { CredentialEntity } from "./entities/CredentialEntity";
24
+ import { ScopeSet } from "../request/ScopeSet";
25
+ import { AccountEntity } from "./entities/AccountEntity";
26
+ import { AccessTokenEntity } from "./entities/AccessTokenEntity";
27
+ import { IdTokenEntity } from "./entities/IdTokenEntity";
28
+ import { RefreshTokenEntity } from "./entities/RefreshTokenEntity";
29
+ import { AuthError } from "../error/AuthError";
30
+ import { ICacheManager } from "./interface/ICacheManager";
31
+ import { ClientAuthError } from "../error/ClientAuthError";
32
+ import { AccountInfo } from "../account/AccountInfo";
33
+ import { AppMetadataEntity } from "./entities/AppMetadataEntity";
34
+ import { ServerTelemetryEntity } from "./entities/ServerTelemetryEntity";
35
+ import { ThrottlingEntity } from "./entities/ThrottlingEntity";
36
+ import { extractTokenClaims } from "../account/AuthToken";
37
+ import { ICrypto } from "../crypto/ICrypto";
38
+ import { AuthorityMetadataEntity } from "./entities/AuthorityMetadataEntity";
39
+ import { BaseAuthRequest } from "../request/BaseAuthRequest";
40
+ import { Logger } from "../logger/Logger";
41
+ import { name, version } from "../packageMetadata";
42
+ import { StoreInCache } from "../request/StoreInCache";
43
+
44
+ /**
45
+ * Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
46
+ * @internal
47
+ */
48
+ export abstract class CacheManager implements ICacheManager {
49
+ protected clientId: string;
50
+ protected cryptoImpl: ICrypto;
51
+ // Instance of logger for functions defined in the msal-common layer
52
+ private commonLogger: Logger;
53
+
54
+ constructor(clientId: string, cryptoImpl: ICrypto, logger: Logger) {
55
+ this.clientId = clientId;
56
+ this.cryptoImpl = cryptoImpl;
57
+ this.commonLogger = logger.clone(name, version);
58
+ }
59
+
60
+ /**
61
+ * fetch the account entity from the platform cache
62
+ * @param accountKey
63
+ */
64
+ abstract getAccount(accountKey: string): AccountEntity | null;
65
+
66
+ /**
67
+ * set account entity in the platform cache
68
+ * @param account
69
+ */
70
+ abstract setAccount(account: AccountEntity): void;
71
+
72
+ /**
73
+ * fetch the idToken entity from the platform cache
74
+ * @param idTokenKey
75
+ */
76
+ abstract getIdTokenCredential(idTokenKey: string): IdTokenEntity | null;
77
+
78
+ /**
79
+ * set idToken entity to the platform cache
80
+ * @param idToken
81
+ */
82
+ abstract setIdTokenCredential(idToken: IdTokenEntity): void;
83
+
84
+ /**
85
+ * fetch the idToken entity from the platform cache
86
+ * @param accessTokenKey
87
+ */
88
+ abstract getAccessTokenCredential(
89
+ accessTokenKey: string
90
+ ): AccessTokenEntity | null;
91
+
92
+ /**
93
+ * set idToken entity to the platform cache
94
+ * @param accessToken
95
+ */
96
+ abstract setAccessTokenCredential(accessToken: AccessTokenEntity): void;
97
+
98
+ /**
99
+ * fetch the idToken entity from the platform cache
100
+ * @param refreshTokenKey
101
+ */
102
+ abstract getRefreshTokenCredential(
103
+ refreshTokenKey: string
104
+ ): RefreshTokenEntity | null;
105
+
106
+ /**
107
+ * set idToken entity to the platform cache
108
+ * @param refreshToken
109
+ */
110
+ abstract setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void;
111
+
112
+ /**
113
+ * fetch appMetadata entity from the platform cache
114
+ * @param appMetadataKey
115
+ */
116
+ abstract getAppMetadata(appMetadataKey: string): AppMetadataEntity | null;
117
+
118
+ /**
119
+ * set appMetadata entity to the platform cache
120
+ * @param appMetadata
121
+ */
122
+ abstract setAppMetadata(appMetadata: AppMetadataEntity): void;
123
+
124
+ /**
125
+ * fetch server telemetry entity from the platform cache
126
+ * @param serverTelemetryKey
127
+ */
128
+ abstract getServerTelemetry(
129
+ serverTelemetryKey: string
130
+ ): ServerTelemetryEntity | null;
131
+
132
+ /**
133
+ * set server telemetry entity to the platform cache
134
+ * @param serverTelemetryKey
135
+ * @param serverTelemetry
136
+ */
137
+ abstract setServerTelemetry(
138
+ serverTelemetryKey: string,
139
+ serverTelemetry: ServerTelemetryEntity
140
+ ): void;
141
+
142
+ /**
143
+ * fetch cloud discovery metadata entity from the platform cache
144
+ * @param key
145
+ */
146
+ abstract getAuthorityMetadata(key: string): AuthorityMetadataEntity | null;
147
+
148
+ /**
149
+ *
150
+ */
151
+ abstract getAuthorityMetadataKeys(): Array<string>;
152
+
153
+ /**
154
+ * set cloud discovery metadata entity to the platform cache
155
+ * @param key
156
+ * @param value
157
+ */
158
+ abstract setAuthorityMetadata(
159
+ key: string,
160
+ value: AuthorityMetadataEntity
161
+ ): void;
162
+
163
+ /**
164
+ * fetch throttling entity from the platform cache
165
+ * @param throttlingCacheKey
166
+ */
167
+ abstract getThrottlingCache(
168
+ throttlingCacheKey: string
169
+ ): ThrottlingEntity | null;
170
+
171
+ /**
172
+ * set throttling entity to the platform cache
173
+ * @param throttlingCacheKey
174
+ * @param throttlingCache
175
+ */
176
+ abstract setThrottlingCache(
177
+ throttlingCacheKey: string,
178
+ throttlingCache: ThrottlingEntity
179
+ ): void;
180
+
181
+ /**
182
+ * Function to remove an item from cache given its key.
183
+ * @param key
184
+ */
185
+ abstract removeItem(key: string): void;
186
+
187
+ /**
188
+ * Function which returns boolean whether cache contains a specific key.
189
+ * @param key
190
+ */
191
+ abstract containsKey(key: string, type?: string): boolean;
192
+
193
+ /**
194
+ * Function which retrieves all current keys from the cache.
195
+ */
196
+ abstract getKeys(): string[];
197
+
198
+ /**
199
+ * Function which retrieves all account keys from the cache
200
+ */
201
+ abstract getAccountKeys(): string[];
202
+
203
+ /**
204
+ * Function which retrieves all token keys from the cache
205
+ */
206
+ abstract getTokenKeys(): TokenKeys;
207
+
208
+ /**
209
+ * Function which clears cache.
210
+ */
211
+ abstract clear(): Promise<void>;
212
+
213
+ /**
214
+ * Function which updates an outdated credential cache key
215
+ */
216
+ abstract updateCredentialCacheKey(
217
+ currentCacheKey: string,
218
+ credential: ValidCredentialType
219
+ ): string;
220
+
221
+ /**
222
+ * Returns all accounts in cache
223
+ */
224
+ getAllAccounts(): AccountInfo[] {
225
+ const allAccountKeys = this.getAccountKeys();
226
+ if (allAccountKeys.length < 1) {
227
+ return [];
228
+ }
229
+
230
+ const accountEntities: AccountEntity[] = allAccountKeys.reduce(
231
+ (accounts: AccountEntity[], key: string) => {
232
+ const entity: AccountEntity | null = this.getAccount(key);
233
+
234
+ if (!entity) {
235
+ return accounts;
236
+ }
237
+ accounts.push(entity);
238
+ return accounts;
239
+ },
240
+ []
241
+ );
242
+
243
+ if (accountEntities.length < 1) {
244
+ return [];
245
+ } else {
246
+ const allAccounts = accountEntities.map<AccountInfo>(
247
+ (accountEntity) => {
248
+ return this.getAccountInfoFromEntity(accountEntity);
249
+ }
250
+ );
251
+ return allAccounts;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Gets accountInfo object based on provided filters
257
+ */
258
+ getAccountInfoFilteredBy(accountFilter: AccountFilter): AccountInfo | null {
259
+ const allAccounts = this.getAccountsFilteredBy(accountFilter);
260
+ if (allAccounts.length > 0) {
261
+ return this.getAccountInfoFromEntity(allAccounts[0]);
262
+ } else {
263
+ return null;
264
+ }
265
+ }
266
+
267
+ private getAccountInfoFromEntity(
268
+ accountEntity: AccountEntity
269
+ ): AccountInfo {
270
+ const accountInfo = accountEntity.getAccountInfo();
271
+ const idToken = this.getIdToken(accountInfo);
272
+ if (idToken) {
273
+ accountInfo.idToken = idToken.secret;
274
+ accountInfo.idTokenClaims = extractTokenClaims(
275
+ idToken.secret,
276
+ this.cryptoImpl.base64Decode
277
+ );
278
+ }
279
+ return accountInfo;
280
+ }
281
+
282
+ /**
283
+ * saves a cache record
284
+ * @param cacheRecord
285
+ */
286
+ async saveCacheRecord(
287
+ cacheRecord: CacheRecord,
288
+ storeInCache?: StoreInCache
289
+ ): Promise<void> {
290
+ if (!cacheRecord) {
291
+ throw ClientAuthError.createNullOrUndefinedCacheRecord();
292
+ }
293
+
294
+ if (!!cacheRecord.account) {
295
+ this.setAccount(cacheRecord.account);
296
+ }
297
+
298
+ if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
299
+ this.setIdTokenCredential(cacheRecord.idToken);
300
+ }
301
+
302
+ if (!!cacheRecord.accessToken && storeInCache?.accessToken !== false) {
303
+ await this.saveAccessToken(cacheRecord.accessToken);
304
+ }
305
+
306
+ if (
307
+ !!cacheRecord.refreshToken &&
308
+ storeInCache?.refreshToken !== false
309
+ ) {
310
+ this.setRefreshTokenCredential(cacheRecord.refreshToken);
311
+ }
312
+
313
+ if (!!cacheRecord.appMetadata) {
314
+ this.setAppMetadata(cacheRecord.appMetadata);
315
+ }
316
+ }
317
+
318
+ /**
319
+ * saves access token credential
320
+ * @param credential
321
+ */
322
+ private async saveAccessToken(
323
+ credential: AccessTokenEntity
324
+ ): Promise<void> {
325
+ const accessTokenFilter: CredentialFilter = {
326
+ clientId: credential.clientId,
327
+ credentialType: credential.credentialType,
328
+ environment: credential.environment,
329
+ homeAccountId: credential.homeAccountId,
330
+ realm: credential.realm,
331
+ tokenType: credential.tokenType,
332
+ requestedClaimsHash: credential.requestedClaimsHash,
333
+ };
334
+
335
+ const tokenKeys = this.getTokenKeys();
336
+ const currentScopes = ScopeSet.fromString(credential.target);
337
+
338
+ const removedAccessTokens: Array<Promise<void>> = [];
339
+ tokenKeys.accessToken.forEach((key) => {
340
+ if (
341
+ !this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)
342
+ ) {
343
+ return;
344
+ }
345
+
346
+ const tokenEntity = this.getAccessTokenCredential(key);
347
+
348
+ if (
349
+ tokenEntity &&
350
+ this.credentialMatchesFilter(tokenEntity, accessTokenFilter)
351
+ ) {
352
+ const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
353
+ if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
354
+ removedAccessTokens.push(this.removeAccessToken(key));
355
+ }
356
+ }
357
+ });
358
+ await Promise.all(removedAccessTokens);
359
+ this.setAccessTokenCredential(credential);
360
+ }
361
+
362
+ /**
363
+ * retrieve accounts matching all provided filters; if no filter is set, get all accounts
364
+ * not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
365
+ * @param homeAccountId
366
+ * @param environment
367
+ * @param realm
368
+ */
369
+ getAccountsFilteredBy(accountFilter: AccountFilter): AccountEntity[] {
370
+ const allAccountKeys = this.getAccountKeys();
371
+ const matchingAccounts: AccountEntity[] = [];
372
+
373
+ allAccountKeys.forEach((cacheKey) => {
374
+ if (
375
+ !this.isAccountKey(
376
+ cacheKey,
377
+ accountFilter.homeAccountId,
378
+ accountFilter.realm
379
+ )
380
+ ) {
381
+ // Don't parse value if the key doesn't match the account filters
382
+ return;
383
+ }
384
+
385
+ const entity: AccountEntity | null = this.getAccount(cacheKey);
386
+
387
+ if (!entity) {
388
+ return;
389
+ }
390
+
391
+ if (
392
+ !!accountFilter.homeAccountId &&
393
+ !this.matchHomeAccountId(entity, accountFilter.homeAccountId)
394
+ ) {
395
+ return;
396
+ }
397
+
398
+ if (
399
+ !!accountFilter.localAccountId &&
400
+ !this.matchLocalAccountId(entity, accountFilter.localAccountId)
401
+ ) {
402
+ return;
403
+ }
404
+
405
+ if (
406
+ !!accountFilter.username &&
407
+ !this.matchUsername(entity, accountFilter.username)
408
+ ) {
409
+ return;
410
+ }
411
+
412
+ if (
413
+ !!accountFilter.environment &&
414
+ !this.matchEnvironment(entity, accountFilter.environment)
415
+ ) {
416
+ return;
417
+ }
418
+
419
+ if (
420
+ !!accountFilter.realm &&
421
+ !this.matchRealm(entity, accountFilter.realm)
422
+ ) {
423
+ return;
424
+ }
425
+
426
+ if (
427
+ !!accountFilter.nativeAccountId &&
428
+ !this.matchNativeAccountId(
429
+ entity,
430
+ accountFilter.nativeAccountId
431
+ )
432
+ ) {
433
+ return;
434
+ }
435
+
436
+ matchingAccounts.push(entity);
437
+ });
438
+
439
+ return matchingAccounts;
440
+ }
441
+
442
+ /**
443
+ * Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
444
+ * @param key
445
+ * @param homeAccountId
446
+ * @param tenantId
447
+ * @returns
448
+ */
449
+ isAccountKey(
450
+ key: string,
451
+ homeAccountId?: string,
452
+ tenantId?: string
453
+ ): boolean {
454
+ if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 3) {
455
+ // Account cache keys contain 3 items separated by '-' (each item may also contain '-')
456
+ return false;
457
+ }
458
+
459
+ if (
460
+ homeAccountId &&
461
+ !key.toLowerCase().includes(homeAccountId.toLowerCase())
462
+ ) {
463
+ return false;
464
+ }
465
+
466
+ if (tenantId && !key.toLowerCase().includes(tenantId.toLowerCase())) {
467
+ return false;
468
+ }
469
+
470
+ // Do not check environment as aliasing can cause false negatives
471
+
472
+ return true;
473
+ }
474
+
475
+ /**
476
+ * Returns true if the given key matches our credential key schema.
477
+ * @param key
478
+ */
479
+ isCredentialKey(key: string): boolean {
480
+ if (key.split(Separators.CACHE_KEY_SEPARATOR).length < 6) {
481
+ // Credential cache keys contain 6 items separated by '-' (each item may also contain '-')
482
+ return false;
483
+ }
484
+
485
+ const lowerCaseKey = key.toLowerCase();
486
+ // Credential keys must indicate what credential type they represent
487
+ if (
488
+ lowerCaseKey.indexOf(CredentialType.ID_TOKEN.toLowerCase()) ===
489
+ -1 &&
490
+ lowerCaseKey.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) ===
491
+ -1 &&
492
+ lowerCaseKey.indexOf(
493
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()
494
+ ) === -1 &&
495
+ lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) ===
496
+ -1
497
+ ) {
498
+ return false;
499
+ }
500
+
501
+ if (
502
+ lowerCaseKey.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) >
503
+ -1
504
+ ) {
505
+ // Refresh tokens must contain the client id or family id
506
+ const clientIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${this.clientId}${Separators.CACHE_KEY_SEPARATOR}`;
507
+ const familyIdValidation = `${CredentialType.REFRESH_TOKEN}${Separators.CACHE_KEY_SEPARATOR}${THE_FAMILY_ID}${Separators.CACHE_KEY_SEPARATOR}`;
508
+ if (
509
+ lowerCaseKey.indexOf(clientIdValidation.toLowerCase()) === -1 &&
510
+ lowerCaseKey.indexOf(familyIdValidation.toLowerCase()) === -1
511
+ ) {
512
+ return false;
513
+ }
514
+ } else if (lowerCaseKey.indexOf(this.clientId.toLowerCase()) === -1) {
515
+ // Tokens must contain the clientId
516
+ return false;
517
+ }
518
+
519
+ return true;
520
+ }
521
+
522
+ /**
523
+ * Returns whether or not the given credential entity matches the filter
524
+ * @param entity
525
+ * @param filter
526
+ * @returns
527
+ */
528
+ credentialMatchesFilter(
529
+ entity: ValidCredentialType,
530
+ filter: CredentialFilter
531
+ ): boolean {
532
+ if (!!filter.clientId && !this.matchClientId(entity, filter.clientId)) {
533
+ return false;
534
+ }
535
+
536
+ if (
537
+ !!filter.userAssertionHash &&
538
+ !this.matchUserAssertionHash(entity, filter.userAssertionHash)
539
+ ) {
540
+ return false;
541
+ }
542
+
543
+ /*
544
+ * homeAccountId can be undefined, and we want to filter out cached items that have a homeAccountId of ""
545
+ * because we don't want a client_credential request to return a cached token that has a homeAccountId
546
+ */
547
+ if (
548
+ typeof filter.homeAccountId === "string" &&
549
+ !this.matchHomeAccountId(entity, filter.homeAccountId)
550
+ ) {
551
+ return false;
552
+ }
553
+
554
+ if (
555
+ !!filter.environment &&
556
+ !this.matchEnvironment(entity, filter.environment)
557
+ ) {
558
+ return false;
559
+ }
560
+
561
+ if (!!filter.realm && !this.matchRealm(entity, filter.realm)) {
562
+ return false;
563
+ }
564
+
565
+ if (
566
+ !!filter.credentialType &&
567
+ !this.matchCredentialType(entity, filter.credentialType)
568
+ ) {
569
+ return false;
570
+ }
571
+
572
+ if (!!filter.familyId && !this.matchFamilyId(entity, filter.familyId)) {
573
+ return false;
574
+ }
575
+
576
+ /*
577
+ * idTokens do not have "target", target specific refreshTokens do exist for some types of authentication
578
+ * Resource specific refresh tokens case will be added when the support is deemed necessary
579
+ */
580
+ if (!!filter.target && !this.matchTarget(entity, filter.target)) {
581
+ return false;
582
+ }
583
+
584
+ // If request OR cached entity has requested Claims Hash, check if they match
585
+ if (filter.requestedClaimsHash || entity.requestedClaimsHash) {
586
+ // Don't match if either is undefined or they are different
587
+ if (entity.requestedClaimsHash !== filter.requestedClaimsHash) {
588
+ return false;
589
+ }
590
+ }
591
+
592
+ // Access Token with Auth Scheme specific matching
593
+ if (
594
+ entity.credentialType ===
595
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
596
+ ) {
597
+ if (
598
+ !!filter.tokenType &&
599
+ !this.matchTokenType(entity, filter.tokenType)
600
+ ) {
601
+ return false;
602
+ }
603
+
604
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
605
+ if (filter.tokenType === AuthenticationScheme.SSH) {
606
+ if (filter.keyId && !this.matchKeyId(entity, filter.keyId)) {
607
+ return false;
608
+ }
609
+ }
610
+ }
611
+
612
+ return true;
613
+ }
614
+
615
+ /**
616
+ * retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
617
+ * @param filter
618
+ */
619
+ getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache {
620
+ return this.getAppMetadataFilteredByInternal(
621
+ filter.environment,
622
+ filter.clientId
623
+ );
624
+ }
625
+
626
+ /**
627
+ * Support function to help match appMetadata
628
+ * @param environment
629
+ * @param clientId
630
+ */
631
+ private getAppMetadataFilteredByInternal(
632
+ environment?: string,
633
+ clientId?: string
634
+ ): AppMetadataCache {
635
+ const allCacheKeys = this.getKeys();
636
+ const matchingAppMetadata: AppMetadataCache = {};
637
+
638
+ allCacheKeys.forEach((cacheKey) => {
639
+ // don't parse any non-appMetadata type cache entities
640
+ if (!this.isAppMetadata(cacheKey)) {
641
+ return;
642
+ }
643
+
644
+ // Attempt retrieval
645
+ const entity = this.getAppMetadata(cacheKey);
646
+
647
+ if (!entity) {
648
+ return;
649
+ }
650
+
651
+ if (!!environment && !this.matchEnvironment(entity, environment)) {
652
+ return;
653
+ }
654
+
655
+ if (!!clientId && !this.matchClientId(entity, clientId)) {
656
+ return;
657
+ }
658
+
659
+ matchingAppMetadata[cacheKey] = entity;
660
+ });
661
+
662
+ return matchingAppMetadata;
663
+ }
664
+
665
+ /**
666
+ * retrieve authorityMetadata that contains a matching alias
667
+ * @param filter
668
+ */
669
+ getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null {
670
+ const allCacheKeys = this.getAuthorityMetadataKeys();
671
+ let matchedEntity = null;
672
+
673
+ allCacheKeys.forEach((cacheKey) => {
674
+ // don't parse any non-authorityMetadata type cache entities
675
+ if (
676
+ !this.isAuthorityMetadata(cacheKey) ||
677
+ cacheKey.indexOf(this.clientId) === -1
678
+ ) {
679
+ return;
680
+ }
681
+
682
+ // Attempt retrieval
683
+ const entity = this.getAuthorityMetadata(cacheKey);
684
+
685
+ if (!entity) {
686
+ return;
687
+ }
688
+
689
+ if (entity.aliases.indexOf(host) === -1) {
690
+ return;
691
+ }
692
+
693
+ matchedEntity = entity;
694
+ });
695
+
696
+ return matchedEntity;
697
+ }
698
+
699
+ /**
700
+ * Removes all accounts and related tokens from cache.
701
+ */
702
+ async removeAllAccounts(): Promise<void> {
703
+ const allAccountKeys = this.getAccountKeys();
704
+ const removedAccounts: Array<Promise<void>> = [];
705
+
706
+ allAccountKeys.forEach((cacheKey) => {
707
+ removedAccounts.push(this.removeAccount(cacheKey));
708
+ });
709
+
710
+ await Promise.all(removedAccounts);
711
+ }
712
+
713
+ /**
714
+ * Removes the account and related tokens for a given account key
715
+ * @param account
716
+ */
717
+ async removeAccount(accountKey: string): Promise<void> {
718
+ const account = this.getAccount(accountKey);
719
+ if (!account) {
720
+ return;
721
+ }
722
+ await this.removeAccountContext(account);
723
+ this.removeItem(accountKey);
724
+ }
725
+
726
+ /**
727
+ * Removes credentials associated with the provided account
728
+ * @param account
729
+ */
730
+ async removeAccountContext(account: AccountEntity): Promise<void> {
731
+ const allTokenKeys = this.getTokenKeys();
732
+ const accountId = account.generateAccountId();
733
+ const removedCredentials: Array<Promise<void>> = [];
734
+
735
+ allTokenKeys.idToken.forEach((key) => {
736
+ if (key.indexOf(accountId) === 0) {
737
+ this.removeIdToken(key);
738
+ }
739
+ });
740
+
741
+ allTokenKeys.accessToken.forEach((key) => {
742
+ if (key.indexOf(accountId) === 0) {
743
+ removedCredentials.push(this.removeAccessToken(key));
744
+ }
745
+ });
746
+
747
+ allTokenKeys.refreshToken.forEach((key) => {
748
+ if (key.indexOf(accountId) === 0) {
749
+ this.removeRefreshToken(key);
750
+ }
751
+ });
752
+
753
+ await Promise.all(removedCredentials);
754
+ }
755
+
756
+ /**
757
+ * returns a boolean if the given credential is removed
758
+ * @param credential
759
+ */
760
+ async removeAccessToken(key: string): Promise<void> {
761
+ const credential = this.getAccessTokenCredential(key);
762
+ if (!credential) {
763
+ return;
764
+ }
765
+
766
+ // Remove Token Binding Key from key store for PoP Tokens Credentials
767
+ if (
768
+ credential.credentialType.toLowerCase() ===
769
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()
770
+ ) {
771
+ if (credential.tokenType === AuthenticationScheme.POP) {
772
+ const accessTokenWithAuthSchemeEntity =
773
+ credential as AccessTokenEntity;
774
+ const kid = accessTokenWithAuthSchemeEntity.keyId;
775
+
776
+ if (kid) {
777
+ try {
778
+ await this.cryptoImpl.removeTokenBindingKey(kid);
779
+ } catch (error) {
780
+ throw ClientAuthError.createBindingKeyNotRemovedError();
781
+ }
782
+ }
783
+ }
784
+ }
785
+
786
+ return this.removeItem(key);
787
+ }
788
+
789
+ /**
790
+ * Removes all app metadata objects from cache.
791
+ */
792
+ removeAppMetadata(): boolean {
793
+ const allCacheKeys = this.getKeys();
794
+ allCacheKeys.forEach((cacheKey) => {
795
+ if (this.isAppMetadata(cacheKey)) {
796
+ this.removeItem(cacheKey);
797
+ }
798
+ });
799
+
800
+ return true;
801
+ }
802
+
803
+ /**
804
+ * Retrieve the cached credentials into a cacherecord
805
+ * @param account
806
+ * @param clientId
807
+ * @param scopes
808
+ * @param environment
809
+ * @param authScheme
810
+ */
811
+ readCacheRecord(
812
+ account: AccountInfo,
813
+ request: BaseAuthRequest,
814
+ environment: string
815
+ ): CacheRecord {
816
+ const tokenKeys = this.getTokenKeys();
817
+ const cachedAccount = this.readAccountFromCache(account);
818
+ const cachedIdToken = this.getIdToken(account, tokenKeys);
819
+ const cachedAccessToken = this.getAccessToken(
820
+ account,
821
+ request,
822
+ tokenKeys
823
+ );
824
+ const cachedRefreshToken = this.getRefreshToken(
825
+ account,
826
+ false,
827
+ tokenKeys
828
+ );
829
+ const cachedAppMetadata = this.readAppMetadataFromCache(environment);
830
+
831
+ if (cachedAccount && cachedIdToken) {
832
+ cachedAccount.idTokenClaims = extractTokenClaims(
833
+ cachedIdToken.secret,
834
+ this.cryptoImpl.base64Decode
835
+ );
836
+ }
837
+
838
+ return {
839
+ account: cachedAccount,
840
+ idToken: cachedIdToken,
841
+ accessToken: cachedAccessToken,
842
+ refreshToken: cachedRefreshToken,
843
+ appMetadata: cachedAppMetadata,
844
+ };
845
+ }
846
+
847
+ /**
848
+ * Retrieve AccountEntity from cache
849
+ * @param account
850
+ */
851
+ readAccountFromCache(account: AccountInfo): AccountEntity | null {
852
+ const accountKey: string =
853
+ AccountEntity.generateAccountCacheKey(account);
854
+ return this.getAccount(accountKey);
855
+ }
856
+
857
+ /**
858
+ * Retrieve IdTokenEntity from cache
859
+ * @param clientId
860
+ * @param account
861
+ * @param inputRealm
862
+ */
863
+ getIdToken(
864
+ account: AccountInfo,
865
+ tokenKeys?: TokenKeys
866
+ ): IdTokenEntity | null {
867
+ this.commonLogger.trace("CacheManager - getIdToken called");
868
+ const idTokenFilter: CredentialFilter = {
869
+ homeAccountId: account.homeAccountId,
870
+ environment: account.environment,
871
+ credentialType: CredentialType.ID_TOKEN,
872
+ clientId: this.clientId,
873
+ realm: account.tenantId,
874
+ };
875
+
876
+ const idTokens: IdTokenEntity[] = this.getIdTokensByFilter(
877
+ idTokenFilter,
878
+ tokenKeys
879
+ );
880
+ const numIdTokens = idTokens.length;
881
+
882
+ if (numIdTokens < 1) {
883
+ this.commonLogger.info("CacheManager:getIdToken - No token found");
884
+ return null;
885
+ } else if (numIdTokens > 1) {
886
+ this.commonLogger.info(
887
+ "CacheManager:getIdToken - Multiple id tokens found, clearing them"
888
+ );
889
+ idTokens.forEach((idToken) => {
890
+ this.removeIdToken(idToken.generateCredentialKey());
891
+ });
892
+ return null;
893
+ }
894
+
895
+ this.commonLogger.info("CacheManager:getIdToken - Returning id token");
896
+ return idTokens[0];
897
+ }
898
+
899
+ /**
900
+ * Gets all idTokens matching the given filter
901
+ * @param filter
902
+ * @returns
903
+ */
904
+ getIdTokensByFilter(
905
+ filter: CredentialFilter,
906
+ tokenKeys?: TokenKeys
907
+ ): IdTokenEntity[] {
908
+ const idTokenKeys =
909
+ (tokenKeys && tokenKeys.idToken) || this.getTokenKeys().idToken;
910
+
911
+ const idTokens: IdTokenEntity[] = [];
912
+ idTokenKeys.forEach((key) => {
913
+ if (
914
+ !this.idTokenKeyMatchesFilter(key, {
915
+ clientId: this.clientId,
916
+ ...filter,
917
+ })
918
+ ) {
919
+ return;
920
+ }
921
+
922
+ const idToken = this.getIdTokenCredential(key);
923
+ if (idToken && this.credentialMatchesFilter(idToken, filter)) {
924
+ idTokens.push(idToken);
925
+ }
926
+ });
927
+
928
+ return idTokens;
929
+ }
930
+
931
+ /**
932
+ * Validate the cache key against filter before retrieving and parsing cache value
933
+ * @param key
934
+ * @param filter
935
+ * @returns
936
+ */
937
+ idTokenKeyMatchesFilter(
938
+ inputKey: string,
939
+ filter: CredentialFilter
940
+ ): boolean {
941
+ const key = inputKey.toLowerCase();
942
+ if (
943
+ filter.clientId &&
944
+ key.indexOf(filter.clientId.toLowerCase()) === -1
945
+ ) {
946
+ return false;
947
+ }
948
+
949
+ if (
950
+ filter.homeAccountId &&
951
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1
952
+ ) {
953
+ return false;
954
+ }
955
+
956
+ return true;
957
+ }
958
+
959
+ /**
960
+ * Removes idToken from the cache
961
+ * @param key
962
+ */
963
+ removeIdToken(key: string): void {
964
+ this.removeItem(key);
965
+ }
966
+
967
+ /**
968
+ * Removes refresh token from the cache
969
+ * @param key
970
+ */
971
+ removeRefreshToken(key: string): void {
972
+ this.removeItem(key);
973
+ }
974
+
975
+ /**
976
+ * Retrieve AccessTokenEntity from cache
977
+ * @param clientId
978
+ * @param account
979
+ * @param scopes
980
+ * @param authScheme
981
+ */
982
+ getAccessToken(
983
+ account: AccountInfo,
984
+ request: BaseAuthRequest,
985
+ tokenKeys?: TokenKeys
986
+ ): AccessTokenEntity | null {
987
+ this.commonLogger.trace("CacheManager - getAccessToken called");
988
+ const scopes = ScopeSet.createSearchScopes(request.scopes);
989
+ const authScheme =
990
+ request.authenticationScheme || AuthenticationScheme.BEARER;
991
+ /*
992
+ * Distinguish between Bearer and PoP/SSH token cache types
993
+ * Cast to lowercase to handle "bearer" from ADFS
994
+ */
995
+ const credentialType =
996
+ authScheme &&
997
+ authScheme.toLowerCase() !==
998
+ AuthenticationScheme.BEARER.toLowerCase()
999
+ ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME
1000
+ : CredentialType.ACCESS_TOKEN;
1001
+
1002
+ const accessTokenFilter: CredentialFilter = {
1003
+ homeAccountId: account.homeAccountId,
1004
+ environment: account.environment,
1005
+ credentialType: credentialType,
1006
+ clientId: this.clientId,
1007
+ realm: account.tenantId,
1008
+ target: scopes,
1009
+ tokenType: authScheme,
1010
+ keyId: request.sshKid,
1011
+ requestedClaimsHash: request.requestedClaimsHash,
1012
+ };
1013
+
1014
+ const accessTokenKeys =
1015
+ (tokenKeys && tokenKeys.accessToken) ||
1016
+ this.getTokenKeys().accessToken;
1017
+ const accessTokens: AccessTokenEntity[] = [];
1018
+
1019
+ accessTokenKeys.forEach((key) => {
1020
+ // Validate key
1021
+ if (
1022
+ this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)
1023
+ ) {
1024
+ const accessToken = this.getAccessTokenCredential(key);
1025
+
1026
+ // Validate value
1027
+ if (
1028
+ accessToken &&
1029
+ this.credentialMatchesFilter(accessToken, accessTokenFilter)
1030
+ ) {
1031
+ accessTokens.push(accessToken);
1032
+ }
1033
+ }
1034
+ });
1035
+
1036
+ const numAccessTokens = accessTokens.length;
1037
+ if (numAccessTokens < 1) {
1038
+ this.commonLogger.info(
1039
+ "CacheManager:getAccessToken - No token found"
1040
+ );
1041
+ return null;
1042
+ } else if (numAccessTokens > 1) {
1043
+ this.commonLogger.info(
1044
+ "CacheManager:getAccessToken - Multiple access tokens found, clearing them"
1045
+ );
1046
+ accessTokens.forEach((accessToken) => {
1047
+ void this.removeAccessToken(
1048
+ accessToken.generateCredentialKey()
1049
+ );
1050
+ });
1051
+ return null;
1052
+ }
1053
+
1054
+ this.commonLogger.info(
1055
+ "CacheManager:getAccessToken - Returning access token"
1056
+ );
1057
+ return accessTokens[0];
1058
+ }
1059
+
1060
+ /**
1061
+ * Validate the cache key against filter before retrieving and parsing cache value
1062
+ * @param key
1063
+ * @param filter
1064
+ * @param keyMustContainAllScopes
1065
+ * @returns
1066
+ */
1067
+ accessTokenKeyMatchesFilter(
1068
+ inputKey: string,
1069
+ filter: CredentialFilter,
1070
+ keyMustContainAllScopes: boolean
1071
+ ): boolean {
1072
+ const key = inputKey.toLowerCase();
1073
+ if (
1074
+ filter.clientId &&
1075
+ key.indexOf(filter.clientId.toLowerCase()) === -1
1076
+ ) {
1077
+ return false;
1078
+ }
1079
+
1080
+ if (
1081
+ filter.homeAccountId &&
1082
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1
1083
+ ) {
1084
+ return false;
1085
+ }
1086
+
1087
+ if (filter.realm && key.indexOf(filter.realm.toLowerCase()) === -1) {
1088
+ return false;
1089
+ }
1090
+
1091
+ if (
1092
+ filter.requestedClaimsHash &&
1093
+ key.indexOf(filter.requestedClaimsHash.toLowerCase()) === -1
1094
+ ) {
1095
+ return false;
1096
+ }
1097
+
1098
+ if (filter.target) {
1099
+ const scopes = filter.target.asArray();
1100
+ for (let i = 0; i < scopes.length; i++) {
1101
+ if (
1102
+ keyMustContainAllScopes &&
1103
+ !key.includes(scopes[i].toLowerCase())
1104
+ ) {
1105
+ // When performing a cache lookup a missing scope would be a cache miss
1106
+ return false;
1107
+ } else if (
1108
+ !keyMustContainAllScopes &&
1109
+ key.includes(scopes[i].toLowerCase())
1110
+ ) {
1111
+ // When performing a cache write, any token with a subset of requested scopes should be replaced
1112
+ return true;
1113
+ }
1114
+ }
1115
+ }
1116
+
1117
+ return true;
1118
+ }
1119
+
1120
+ /**
1121
+ * Gets all access tokens matching the filter
1122
+ * @param filter
1123
+ * @returns
1124
+ */
1125
+ getAccessTokensByFilter(filter: CredentialFilter): AccessTokenEntity[] {
1126
+ const tokenKeys = this.getTokenKeys();
1127
+
1128
+ const accessTokens: AccessTokenEntity[] = [];
1129
+ tokenKeys.accessToken.forEach((key) => {
1130
+ if (!this.accessTokenKeyMatchesFilter(key, filter, true)) {
1131
+ return;
1132
+ }
1133
+
1134
+ const accessToken = this.getAccessTokenCredential(key);
1135
+ if (
1136
+ accessToken &&
1137
+ this.credentialMatchesFilter(accessToken, filter)
1138
+ ) {
1139
+ accessTokens.push(accessToken);
1140
+ }
1141
+ });
1142
+
1143
+ return accessTokens;
1144
+ }
1145
+
1146
+ /**
1147
+ * Helper to retrieve the appropriate refresh token from cache
1148
+ * @param clientId
1149
+ * @param account
1150
+ * @param familyRT
1151
+ */
1152
+ getRefreshToken(
1153
+ account: AccountInfo,
1154
+ familyRT: boolean,
1155
+ tokenKeys?: TokenKeys
1156
+ ): RefreshTokenEntity | null {
1157
+ this.commonLogger.trace("CacheManager - getRefreshToken called");
1158
+ const id = familyRT ? THE_FAMILY_ID : undefined;
1159
+ const refreshTokenFilter: CredentialFilter = {
1160
+ homeAccountId: account.homeAccountId,
1161
+ environment: account.environment,
1162
+ credentialType: CredentialType.REFRESH_TOKEN,
1163
+ clientId: this.clientId,
1164
+ familyId: id,
1165
+ };
1166
+
1167
+ const refreshTokenKeys =
1168
+ (tokenKeys && tokenKeys.refreshToken) ||
1169
+ this.getTokenKeys().refreshToken;
1170
+ const refreshTokens: RefreshTokenEntity[] = [];
1171
+
1172
+ refreshTokenKeys.forEach((key) => {
1173
+ // Validate key
1174
+ if (this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
1175
+ const refreshToken = this.getRefreshTokenCredential(key);
1176
+ // Validate value
1177
+ if (
1178
+ refreshToken &&
1179
+ this.credentialMatchesFilter(
1180
+ refreshToken,
1181
+ refreshTokenFilter
1182
+ )
1183
+ ) {
1184
+ refreshTokens.push(refreshToken);
1185
+ }
1186
+ }
1187
+ });
1188
+
1189
+ const numRefreshTokens = refreshTokens.length;
1190
+ if (numRefreshTokens < 1) {
1191
+ this.commonLogger.info(
1192
+ "CacheManager:getRefreshToken - No refresh token found."
1193
+ );
1194
+ return null;
1195
+ }
1196
+ // address the else case after remove functions address environment aliases
1197
+
1198
+ this.commonLogger.info(
1199
+ "CacheManager:getRefreshToken - returning refresh token"
1200
+ );
1201
+ return refreshTokens[0] as RefreshTokenEntity;
1202
+ }
1203
+
1204
+ /**
1205
+ * Validate the cache key against filter before retrieving and parsing cache value
1206
+ * @param key
1207
+ * @param filter
1208
+ */
1209
+ refreshTokenKeyMatchesFilter(
1210
+ inputKey: string,
1211
+ filter: CredentialFilter
1212
+ ): boolean {
1213
+ const key = inputKey.toLowerCase();
1214
+ if (
1215
+ filter.familyId &&
1216
+ key.indexOf(filter.familyId.toLowerCase()) === -1
1217
+ ) {
1218
+ return false;
1219
+ }
1220
+
1221
+ // If familyId is used, clientId is not in the key
1222
+ if (
1223
+ !filter.familyId &&
1224
+ filter.clientId &&
1225
+ key.indexOf(filter.clientId.toLowerCase()) === -1
1226
+ ) {
1227
+ return false;
1228
+ }
1229
+
1230
+ if (
1231
+ filter.homeAccountId &&
1232
+ key.indexOf(filter.homeAccountId.toLowerCase()) === -1
1233
+ ) {
1234
+ return false;
1235
+ }
1236
+
1237
+ return true;
1238
+ }
1239
+
1240
+ /**
1241
+ * Retrieve AppMetadataEntity from cache
1242
+ */
1243
+ readAppMetadataFromCache(environment: string): AppMetadataEntity | null {
1244
+ const appMetadataFilter: AppMetadataFilter = {
1245
+ environment,
1246
+ clientId: this.clientId,
1247
+ };
1248
+
1249
+ const appMetadata: AppMetadataCache =
1250
+ this.getAppMetadataFilteredBy(appMetadataFilter);
1251
+ const appMetadataEntries: AppMetadataEntity[] = Object.keys(
1252
+ appMetadata
1253
+ ).map((key) => appMetadata[key]);
1254
+
1255
+ const numAppMetadata = appMetadataEntries.length;
1256
+ if (numAppMetadata < 1) {
1257
+ return null;
1258
+ } else if (numAppMetadata > 1) {
1259
+ throw ClientAuthError.createMultipleMatchingAppMetadataInCacheError();
1260
+ }
1261
+
1262
+ return appMetadataEntries[0] as AppMetadataEntity;
1263
+ }
1264
+
1265
+ /**
1266
+ * Return the family_id value associated with FOCI
1267
+ * @param environment
1268
+ * @param clientId
1269
+ */
1270
+ isAppMetadataFOCI(environment: string): boolean {
1271
+ const appMetadata = this.readAppMetadataFromCache(environment);
1272
+ return !!(appMetadata && appMetadata.familyId === THE_FAMILY_ID);
1273
+ }
1274
+
1275
+ /**
1276
+ * helper to match account ids
1277
+ * @param value
1278
+ * @param homeAccountId
1279
+ */
1280
+ private matchHomeAccountId(
1281
+ entity: AccountEntity | CredentialEntity,
1282
+ homeAccountId: string
1283
+ ): boolean {
1284
+ return !!(
1285
+ typeof entity.homeAccountId === "string" &&
1286
+ homeAccountId === entity.homeAccountId
1287
+ );
1288
+ }
1289
+
1290
+ /**
1291
+ * helper to match account ids
1292
+ * @param entity
1293
+ * @param localAccountId
1294
+ * @returns
1295
+ */
1296
+ private matchLocalAccountId(
1297
+ entity: AccountEntity,
1298
+ localAccountId: string
1299
+ ): boolean {
1300
+ return !!(
1301
+ typeof entity.localAccountId === "string" &&
1302
+ localAccountId === entity.localAccountId
1303
+ );
1304
+ }
1305
+
1306
+ /**
1307
+ * helper to match usernames
1308
+ * @param entity
1309
+ * @param username
1310
+ * @returns
1311
+ */
1312
+ private matchUsername(entity: AccountEntity, username: string): boolean {
1313
+ return !!(
1314
+ typeof entity.username === "string" &&
1315
+ username.toLowerCase() === entity.username.toLowerCase()
1316
+ );
1317
+ }
1318
+
1319
+ /**
1320
+ * helper to match assertion
1321
+ * @param value
1322
+ * @param oboAssertion
1323
+ */
1324
+ private matchUserAssertionHash(
1325
+ entity: CredentialEntity,
1326
+ userAssertionHash: string
1327
+ ): boolean {
1328
+ return !!(
1329
+ entity.userAssertionHash &&
1330
+ userAssertionHash === entity.userAssertionHash
1331
+ );
1332
+ }
1333
+
1334
+ /**
1335
+ * helper to match environment
1336
+ * @param value
1337
+ * @param environment
1338
+ */
1339
+ private matchEnvironment(
1340
+ entity: AccountEntity | CredentialEntity | AppMetadataEntity,
1341
+ environment: string
1342
+ ): boolean {
1343
+ const cloudMetadata = this.getAuthorityMetadataByAlias(environment);
1344
+ if (
1345
+ cloudMetadata &&
1346
+ cloudMetadata.aliases.indexOf(entity.environment) > -1
1347
+ ) {
1348
+ return true;
1349
+ }
1350
+
1351
+ return false;
1352
+ }
1353
+
1354
+ /**
1355
+ * helper to match credential type
1356
+ * @param entity
1357
+ * @param credentialType
1358
+ */
1359
+ private matchCredentialType(
1360
+ entity: CredentialEntity,
1361
+ credentialType: string
1362
+ ): boolean {
1363
+ return (
1364
+ entity.credentialType &&
1365
+ credentialType.toLowerCase() === entity.credentialType.toLowerCase()
1366
+ );
1367
+ }
1368
+
1369
+ /**
1370
+ * helper to match client ids
1371
+ * @param entity
1372
+ * @param clientId
1373
+ */
1374
+ private matchClientId(
1375
+ entity: CredentialEntity | AppMetadataEntity,
1376
+ clientId: string
1377
+ ): boolean {
1378
+ return !!(entity.clientId && clientId === entity.clientId);
1379
+ }
1380
+
1381
+ /**
1382
+ * helper to match family ids
1383
+ * @param entity
1384
+ * @param familyId
1385
+ */
1386
+ private matchFamilyId(
1387
+ entity: CredentialEntity | AppMetadataEntity,
1388
+ familyId: string
1389
+ ): boolean {
1390
+ return !!(entity.familyId && familyId === entity.familyId);
1391
+ }
1392
+
1393
+ /**
1394
+ * helper to match realm
1395
+ * @param entity
1396
+ * @param realm
1397
+ */
1398
+ private matchRealm(
1399
+ entity: AccountEntity | CredentialEntity,
1400
+ realm: string
1401
+ ): boolean {
1402
+ return !!(entity.realm && realm === entity.realm);
1403
+ }
1404
+
1405
+ /**
1406
+ * helper to match nativeAccountId
1407
+ * @param entity
1408
+ * @param nativeAccountId
1409
+ * @returns boolean indicating the match result
1410
+ */
1411
+ private matchNativeAccountId(
1412
+ entity: AccountEntity,
1413
+ nativeAccountId: string
1414
+ ): boolean {
1415
+ return !!(
1416
+ entity.nativeAccountId && nativeAccountId === entity.nativeAccountId
1417
+ );
1418
+ }
1419
+
1420
+ /**
1421
+ * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
1422
+ * @param entity
1423
+ * @param target
1424
+ */
1425
+ private matchTarget(entity: CredentialEntity, target: ScopeSet): boolean {
1426
+ const isNotAccessTokenCredential =
1427
+ entity.credentialType !== CredentialType.ACCESS_TOKEN &&
1428
+ entity.credentialType !==
1429
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
1430
+
1431
+ if (isNotAccessTokenCredential || !entity.target) {
1432
+ return false;
1433
+ }
1434
+
1435
+ const entityScopeSet: ScopeSet = ScopeSet.fromString(entity.target);
1436
+
1437
+ return entityScopeSet.containsScopeSet(target);
1438
+ }
1439
+
1440
+ /**
1441
+ * Returns true if the credential's tokenType or Authentication Scheme matches the one in the request, false otherwise
1442
+ * @param entity
1443
+ * @param tokenType
1444
+ */
1445
+ private matchTokenType(
1446
+ entity: CredentialEntity,
1447
+ tokenType: AuthenticationScheme
1448
+ ): boolean {
1449
+ return !!(entity.tokenType && entity.tokenType === tokenType);
1450
+ }
1451
+
1452
+ /**
1453
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
1454
+ * @param entity
1455
+ * @param tokenType
1456
+ */
1457
+ private matchKeyId(entity: CredentialEntity, keyId: string): boolean {
1458
+ return !!(entity.keyId && entity.keyId === keyId);
1459
+ }
1460
+
1461
+ /**
1462
+ * returns if a given cache entity is of the type appmetadata
1463
+ * @param key
1464
+ */
1465
+ private isAppMetadata(key: string): boolean {
1466
+ return key.indexOf(APP_METADATA) !== -1;
1467
+ }
1468
+
1469
+ /**
1470
+ * returns if a given cache entity is of the type authoritymetadata
1471
+ * @param key
1472
+ */
1473
+ protected isAuthorityMetadata(key: string): boolean {
1474
+ return key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) !== -1;
1475
+ }
1476
+
1477
+ /**
1478
+ * returns cache key used for cloud instance metadata
1479
+ */
1480
+ generateAuthorityMetadataCacheKey(authority: string): string {
1481
+ return `${AUTHORITY_METADATA_CONSTANTS.CACHE_KEY}-${this.clientId}-${authority}`;
1482
+ }
1483
+
1484
+ /**
1485
+ * Helper to convert serialized data to object
1486
+ * @param obj
1487
+ * @param json
1488
+ */
1489
+ static toObject<T>(obj: T, json: object): T {
1490
+ for (const propertyName in json) {
1491
+ obj[propertyName] = json[propertyName];
1492
+ }
1493
+ return obj;
1494
+ }
1495
+ }
1496
+
1497
+ /** @internal */
1498
+ export class DefaultStorageClass extends CacheManager {
1499
+ setAccount(): void {
1500
+ const notImplErr =
1501
+ "Storage interface - setAccount() has not been implemented for the cacheStorage interface.";
1502
+ throw AuthError.createUnexpectedError(notImplErr);
1503
+ }
1504
+ getAccount(): AccountEntity {
1505
+ const notImplErr =
1506
+ "Storage interface - getAccount() has not been implemented for the cacheStorage interface.";
1507
+ throw AuthError.createUnexpectedError(notImplErr);
1508
+ }
1509
+ setIdTokenCredential(): void {
1510
+ const notImplErr =
1511
+ "Storage interface - setIdTokenCredential() has not been implemented for the cacheStorage interface.";
1512
+ throw AuthError.createUnexpectedError(notImplErr);
1513
+ }
1514
+ getIdTokenCredential(): IdTokenEntity {
1515
+ const notImplErr =
1516
+ "Storage interface - getIdTokenCredential() has not been implemented for the cacheStorage interface.";
1517
+ throw AuthError.createUnexpectedError(notImplErr);
1518
+ }
1519
+ setAccessTokenCredential(): void {
1520
+ const notImplErr =
1521
+ "Storage interface - setAccessTokenCredential() has not been implemented for the cacheStorage interface.";
1522
+ throw AuthError.createUnexpectedError(notImplErr);
1523
+ }
1524
+ getAccessTokenCredential(): AccessTokenEntity {
1525
+ const notImplErr =
1526
+ "Storage interface - getAccessTokenCredential() has not been implemented for the cacheStorage interface.";
1527
+ throw AuthError.createUnexpectedError(notImplErr);
1528
+ }
1529
+ setRefreshTokenCredential(): void {
1530
+ const notImplErr =
1531
+ "Storage interface - setRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
1532
+ throw AuthError.createUnexpectedError(notImplErr);
1533
+ }
1534
+ getRefreshTokenCredential(): RefreshTokenEntity {
1535
+ const notImplErr =
1536
+ "Storage interface - getRefreshTokenCredential() has not been implemented for the cacheStorage interface.";
1537
+ throw AuthError.createUnexpectedError(notImplErr);
1538
+ }
1539
+ setAppMetadata(): void {
1540
+ const notImplErr =
1541
+ "Storage interface - setAppMetadata() has not been implemented for the cacheStorage interface.";
1542
+ throw AuthError.createUnexpectedError(notImplErr);
1543
+ }
1544
+ getAppMetadata(): AppMetadataEntity {
1545
+ const notImplErr =
1546
+ "Storage interface - getAppMetadata() has not been implemented for the cacheStorage interface.";
1547
+ throw AuthError.createUnexpectedError(notImplErr);
1548
+ }
1549
+ setServerTelemetry(): void {
1550
+ const notImplErr =
1551
+ "Storage interface - setServerTelemetry() has not been implemented for the cacheStorage interface.";
1552
+ throw AuthError.createUnexpectedError(notImplErr);
1553
+ }
1554
+ getServerTelemetry(): ServerTelemetryEntity {
1555
+ const notImplErr =
1556
+ "Storage interface - getServerTelemetry() has not been implemented for the cacheStorage interface.";
1557
+ throw AuthError.createUnexpectedError(notImplErr);
1558
+ }
1559
+ setAuthorityMetadata(): void {
1560
+ const notImplErr =
1561
+ "Storage interface - setAuthorityMetadata() has not been implemented for the cacheStorage interface.";
1562
+ throw AuthError.createUnexpectedError(notImplErr);
1563
+ }
1564
+ getAuthorityMetadata(): AuthorityMetadataEntity | null {
1565
+ const notImplErr =
1566
+ "Storage interface - getAuthorityMetadata() has not been implemented for the cacheStorage interface.";
1567
+ throw AuthError.createUnexpectedError(notImplErr);
1568
+ }
1569
+ getAuthorityMetadataKeys(): Array<string> {
1570
+ const notImplErr =
1571
+ "Storage interface - getAuthorityMetadataKeys() has not been implemented for the cacheStorage interface.";
1572
+ throw AuthError.createUnexpectedError(notImplErr);
1573
+ }
1574
+ setThrottlingCache(): void {
1575
+ const notImplErr =
1576
+ "Storage interface - setThrottlingCache() has not been implemented for the cacheStorage interface.";
1577
+ throw AuthError.createUnexpectedError(notImplErr);
1578
+ }
1579
+ getThrottlingCache(): ThrottlingEntity {
1580
+ const notImplErr =
1581
+ "Storage interface - getThrottlingCache() has not been implemented for the cacheStorage interface.";
1582
+ throw AuthError.createUnexpectedError(notImplErr);
1583
+ }
1584
+ removeItem(): boolean {
1585
+ const notImplErr =
1586
+ "Storage interface - removeItem() has not been implemented for the cacheStorage interface.";
1587
+ throw AuthError.createUnexpectedError(notImplErr);
1588
+ }
1589
+ containsKey(): boolean {
1590
+ const notImplErr =
1591
+ "Storage interface - containsKey() has not been implemented for the cacheStorage interface.";
1592
+ throw AuthError.createUnexpectedError(notImplErr);
1593
+ }
1594
+ getKeys(): string[] {
1595
+ const notImplErr =
1596
+ "Storage interface - getKeys() has not been implemented for the cacheStorage interface.";
1597
+ throw AuthError.createUnexpectedError(notImplErr);
1598
+ }
1599
+ getAccountKeys(): string[] {
1600
+ const notImplErr =
1601
+ "Storage interface - getAccountKeys() has not been implemented for the cacheStorage interface.";
1602
+ throw AuthError.createUnexpectedError(notImplErr);
1603
+ }
1604
+ getTokenKeys(): TokenKeys {
1605
+ const notImplErr =
1606
+ "Storage interface - getTokenKeys() has not been implemented for the cacheStorage interface.";
1607
+ throw AuthError.createUnexpectedError(notImplErr);
1608
+ }
1609
+ async clear(): Promise<void> {
1610
+ const notImplErr =
1611
+ "Storage interface - clear() has not been implemented for the cacheStorage interface.";
1612
+ throw AuthError.createUnexpectedError(notImplErr);
1613
+ }
1614
+ updateCredentialCacheKey(): string {
1615
+ const notImplErr =
1616
+ "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
1617
+ throw AuthError.createUnexpectedError(notImplErr);
1618
+ }
1619
+ }