@azure/msal-common 14.6.0-alpha.0 → 14.6.0

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 (203) hide show
  1. package/dist/account/AccountInfo.d.ts +58 -58
  2. package/dist/account/AccountInfo.mjs +59 -59
  3. package/dist/account/AuthToken.d.ts +17 -17
  4. package/dist/account/AuthToken.mjs +58 -58
  5. package/dist/account/CcsCredential.d.ts +9 -9
  6. package/dist/account/CcsCredential.mjs +8 -8
  7. package/dist/account/ClientCredentials.d.ts +14 -14
  8. package/dist/account/ClientInfo.d.ts +18 -18
  9. package/dist/account/ClientInfo.mjs +37 -37
  10. package/dist/account/TokenClaims.d.ts +83 -83
  11. package/dist/account/TokenClaims.mjs +20 -20
  12. package/dist/authority/Authority.d.ts +253 -254
  13. package/dist/authority/Authority.d.ts.map +1 -1
  14. package/dist/authority/Authority.mjs +827 -816
  15. package/dist/authority/Authority.mjs.map +1 -1
  16. package/dist/authority/AuthorityFactory.d.ts +31 -31
  17. package/dist/authority/AuthorityFactory.mjs +47 -47
  18. package/dist/authority/AuthorityMetadata.d.ts +503 -503
  19. package/dist/authority/AuthorityMetadata.mjs +603 -603
  20. package/dist/authority/AuthorityOptions.d.ts +27 -27
  21. package/dist/authority/AuthorityOptions.mjs +18 -18
  22. package/dist/authority/AuthorityType.d.ts +10 -10
  23. package/dist/authority/AuthorityType.mjs +13 -13
  24. package/dist/authority/AzureRegion.d.ts +1 -1
  25. package/dist/authority/AzureRegionConfiguration.d.ts +5 -5
  26. package/dist/authority/CloudDiscoveryMetadata.d.ts +5 -5
  27. package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +13 -13
  28. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +8 -8
  29. package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +9 -9
  30. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +8 -8
  31. package/dist/authority/ImdsOptions.d.ts +5 -5
  32. package/dist/authority/OIDCOptions.d.ts +8 -8
  33. package/dist/authority/OpenIdConfigResponse.d.ts +11 -11
  34. package/dist/authority/OpenIdConfigResponse.mjs +10 -10
  35. package/dist/authority/ProtocolMode.d.ts +8 -8
  36. package/dist/authority/ProtocolMode.mjs +11 -11
  37. package/dist/authority/RegionDiscovery.d.ts +32 -32
  38. package/dist/authority/RegionDiscovery.mjs +106 -106
  39. package/dist/authority/RegionDiscoveryMetadata.d.ts +6 -6
  40. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +15 -15
  41. package/dist/cache/CacheManager.d.ts +508 -508
  42. package/dist/cache/CacheManager.mjs +1237 -1237
  43. package/dist/cache/entities/AccessTokenEntity.d.ts +25 -25
  44. package/dist/cache/entities/AccountEntity.d.ts +106 -106
  45. package/dist/cache/entities/AccountEntity.mjs +244 -244
  46. package/dist/cache/entities/AppMetadataEntity.d.ts +11 -39
  47. package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -1
  48. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +15 -48
  49. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
  50. package/dist/cache/entities/CacheRecord.d.ts +14 -14
  51. package/dist/cache/entities/CacheRecord.mjs +14 -14
  52. package/dist/cache/entities/CredentialEntity.d.ts +30 -30
  53. package/dist/cache/entities/IdTokenEntity.d.ts +8 -8
  54. package/dist/cache/entities/RefreshTokenEntity.d.ts +7 -7
  55. package/dist/cache/entities/ServerTelemetryEntity.d.ts +5 -5
  56. package/dist/cache/entities/ThrottlingEntity.d.ts +7 -7
  57. package/dist/cache/interface/ICacheManager.d.ts +166 -166
  58. package/dist/cache/interface/ICachePlugin.d.ts +5 -5
  59. package/dist/cache/interface/ISerializableTokenCache.d.ts +4 -4
  60. package/dist/cache/persistence/TokenCacheContext.d.ts +23 -23
  61. package/dist/cache/persistence/TokenCacheContext.mjs +25 -25
  62. package/dist/cache/utils/CacheHelpers.d.ts +94 -70
  63. package/dist/cache/utils/CacheHelpers.d.ts.map +1 -1
  64. package/dist/cache/utils/CacheHelpers.mjs +326 -252
  65. package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
  66. package/dist/cache/utils/CacheTypes.d.ts +69 -69
  67. package/dist/client/AuthorizationCodeClient.d.ts +74 -74
  68. package/dist/client/AuthorizationCodeClient.mjs +402 -402
  69. package/dist/client/BaseClient.d.ts +51 -51
  70. package/dist/client/BaseClient.mjs +100 -100
  71. package/dist/client/RefreshTokenClient.d.ts +35 -35
  72. package/dist/client/RefreshTokenClient.mjs +204 -204
  73. package/dist/client/SilentFlowClient.d.ts +27 -27
  74. package/dist/client/SilentFlowClient.mjs +128 -128
  75. package/dist/config/AppTokenProvider.d.ts +38 -38
  76. package/dist/config/ClientConfiguration.d.ts +150 -150
  77. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  78. package/dist/config/ClientConfiguration.mjs +98 -96
  79. package/dist/config/ClientConfiguration.mjs.map +1 -1
  80. package/dist/constants/AADServerParamKeys.d.ts +52 -52
  81. package/dist/constants/AADServerParamKeys.mjs +56 -56
  82. package/dist/crypto/ICrypto.d.ts +58 -58
  83. package/dist/crypto/ICrypto.mjs +30 -30
  84. package/dist/crypto/IGuidGenerator.d.ts +4 -4
  85. package/dist/crypto/JoseHeader.d.ts +22 -22
  86. package/dist/crypto/JoseHeader.mjs +37 -37
  87. package/dist/crypto/PopTokenGenerator.d.ts +60 -60
  88. package/dist/crypto/PopTokenGenerator.mjs +82 -82
  89. package/dist/crypto/SignedHttpRequest.d.ts +15 -15
  90. package/dist/error/AuthError.d.ts +44 -44
  91. package/dist/error/AuthError.mjs +46 -46
  92. package/dist/error/AuthErrorCodes.d.ts +5 -5
  93. package/dist/error/AuthErrorCodes.mjs +9 -9
  94. package/dist/error/ClientAuthError.d.ts +237 -237
  95. package/dist/error/ClientAuthError.mjs +249 -249
  96. package/dist/error/ClientAuthErrorCodes.d.ts +44 -44
  97. package/dist/error/ClientAuthErrorCodes.mjs +48 -48
  98. package/dist/error/ClientConfigurationError.d.ts +128 -128
  99. package/dist/error/ClientConfigurationError.mjs +135 -135
  100. package/dist/error/ClientConfigurationErrorCodes.d.ts +22 -22
  101. package/dist/error/ClientConfigurationErrorCodes.mjs +26 -26
  102. package/dist/error/InteractionRequiredAuthError.d.ts +61 -61
  103. package/dist/error/InteractionRequiredAuthError.mjs +84 -84
  104. package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +7 -7
  105. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +13 -13
  106. package/dist/error/JoseHeaderError.d.ts +15 -15
  107. package/dist/error/JoseHeaderError.mjs +22 -22
  108. package/dist/error/JoseHeaderErrorCodes.d.ts +2 -2
  109. package/dist/error/JoseHeaderErrorCodes.mjs +6 -6
  110. package/dist/error/ServerError.d.ts +7 -7
  111. package/dist/error/ServerError.mjs +14 -14
  112. package/dist/index.cjs +8557 -8611
  113. package/dist/index.cjs.map +1 -1
  114. package/dist/index.d.ts +99 -99
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.mjs +2 -4
  117. package/dist/index.mjs.map +1 -1
  118. package/dist/logger/Logger.d.ts +95 -95
  119. package/dist/logger/Logger.mjs +188 -188
  120. package/dist/network/INetworkModule.d.ts +29 -29
  121. package/dist/network/INetworkModule.mjs +12 -12
  122. package/dist/network/NetworkManager.d.ts +33 -33
  123. package/dist/network/NetworkManager.mjs +34 -34
  124. package/dist/network/RequestThumbprint.d.ts +18 -18
  125. package/dist/network/ThrottlingUtils.d.ts +42 -42
  126. package/dist/network/ThrottlingUtils.mjs +95 -95
  127. package/dist/packageMetadata.d.ts +2 -2
  128. package/dist/packageMetadata.d.ts.map +1 -1
  129. package/dist/packageMetadata.mjs +4 -4
  130. package/dist/request/AuthenticationHeaderParser.d.ts +19 -19
  131. package/dist/request/AuthenticationHeaderParser.mjs +55 -55
  132. package/dist/request/BaseAuthRequest.d.ts +43 -43
  133. package/dist/request/CommonAuthorizationCodeRequest.d.ts +27 -27
  134. package/dist/request/CommonAuthorizationUrlRequest.d.ts +50 -50
  135. package/dist/request/CommonClientCredentialRequest.d.ts +17 -17
  136. package/dist/request/CommonDeviceCodeRequest.d.ts +21 -21
  137. package/dist/request/CommonEndSessionRequest.d.ts +21 -21
  138. package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -13
  139. package/dist/request/CommonRefreshTokenRequest.d.ts +22 -22
  140. package/dist/request/CommonSilentFlowRequest.d.ts +27 -27
  141. package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -17
  142. package/dist/request/NativeRequest.d.ts +19 -19
  143. package/dist/request/NativeSignOutRequest.d.ts +5 -5
  144. package/dist/request/RequestParameterBuilder.d.ts +217 -217
  145. package/dist/request/RequestParameterBuilder.mjs +381 -381
  146. package/dist/request/RequestValidator.d.ts +33 -33
  147. package/dist/request/RequestValidator.mjs +81 -81
  148. package/dist/request/ScopeSet.d.ts +88 -88
  149. package/dist/request/ScopeSet.mjs +197 -197
  150. package/dist/request/StoreInCache.d.ts +8 -8
  151. package/dist/response/AuthenticationResult.d.ts +41 -41
  152. package/dist/response/AuthorizationCodePayload.d.ts +13 -13
  153. package/dist/response/DeviceCodeResponse.d.ts +25 -25
  154. package/dist/response/ExternalTokenResponse.d.ts +15 -15
  155. package/dist/response/IMDSBadResponse.d.ts +4 -4
  156. package/dist/response/ResponseHandler.d.ts +69 -69
  157. package/dist/response/ResponseHandler.mjs +350 -347
  158. package/dist/response/ResponseHandler.mjs.map +1 -1
  159. package/dist/response/ServerAuthorizationCodeResponse.d.ts +25 -25
  160. package/dist/response/ServerAuthorizationTokenResponse.d.ts +47 -47
  161. package/dist/telemetry/performance/IPerformanceClient.d.ts +57 -57
  162. package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +5 -5
  163. package/dist/telemetry/performance/PerformanceClient.d.ts +198 -198
  164. package/dist/telemetry/performance/PerformanceClient.mjs +412 -412
  165. package/dist/telemetry/performance/PerformanceEvent.d.ts +464 -464
  166. package/dist/telemetry/performance/PerformanceEvent.mjs +253 -253
  167. package/dist/telemetry/performance/StubPerformanceClient.d.ts +24 -24
  168. package/dist/telemetry/performance/StubPerformanceClient.mjs +76 -76
  169. package/dist/telemetry/server/ServerTelemetryManager.d.ts +66 -66
  170. package/dist/telemetry/server/ServerTelemetryManager.mjs +201 -201
  171. package/dist/telemetry/server/ServerTelemetryRequest.d.ts +8 -8
  172. package/dist/url/IUri.d.ts +12 -12
  173. package/dist/url/UrlString.d.ts +48 -48
  174. package/dist/url/UrlString.mjs +161 -161
  175. package/dist/utils/Constants.d.ts +296 -298
  176. package/dist/utils/Constants.d.ts.map +1 -1
  177. package/dist/utils/Constants.mjs +310 -313
  178. package/dist/utils/Constants.mjs.map +1 -1
  179. package/dist/utils/FunctionWrappers.d.ts +27 -27
  180. package/dist/utils/FunctionWrappers.mjs +84 -84
  181. package/dist/utils/MsalTypes.d.ts +6 -6
  182. package/dist/utils/ProtocolUtils.d.ts +42 -42
  183. package/dist/utils/ProtocolUtils.mjs +69 -69
  184. package/dist/utils/StringUtils.d.ts +40 -40
  185. package/dist/utils/StringUtils.mjs +95 -95
  186. package/dist/utils/TimeUtils.d.ts +27 -27
  187. package/dist/utils/TimeUtils.mjs +45 -45
  188. package/dist/utils/UrlUtils.d.ts +10 -10
  189. package/dist/utils/UrlUtils.mjs +44 -44
  190. package/package.json +1 -1
  191. package/src/authority/Authority.ts +58 -25
  192. package/src/cache/entities/AppMetadataEntity.ts +6 -81
  193. package/src/cache/entities/AuthorityMetadataEntity.ts +2 -94
  194. package/src/cache/utils/CacheHelpers.ts +111 -0
  195. package/src/config/ClientConfiguration.ts +4 -4
  196. package/src/index.ts +0 -1
  197. package/src/packageMetadata.ts +1 -1
  198. package/src/response/ResponseHandler.ts +5 -5
  199. package/src/utils/Constants.ts +0 -4
  200. package/dist/cache/entities/AppMetadataEntity.mjs +0 -73
  201. package/dist/cache/entities/AppMetadataEntity.mjs.map +0 -1
  202. package/dist/cache/entities/AuthorityMetadataEntity.mjs +0 -86
  203. package/dist/cache/entities/AuthorityMetadataEntity.mjs.map +0 -1
@@ -57,6 +57,7 @@ import { AuthError } from "../error/AuthError";
57
57
  import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient";
58
58
  import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent";
59
59
  import { invokeAsync } from "../utils/FunctionWrappers";
60
+ import * as CacheHelpers from "../cache/utils/CacheHelpers";
60
61
 
61
62
  /**
62
63
  * The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
@@ -86,8 +87,6 @@ export class Authority {
86
87
  protected performanceClient: IPerformanceClient | undefined;
87
88
  // Correlation Id
88
89
  protected correlationId: string | undefined;
89
- // Indicates if the authority is fake, for the purpose of a Managed Identity Application
90
- private managedIdentity: boolean;
91
90
  // Reserved tenant domain names that will not be replaced with tenant id
92
91
  private static reservedTenantDomains: Set<string> = new Set([
93
92
  "{tenant}",
@@ -104,8 +103,7 @@ export class Authority {
104
103
  authorityOptions: AuthorityOptions,
105
104
  logger: Logger,
106
105
  performanceClient?: IPerformanceClient,
107
- correlationId?: string,
108
- managedIdentity?: boolean
106
+ correlationId?: string
109
107
  ) {
110
108
  this.canonicalAuthority = authority;
111
109
  this._canonicalAuthority.validateAsUri();
@@ -120,7 +118,6 @@ export class Authority {
120
118
  this.logger = logger;
121
119
  this.performanceClient = performanceClient;
122
120
  this.correlationId = correlationId;
123
- this.managedIdentity = managedIdentity || false;
124
121
  this.regionDiscovery = new RegionDiscovery(
125
122
  networkInterface,
126
123
  this.logger,
@@ -386,7 +383,7 @@ export class Authority {
386
383
  }
387
384
 
388
385
  /**
389
- * Boolean that returns whether or not tenant discovery has been completed.
386
+ * Boolean that returns whethr or not tenant discovery has been completed.
390
387
  */
391
388
  discoveryComplete(): boolean {
392
389
  return !!this.metadata;
@@ -433,13 +430,24 @@ export class Authority {
433
430
  * @returns
434
431
  */
435
432
  private getCurrentMetadataEntity(): AuthorityMetadataEntity {
436
- let metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(
437
- this.hostnameAndPort
438
- );
433
+ let metadataEntity: AuthorityMetadataEntity | null =
434
+ this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
439
435
 
440
436
  if (!metadataEntity) {
441
- metadataEntity = new AuthorityMetadataEntity();
442
- metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
437
+ metadataEntity = {
438
+ aliases: [],
439
+ preferred_cache: this.hostnameAndPort,
440
+ preferred_network: this.hostnameAndPort,
441
+ canonical_authority: this.canonicalAuthority,
442
+ authorization_endpoint: "",
443
+ token_endpoint: "",
444
+ end_session_endpoint: "",
445
+ issuer: "",
446
+ aliasesFromNetwork: false,
447
+ endpointsFromNetwork: false,
448
+ expiresAt: CacheHelpers.generateAuthorityMetadataExpiresAt(),
449
+ jwks_uri: "",
450
+ };
443
451
  }
444
452
  return metadataEntity;
445
453
  }
@@ -464,8 +472,9 @@ export class Authority {
464
472
  endpointMetadataResult?.source !== AuthorityMetadataSource.CACHE
465
473
  ) {
466
474
  // Reset the expiration time unless both values came from a successful cache lookup
467
- metadataEntity.resetExpiresAt();
468
- metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
475
+ metadataEntity.expiresAt =
476
+ CacheHelpers.generateAuthorityMetadataExpiresAt();
477
+ metadataEntity.canonical_authority = this.canonicalAuthority;
469
478
  }
470
479
 
471
480
  const cacheKey = this.cacheManager.generateAuthorityMetadataCacheKey(
@@ -510,10 +519,13 @@ export class Authority {
510
519
  this.performanceClient,
511
520
  this.correlationId
512
521
  )(localMetadata.metadata);
513
- metadataEntity.updateEndpointMetadata(
522
+ CacheHelpers.updateAuthorityEndpointMetadata(
523
+ metadataEntity,
514
524
  hardcodedMetadata,
515
525
  false
516
526
  );
527
+ metadataEntity.canonical_authority =
528
+ this.canonicalAuthority;
517
529
  }
518
530
  }
519
531
  }
@@ -540,7 +552,11 @@ export class Authority {
540
552
  )(metadata);
541
553
  }
542
554
 
543
- metadataEntity.updateEndpointMetadata(metadata, true);
555
+ CacheHelpers.updateAuthorityEndpointMetadata(
556
+ metadataEntity,
557
+ metadata,
558
+ true
559
+ );
544
560
  return AuthorityMetadataSource.NETWORK;
545
561
  } else {
546
562
  // Metadata could not be obtained from the config, cache, network or hardcoded values
@@ -571,7 +587,11 @@ export class Authority {
571
587
  this.logger.verbose(
572
588
  "Found endpoint metadata in authority configuration"
573
589
  );
574
- metadataEntity.updateEndpointMetadata(configMetadata, false);
590
+ CacheHelpers.updateAuthorityEndpointMetadata(
591
+ metadataEntity,
592
+ configMetadata,
593
+ false
594
+ );
575
595
  return {
576
596
  source: AuthorityMetadataSource.CONFIG,
577
597
  };
@@ -590,7 +610,11 @@ export class Authority {
590
610
  const hardcodedMetadata =
591
611
  this.getEndpointMetadataFromHardcodedValues();
592
612
  if (hardcodedMetadata) {
593
- metadataEntity.updateEndpointMetadata(hardcodedMetadata, false);
613
+ CacheHelpers.updateAuthorityEndpointMetadata(
614
+ metadataEntity,
615
+ hardcodedMetadata,
616
+ false
617
+ );
594
618
  return {
595
619
  source: AuthorityMetadataSource.HARDCODED_VALUES,
596
620
  metadata: hardcodedMetadata,
@@ -603,7 +627,8 @@ export class Authority {
603
627
  }
604
628
 
605
629
  // Check cached metadata entity expiration status
606
- const metadataEntityExpired = metadataEntity.isExpired();
630
+ const metadataEntityExpired =
631
+ CacheHelpers.isAuthorityMetadataExpired(metadataEntity);
607
632
  if (
608
633
  this.isAuthoritySameType(metadataEntity) &&
609
634
  metadataEntity.endpointsFromNetwork &&
@@ -805,7 +830,11 @@ export class Authority {
805
830
  )();
806
831
 
807
832
  if (metadata) {
808
- metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
833
+ CacheHelpers.updateCloudDiscoveryMetadata(
834
+ metadataEntity,
835
+ metadata,
836
+ true
837
+ );
809
838
  return AuthorityMetadataSource.NETWORK;
810
839
  }
811
840
 
@@ -843,7 +872,11 @@ export class Authority {
843
872
  this.logger.verbose(
844
873
  "Found cloud discovery metadata in authority configuration"
845
874
  );
846
- metadataEntity.updateCloudDiscoveryMetadata(metadata, false);
875
+ CacheHelpers.updateCloudDiscoveryMetadata(
876
+ metadataEntity,
877
+ metadata,
878
+ false
879
+ );
847
880
  return AuthorityMetadataSource.CONFIG;
848
881
  }
849
882
 
@@ -865,7 +898,8 @@ export class Authority {
865
898
  this.logger.verbose(
866
899
  "Found cloud discovery metadata from hardcoded values."
867
900
  );
868
- metadataEntity.updateCloudDiscoveryMetadata(
901
+ CacheHelpers.updateCloudDiscoveryMetadata(
902
+ metadataEntity,
869
903
  hardcodedMetadata,
870
904
  false
871
905
  );
@@ -877,7 +911,8 @@ export class Authority {
877
911
  );
878
912
  }
879
913
 
880
- const metadataEntityExpired = metadataEntity.isExpired();
914
+ const metadataEntityExpired =
915
+ CacheHelpers.isAuthorityMetadataExpired(metadataEntity);
881
916
  if (
882
917
  this.isAuthoritySameType(metadataEntity) &&
883
918
  metadataEntity.aliasesFromNetwork &&
@@ -1123,9 +1158,7 @@ export class Authority {
1123
1158
  * helper function to generate environment from authority object
1124
1159
  */
1125
1160
  getPreferredCache(): string {
1126
- if (this.managedIdentity) {
1127
- return Constants.DEFAULT_AUTHORITY_HOST;
1128
- } else if (this.discoveryComplete()) {
1161
+ if (this.discoveryComplete()) {
1129
1162
  return this.metadata.preferred_cache;
1130
1163
  } else {
1131
1164
  throw createClientAuthError(
@@ -3,89 +3,14 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { APP_METADATA, Separators } from "../../utils/Constants";
7
-
8
6
  /**
9
- * APP_METADATA Cache
10
- *
11
- * Key:Value Schema:
12
- *
13
- * Key: appmetadata-<environment>-<client_id>
14
- *
15
- * Value:
16
- * {
17
- * clientId: client ID of the application
18
- * environment: entity that issued the token, represented as a full host
19
- * familyId: Family ID identifier, '1' represents Microsoft Family
20
- * }
7
+ * App Metadata Cache Type
21
8
  */
22
- export class AppMetadataEntity {
9
+ export type AppMetadataEntity = {
10
+ /** clientId of the application */
23
11
  clientId: string;
12
+ /** entity that issued the token, represented as a full host */
24
13
  environment: string;
14
+ /** Family identifier, '1' represents Microsoft Family */
25
15
  familyId?: string;
26
-
27
- /**
28
- * Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>
29
- */
30
- generateAppMetadataKey(): string {
31
- return AppMetadataEntity.generateAppMetadataCacheKey(
32
- this.environment,
33
- this.clientId
34
- );
35
- }
36
-
37
- /**
38
- * Generate AppMetadata Cache Key
39
- */
40
- static generateAppMetadataCacheKey(
41
- environment: string,
42
- clientId: string
43
- ): string {
44
- const appMetaDataKeyArray: Array<string> = [
45
- APP_METADATA,
46
- environment,
47
- clientId,
48
- ];
49
- return appMetaDataKeyArray
50
- .join(Separators.CACHE_KEY_SEPARATOR)
51
- .toLowerCase();
52
- }
53
-
54
- /**
55
- * Creates AppMetadataEntity
56
- * @param clientId
57
- * @param environment
58
- * @param familyId
59
- */
60
- static createAppMetadataEntity(
61
- clientId: string,
62
- environment: string,
63
- familyId?: string
64
- ): AppMetadataEntity {
65
- const appMetadata = new AppMetadataEntity();
66
-
67
- appMetadata.clientId = clientId;
68
- appMetadata.environment = environment;
69
- if (familyId) {
70
- appMetadata.familyId = familyId;
71
- }
72
-
73
- return appMetadata;
74
- }
75
-
76
- /**
77
- * Validates an entity: checks for all expected params
78
- * @param entity
79
- */
80
- static isAppMetadataEntity(key: string, entity: object): boolean {
81
- if (!entity) {
82
- return false;
83
- }
84
-
85
- return (
86
- key.indexOf(APP_METADATA) === 0 &&
87
- entity.hasOwnProperty("clientId") &&
88
- entity.hasOwnProperty("environment")
89
- );
90
- }
91
- }
16
+ };
@@ -3,13 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { CloudDiscoveryMetadata } from "../../authority/CloudDiscoveryMetadata";
7
- import { OpenIdConfigResponse } from "../../authority/OpenIdConfigResponse";
8
- import { AUTHORITY_METADATA_CONSTANTS } from "../../utils/Constants";
9
- import { TimeUtils } from "../../utils/TimeUtils";
10
-
11
6
  /** @internal */
12
- export class AuthorityMetadataEntity {
7
+ export type AuthorityMetadataEntity = {
13
8
  aliases: Array<string>;
14
9
  preferred_cache: string;
15
10
  preferred_network: string;
@@ -22,91 +17,4 @@ export class AuthorityMetadataEntity {
22
17
  endpointsFromNetwork: boolean;
23
18
  expiresAt: number;
24
19
  jwks_uri: string;
25
-
26
- constructor() {
27
- this.expiresAt =
28
- TimeUtils.nowSeconds() +
29
- AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;
30
- }
31
-
32
- /**
33
- * Update the entity with new aliases, preferred_cache and preferred_network values
34
- * @param metadata
35
- * @param fromNetwork
36
- */
37
- updateCloudDiscoveryMetadata(
38
- metadata: CloudDiscoveryMetadata,
39
- fromNetwork: boolean
40
- ): void {
41
- this.aliases = metadata.aliases;
42
- this.preferred_cache = metadata.preferred_cache;
43
- this.preferred_network = metadata.preferred_network;
44
- this.aliasesFromNetwork = fromNetwork;
45
- }
46
-
47
- /**
48
- * Update the entity with new endpoints
49
- * @param metadata
50
- * @param fromNetwork
51
- */
52
- updateEndpointMetadata(
53
- metadata: OpenIdConfigResponse,
54
- fromNetwork: boolean
55
- ): void {
56
- this.authorization_endpoint = metadata.authorization_endpoint;
57
- this.token_endpoint = metadata.token_endpoint;
58
- this.end_session_endpoint = metadata.end_session_endpoint;
59
- this.issuer = metadata.issuer;
60
- this.endpointsFromNetwork = fromNetwork;
61
- this.jwks_uri = metadata.jwks_uri;
62
- }
63
-
64
- /**
65
- * Save the authority that was used to create this cache entry
66
- * @param authority
67
- */
68
- updateCanonicalAuthority(authority: string): void {
69
- this.canonical_authority = authority;
70
- }
71
-
72
- /**
73
- * Reset the exiresAt value
74
- */
75
- resetExpiresAt(): void {
76
- this.expiresAt =
77
- TimeUtils.nowSeconds() +
78
- AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS;
79
- }
80
-
81
- /**
82
- * Returns whether or not the data needs to be refreshed
83
- */
84
- isExpired(): boolean {
85
- return this.expiresAt <= TimeUtils.nowSeconds();
86
- }
87
-
88
- /**
89
- * Validates an entity: checks for all expected params
90
- * @param entity
91
- */
92
- static isAuthorityMetadataEntity(key: string, entity: object): boolean {
93
- if (!entity) {
94
- return false;
95
- }
96
-
97
- return (
98
- key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) === 0 &&
99
- entity.hasOwnProperty("aliases") &&
100
- entity.hasOwnProperty("preferred_cache") &&
101
- entity.hasOwnProperty("preferred_network") &&
102
- entity.hasOwnProperty("canonical_authority") &&
103
- entity.hasOwnProperty("authorization_endpoint") &&
104
- entity.hasOwnProperty("token_endpoint") &&
105
- entity.hasOwnProperty("issuer") &&
106
- entity.hasOwnProperty("aliasesFromNetwork") &&
107
- entity.hasOwnProperty("endpointsFromNetwork") &&
108
- entity.hasOwnProperty("expiresAt") &&
109
- entity.hasOwnProperty("jwks_uri")
110
- );
111
- }
112
- }
20
+ };
@@ -5,11 +5,15 @@
5
5
 
6
6
  import { extractTokenClaims } from "../../account/AuthToken";
7
7
  import { TokenClaims } from "../../account/TokenClaims";
8
+ import { CloudDiscoveryMetadata } from "../../authority/CloudDiscoveryMetadata";
9
+ import { OpenIdConfigResponse } from "../../authority/OpenIdConfigResponse";
8
10
  import {
9
11
  ClientAuthErrorCodes,
10
12
  createClientAuthError,
11
13
  } from "../../error/ClientAuthError";
12
14
  import {
15
+ APP_METADATA,
16
+ AUTHORITY_METADATA_CONSTANTS,
13
17
  AuthenticationScheme,
14
18
  CredentialType,
15
19
  SERVER_TELEM_CONSTANTS,
@@ -18,6 +22,8 @@ import {
18
22
  } from "../../utils/Constants";
19
23
  import { TimeUtils } from "../../utils/TimeUtils";
20
24
  import { AccessTokenEntity } from "../entities/AccessTokenEntity";
25
+ import { AppMetadataEntity } from "../entities/AppMetadataEntity";
26
+ import { AuthorityMetadataEntity } from "../entities/AuthorityMetadataEntity";
21
27
  import { CredentialEntity } from "../entities/CredentialEntity";
22
28
  import { IdTokenEntity } from "../entities/IdTokenEntity";
23
29
  import { RefreshTokenEntity } from "../entities/RefreshTokenEntity";
@@ -350,3 +356,108 @@ export function isThrottlingEntity(key: string, entity?: object): boolean {
350
356
 
351
357
  return validateKey && validateEntity;
352
358
  }
359
+
360
+ /**
361
+ * Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>
362
+ */
363
+ export function generateAppMetadataKey({
364
+ environment,
365
+ clientId,
366
+ }: AppMetadataEntity): string {
367
+ const appMetaDataKeyArray: Array<string> = [
368
+ APP_METADATA,
369
+ environment,
370
+ clientId,
371
+ ];
372
+ return appMetaDataKeyArray
373
+ .join(Separators.CACHE_KEY_SEPARATOR)
374
+ .toLowerCase();
375
+ }
376
+
377
+ /*
378
+ * Validates an entity: checks for all expected params
379
+ * @param entity
380
+ */
381
+ export function isAppMetadataEntity(key: string, entity: object): boolean {
382
+ if (!entity) {
383
+ return false;
384
+ }
385
+
386
+ return (
387
+ key.indexOf(APP_METADATA) === 0 &&
388
+ entity.hasOwnProperty("clientId") &&
389
+ entity.hasOwnProperty("environment")
390
+ );
391
+ }
392
+
393
+ /**
394
+ * Validates an entity: checks for all expected params
395
+ * @param entity
396
+ */
397
+ export function isAuthorityMetadataEntity(
398
+ key: string,
399
+ entity: object
400
+ ): boolean {
401
+ if (!entity) {
402
+ return false;
403
+ }
404
+
405
+ return (
406
+ key.indexOf(AUTHORITY_METADATA_CONSTANTS.CACHE_KEY) === 0 &&
407
+ entity.hasOwnProperty("aliases") &&
408
+ entity.hasOwnProperty("preferred_cache") &&
409
+ entity.hasOwnProperty("preferred_network") &&
410
+ entity.hasOwnProperty("canonical_authority") &&
411
+ entity.hasOwnProperty("authorization_endpoint") &&
412
+ entity.hasOwnProperty("token_endpoint") &&
413
+ entity.hasOwnProperty("issuer") &&
414
+ entity.hasOwnProperty("aliasesFromNetwork") &&
415
+ entity.hasOwnProperty("endpointsFromNetwork") &&
416
+ entity.hasOwnProperty("expiresAt") &&
417
+ entity.hasOwnProperty("jwks_uri")
418
+ );
419
+ }
420
+
421
+ /**
422
+ * Reset the exiresAt value
423
+ */
424
+ export function generateAuthorityMetadataExpiresAt(): number {
425
+ return (
426
+ TimeUtils.nowSeconds() +
427
+ AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS
428
+ );
429
+ }
430
+
431
+ export function updateAuthorityEndpointMetadata(
432
+ authorityMetadata: AuthorityMetadataEntity,
433
+ updatedValues: OpenIdConfigResponse,
434
+ fromNetwork: boolean
435
+ ): void {
436
+ authorityMetadata.authorization_endpoint =
437
+ updatedValues.authorization_endpoint;
438
+ authorityMetadata.token_endpoint = updatedValues.token_endpoint;
439
+ authorityMetadata.end_session_endpoint = updatedValues.end_session_endpoint;
440
+ authorityMetadata.issuer = updatedValues.issuer;
441
+ authorityMetadata.endpointsFromNetwork = fromNetwork;
442
+ authorityMetadata.jwks_uri = updatedValues.jwks_uri;
443
+ }
444
+
445
+ export function updateCloudDiscoveryMetadata(
446
+ authorityMetadata: AuthorityMetadataEntity,
447
+ updatedValues: CloudDiscoveryMetadata,
448
+ fromNetwork: boolean
449
+ ): void {
450
+ authorityMetadata.aliases = updatedValues.aliases;
451
+ authorityMetadata.preferred_cache = updatedValues.preferred_cache;
452
+ authorityMetadata.preferred_network = updatedValues.preferred_network;
453
+ authorityMetadata.aliasesFromNetwork = fromNetwork;
454
+ }
455
+
456
+ /**
457
+ * Returns whether or not the data needs to be refreshed
458
+ */
459
+ export function isAuthorityMetadataExpired(
460
+ metadata: AuthorityMetadataEntity
461
+ ): boolean {
462
+ return metadata.expiresAt <= TimeUtils.nowSeconds();
463
+ }
@@ -6,10 +6,7 @@
6
6
  import { INetworkModule } from "../network/INetworkModule";
7
7
  import { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from "../crypto/ICrypto";
8
8
  import { ILoggerCallback, Logger, LogLevel } from "../logger/Logger";
9
- import {
10
- Constants,
11
- DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
12
- } from "../utils/Constants";
9
+ import { Constants } from "../utils/Constants";
13
10
  import { version } from "../packageMetadata";
14
11
  import { Authority } from "../authority/Authority";
15
12
  import { AzureCloudInstance } from "../authority/AuthorityOptions";
@@ -24,6 +21,9 @@ import {
24
21
  createClientAuthError,
25
22
  } from "../error/ClientAuthError";
26
23
 
24
+ // Token renewal offset default in seconds
25
+ const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
26
+
27
27
  /**
28
28
  * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.
29
29
  *
package/src/index.ts CHANGED
@@ -204,7 +204,6 @@ export {
204
204
  GrantType,
205
205
  AADAuthorityConstants,
206
206
  HttpStatus,
207
- DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
208
207
  JsonWebTokenTypes,
209
208
  } from "./utils/Constants";
210
209
  export * as AADServerParamKeys from "./constants/AADServerParamKeys";
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "14.6.0-alpha.0";
3
+ export const version = "14.6.0";
@@ -524,11 +524,11 @@ export class ResponseHandler {
524
524
  // appMetadata
525
525
  let cachedAppMetadata: AppMetadataEntity | null = null;
526
526
  if (serverTokenResponse.foci) {
527
- cachedAppMetadata = AppMetadataEntity.createAppMetadataEntity(
528
- this.clientId,
529
- env,
530
- serverTokenResponse.foci
531
- );
527
+ cachedAppMetadata = {
528
+ clientId: this.clientId,
529
+ environment: env,
530
+ familyId: serverTokenResponse.foci,
531
+ };
532
532
  }
533
533
 
534
534
  return new CacheRecord(
@@ -68,7 +68,6 @@ export const HttpStatus = {
68
68
  SUCCESS_RANGE_END: 299,
69
69
  REDIRECT: 302,
70
70
  CLIENT_ERROR_RANGE_START: 400,
71
- UNAUTHORIZED: 401,
72
71
  CLIENT_ERROR_RANGE_END: 499,
73
72
  SERVER_ERROR_RANGE_START: 500,
74
73
  SERVER_ERROR_RANGE_END: 599,
@@ -371,6 +370,3 @@ export type JsonWebTokenTypes =
371
370
  (typeof JsonWebTokenTypes)[keyof typeof JsonWebTokenTypes];
372
371
 
373
372
  export const ONE_DAY_IN_MS = 86400000;
374
-
375
- // Token renewal offset default in seconds
376
- export const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
@@ -1,73 +0,0 @@
1
- /*! @azure/msal-common v14.6.0-alpha.0 2023-12-15 */
2
- 'use strict';
3
- import { Separators, APP_METADATA } from '../../utils/Constants.mjs';
4
-
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- /**
10
- * APP_METADATA Cache
11
- *
12
- * Key:Value Schema:
13
- *
14
- * Key: appmetadata-<environment>-<client_id>
15
- *
16
- * Value:
17
- * {
18
- * clientId: client ID of the application
19
- * environment: entity that issued the token, represented as a full host
20
- * familyId: Family ID identifier, '1' represents Microsoft Family
21
- * }
22
- */
23
- class AppMetadataEntity {
24
- /**
25
- * Generate AppMetadata Cache Key as per the schema: appmetadata-<environment>-<client_id>
26
- */
27
- generateAppMetadataKey() {
28
- return AppMetadataEntity.generateAppMetadataCacheKey(this.environment, this.clientId);
29
- }
30
- /**
31
- * Generate AppMetadata Cache Key
32
- */
33
- static generateAppMetadataCacheKey(environment, clientId) {
34
- const appMetaDataKeyArray = [
35
- APP_METADATA,
36
- environment,
37
- clientId,
38
- ];
39
- return appMetaDataKeyArray
40
- .join(Separators.CACHE_KEY_SEPARATOR)
41
- .toLowerCase();
42
- }
43
- /**
44
- * Creates AppMetadataEntity
45
- * @param clientId
46
- * @param environment
47
- * @param familyId
48
- */
49
- static createAppMetadataEntity(clientId, environment, familyId) {
50
- const appMetadata = new AppMetadataEntity();
51
- appMetadata.clientId = clientId;
52
- appMetadata.environment = environment;
53
- if (familyId) {
54
- appMetadata.familyId = familyId;
55
- }
56
- return appMetadata;
57
- }
58
- /**
59
- * Validates an entity: checks for all expected params
60
- * @param entity
61
- */
62
- static isAppMetadataEntity(key, entity) {
63
- if (!entity) {
64
- return false;
65
- }
66
- return (key.indexOf(APP_METADATA) === 0 &&
67
- entity.hasOwnProperty("clientId") &&
68
- entity.hasOwnProperty("environment"));
69
- }
70
- }
71
-
72
- export { AppMetadataEntity };
73
- //# sourceMappingURL=AppMetadataEntity.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppMetadataEntity.mjs","sources":["../../../src/cache/entities/AppMetadataEntity.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;AAIH;;;;;;;;;;;;;AAaG;MACU,iBAAiB,CAAA;AAK1B;;AAEG;IACH,sBAAsB,GAAA;AAClB,QAAA,OAAO,iBAAiB,CAAC,2BAA2B,CAChD,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,CAChB,CAAC;KACL;AAED;;AAEG;AACH,IAAA,OAAO,2BAA2B,CAC9B,WAAmB,EACnB,QAAgB,EAAA;AAEhB,QAAA,MAAM,mBAAmB,GAAkB;YACvC,YAAY;YACZ,WAAW;YACX,QAAQ;SACX,CAAC;AACF,QAAA,OAAO,mBAAmB;AACrB,aAAA,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC;AACpC,aAAA,WAAW,EAAE,CAAC;KACtB;AAED;;;;;AAKG;AACH,IAAA,OAAO,uBAAuB,CAC1B,QAAgB,EAChB,WAAmB,EACnB,QAAiB,EAAA;AAEjB,QAAA,MAAM,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAE5C,QAAA,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,QAAA,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,QAAA,IAAI,QAAQ,EAAE;AACV,YAAA,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACnC,SAAA;AAED,QAAA,OAAO,WAAW,CAAC;KACtB;AAED;;;AAGG;AACH,IAAA,OAAO,mBAAmB,CAAC,GAAW,EAAE,MAAc,EAAA;QAClD,IAAI,CAAC,MAAM,EAAE;AACT,YAAA,OAAO,KAAK,CAAC;AAChB,SAAA;QAED,QACI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;AAC/B,YAAA,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC;AACjC,YAAA,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACtC;KACL;AACJ;;;;"}