Skip to content

Commit 52c1926

Browse files
authored
Merge pull request #1501 from AzureAD/release/1.10.0
Release 1.10.0
2 parents 8db3b9f + fc5f511 commit 52c1926

32 files changed

+661
-48
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

+22
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@
245245
2371A6182A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 2371A6162A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.h */; };
246246
2371A6192A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 2371A6172A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.m */; };
247247
2371A61A2A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 2371A6172A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.m */; };
248+
2376D8DD2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2376D8DC2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m */; };
249+
2376D8DE2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2376D8DC2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m */; };
248250
237777CA2853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 237777C82853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.h */; };
249251
237777CB2853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 237777C92853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m */; };
250252
237777CC2853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 237777C92853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m */; };
@@ -1798,6 +1800,11 @@
17981800
B443F0002AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B443EFFF2AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h */; };
17991801
B443F0022AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */; };
18001802
B443F0032AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */; };
1803+
B48FC02F2D726A52007B80DB /* MSIDBrokerFlightProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */; };
1804+
B48FC0312D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */; };
1805+
B48FC0322D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */; };
1806+
B48FC0622D7A90FA007B80DB /* MSIDBrokerFlightProviderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0612D7A90F4007B80DB /* MSIDBrokerFlightProviderTests.m */; };
1807+
B48FC0632D7A90FA007B80DB /* MSIDBrokerFlightProviderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B48FC0612D7A90F4007B80DB /* MSIDBrokerFlightProviderTests.m */; };
18011808
B49323912AD491C600E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B493238F2AD4919400E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h */; };
18021809
B49323922AD491CE00E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */; };
18031810
B49323932AD491CF00E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */; };
@@ -2175,6 +2182,7 @@
21752182
2371A6122A4BAB28008A71F3 /* MSIDBrokerOperationBrowserNativeMessageResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationBrowserNativeMessageResponse.m; sourceTree = "<group>"; };
21762183
2371A6162A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrowserNativeMessageGetCookiesResponse.h; sourceTree = "<group>"; };
21772184
2371A6172A4BAB43008A71F3 /* MSIDBrowserNativeMessageGetCookiesResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrowserNativeMessageGetCookiesResponse.m; sourceTree = "<group>"; };
2185+
2376D8DC2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m; sourceTree = "<group>"; };
21782186
237777C82853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ASAuthorizationController+MSIDExtensions.h"; sourceTree = "<group>"; };
21792187
237777C92853FF9400DDEAFC /* ASAuthorizationController+MSIDExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "ASAuthorizationController+MSIDExtensions.m"; sourceTree = "<group>"; };
21802188
237A6D61203269740084E15F /* MSIDJsonSerializable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDJsonSerializable.h; sourceTree = "<group>"; };
@@ -3246,6 +3254,9 @@
32463254
B443EFFC2AD6307E00782168 /* MSIDBrokerOperationGetPasskeyCredentialResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationGetPasskeyCredentialResponse.m; sourceTree = "<group>"; };
32473255
B443EFFF2AD6327700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationPasskeyCredentialRequest.h; sourceTree = "<group>"; };
32483256
B443F0012AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationPasskeyCredentialRequest.m; sourceTree = "<group>"; };
3257+
B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerFlightProvider.h; sourceTree = "<group>"; };
3258+
B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerFlightProvider.m; sourceTree = "<group>"; };
3259+
B48FC0612D7A90F4007B80DB /* MSIDBrokerFlightProviderTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerFlightProviderTests.m; sourceTree = "<group>"; };
32493260
B493238F2AD4919400E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationPasskeyAssertionRequest.h; sourceTree = "<group>"; };
32503261
B49323902AD491B900E0CBC0 /* MSIDBrokerOperationPasskeyAssertionRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationPasskeyAssertionRequest.m; sourceTree = "<group>"; };
32513262
B49323942AD4DA0200E0CBC0 /* MSIDBrokerOperationGetPasskeyAssertionResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationGetPasskeyAssertionResponse.h; sourceTree = "<group>"; };
@@ -5547,6 +5558,8 @@
55475558
728209CB26FE951900B5F018 /* MSIDJwtAlgorithm.h */,
55485559
237F8F2C2D5166FE0095F164 /* MSIDFlightManager.h */,
55495560
237F8F2D2D5166FE0095F164 /* MSIDFlightManager.m */,
5561+
B48FC02E2D726A48007B80DB /* MSIDBrokerFlightProvider.h */,
5562+
B48FC0302D726A64007B80DB /* MSIDBrokerFlightProvider.m */,
55505563
);
55515564
path = src;
55525565
sourceTree = "<group>";
@@ -5622,6 +5635,7 @@
56225635
23419F59239739AF00EA78C5 /* MSIDBrokerOperationSilentTokenRequestTests.m */,
56235636
23419F5F23974C0D00EA78C5 /* MSIDBrokerOperationTokenRequestTests.m */,
56245637
23419F782399AD7500EA78C5 /* MSIDBrokerOperationTokenResponseTests.m */,
5638+
B48FC0612D7A90F4007B80DB /* MSIDBrokerFlightProviderTests.m */,
56255639
231CE9C91FE8D79A00E95D3E /* MSIDCacheItemJsonSerializerTests.m */,
56265640
B2DD4B2D20A8D7DE0047A66E /* MSIDCacheKeyTests.m */,
56275641
23B37D1D20CA098E0018722F /* MSIDCacheTests.m */,
@@ -5737,6 +5751,7 @@
57375751
2347D6682D5453A400372D20 /* MSIDSwitchBrowserOperationTest.swift */,
57385752
237034432D56AA7F00D6A70B /* MSIDSwitchBrowserResumeOperationTest.swift */,
57395753
2A0278902D6E3216005655B4 /* MSIDAADTokenRequestServerTelemetryTests.m */,
5754+
2376D8DC2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m */,
57405755
);
57415756
path = tests;
57425757
sourceTree = "<group>";
@@ -5989,6 +6004,7 @@
59896004
B2C707FD2192530E00D917B8 /* MSIDDefaultSilentTokenRequest.h in Headers */,
59906005
1EE541402458B30300A86414 /* MSIDDevicePopManager.h in Headers */,
59916006
E656E07D2C2627FB0011FB23 /* MSIDWebUpgradeRegResponse.h in Headers */,
6007+
B48FC02F2D726A52007B80DB /* MSIDBrokerFlightProvider.h in Headers */,
59926008
B286B9B32389DD78007833AD /* MSIDWebAADAuthCodeResponse.h in Headers */,
59936009
886F516E29CCA83000F09471 /* MSIDCIAMAuthorityResolver.h in Headers */,
59946010
B286B9D22389DF19007833AD /* MSIDAadAuthorityCache.h in Headers */,
@@ -6855,6 +6871,7 @@
68556871
A0410E5025E88B5E004D80FD /* MSIDThrottlingMetaDataTest.m in Sources */,
68566872
23CA0C5F220A68D400768729 /* MSIDPkeyAuthHelperTests.m in Sources */,
68576873
B274DEC721FC002300DB7757 /* MSIDInteractiveTokenRequestParametersTests.m in Sources */,
6874+
2376D8DD2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m in Sources */,
68586875
5828740724D49C4100466916 /* MSIDBrokerRedirectUriTest.m in Sources */,
68596876
583BFCB124D907410035B901 /* MSIDRedirectUriVerifierTests.m in Sources */,
68606877
B2936F4F20AA908F0050C585 /* MSIDCredentialCacheItemTests.m in Sources */,
@@ -6914,6 +6931,7 @@
69146931
B210F42E1FDDE6A5005A8F76 /* MSIDJsonObjectTests.m in Sources */,
69156932
B2E97FB32914CC4500AFD558 /* MSIDBrokerNativeAppOperationResponseTests.m in Sources */,
69166933
B29F7805213DFA5600D61FC8 /* MSIDErrorTests.m in Sources */,
6934+
B48FC0622D7A90FA007B80DB /* MSIDBrokerFlightProviderTests.m in Sources */,
69176935
60747FF82354F73000C5308F /* MSIDBrokerOperationGetAccountsResponseTests.m in Sources */,
69186936
B2DD5B97204756580084313F /* MSIDAccountTypeTests.m in Sources */,
69196937
B2936F4D20AA906C0050C585 /* MSIDLegacyTokenCacheItemTests.m in Sources */,
@@ -7266,6 +7284,7 @@
72667284
600D19982095988C0004CD43 /* MSIDChallengeHandler.m in Sources */,
72677285
B26CEB042367B3B9009E6E54 /* MSIDSystemWebViewControllerFactory.m in Sources */,
72687286
609E74BE228CA5CA005E3FED /* MSIDAccountMetadataCacheAccessor.m in Sources */,
7287+
B48FC0312D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */,
72697288
23B018C42356D51200207FEC /* NSDictionary+MSIDQueryItems.m in Sources */,
72707289
2394F2042D4894FF00E44F6E /* MSIDWebUpgradeRegOperation.m in Sources */,
72717290
B2C708AE219A612A00D917B8 /* MSIDDefaultBrokerTokenRequest.m in Sources */,
@@ -7544,6 +7563,7 @@
75447563
B2561225217EA97000999876 /* MSIDB2COauth2FactoryTests.m in Sources */,
75457564
B2BE926221A25A8600F5AB8C /* MSIDInteractiveControllerIntegrationTests.m in Sources */,
75467565
B2BE923521A0F80100F5AB8C /* MSIDLegacyTokenRequestProviderTests.m in Sources */,
7566+
B48FC0632D7A90FA007B80DB /* MSIDBrokerFlightProviderTests.m in Sources */,
75477567
23FB5C21225516FB002BF1EB /* MSIDClaimsRequestTests.m in Sources */,
75487568
E75DD02625D5E474007664A6 /* MSIDThrottlingServiceIntegrationTests.m in Sources */,
75497569
B286BA07238A110A007833AD /* MSIDOIDCSignoutRequestTests.m in Sources */,
@@ -7563,6 +7583,7 @@
75637583
B2BE925021A24A5300F5AB8C /* MSIDSilentControllerIntegrationTests.m in Sources */,
75647584
606B108F20D08C9500B34224 /* MSIDOAuth2EmbeddedWebviewControllerTests.m in Sources */,
75657585
B20E3CB31FC4FA550029C097 /* MSIDVersion.m in Sources */,
7586+
2376D8DE2D88FDE900ADC271 /* MSIDBrowserNativeMessageGetSupportedContractsResponseTests.m in Sources */,
75667587
B2936F7A20ABF8310050C585 /* MSIDLegacyAccessTokenTests.m in Sources */,
75677588
B223B0A422ADEE4500FB8713 /* MSIDMaskedUsernameLogParameterTests.m in Sources */,
75687589
6074800423561F8300C5308F /* MSIDAccountMetadataCacheAccessorTests.m in Sources */,
@@ -8086,6 +8107,7 @@
80868107
96235F96207D7286007EAB36 /* MSIDWebOAuth2AuthCodeResponse.m in Sources */,
80878108
B239A43D209E8170000A3268 /* MSIDAccountCredentialCache.m in Sources */,
80888109
23B018822355481800207FEC /* MSIDSSOExtensionInteractiveTokenRequest.m in Sources */,
8110+
B48FC0322D726A66007B80DB /* MSIDBrokerFlightProvider.m in Sources */,
80898111
239E8F88233D951D00251373 /* MSIDBrokerOperationTokenResponse.m in Sources */,
80908112
B208854A29ADB86200A50B88 /* MSIDExternalSSOContextMock.m in Sources */,
80918113
B2B1D57320425DFD00DD81F0 /* MSIDAccountCacheItem.m in Sources */,

IdentityCore/src/MSIDBrokerConstants.h

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extern NSString * _Nonnull const MSID_BROKER_DEVICE_MODE_KEY;
6969
extern NSString * _Nonnull const MSID_BROKER_SSO_EXTENSION_MODE_KEY;
7070
extern NSString * _Nonnull const MSID_BROKER_WPJ_STATUS_KEY;
7171
extern NSString * _Nonnull const MSID_BROKER_BROKER_VERSION_KEY;
72+
extern NSString * _Nonnull const MSID_SSO_PROVIDER_TYPE_KEY;
7273
extern NSString * _Nonnull const MSID_BROKER_IS_PERFORMING_CBA;
7374
extern NSString * _Nonnull const MSID_ADAL_BROKER_MESSAGE_VERSION;
7475
extern NSString * _Nonnull const MSID_MSAL_BROKER_MESSAGE_VERSION;
@@ -96,6 +97,7 @@ extern NSString * _Nonnull const MSID_SKIP_VALIDATE_RESULT_ACCOUNT_KEY;
9697
extern NSString * _Nonnull const MSID_JIT_TROUBLESHOOTING_HOST;
9798
extern NSString * _Nonnull const MSID_IS_CALLER_MANAGED_KEY;
9899
extern NSString * _Nonnull const MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY;
100+
extern NSString * _Nonnull const MSID_BROKER_CLIENT_FLIGHTS_KEY;
99101
extern NSString * _Nonnull const MSID_BROKER_SDM_WPJ_ATTEMPTED;
100102
extern NSString * _Nonnull const MSID_EXP_RETRY_ON_NETWORK;
101103
extern NSString * _Nonnull const MSID_EXP_ENABLE_CONNECTION_CLOSE;

IdentityCore/src/MSIDBrokerConstants.m

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
NSString *const MSID_BROKER_SSO_EXTENSION_MODE_KEY = @"sso_extension_mode";
6767
NSString *const MSID_BROKER_WPJ_STATUS_KEY = @"wpj_status";
6868
NSString *const MSID_BROKER_BROKER_VERSION_KEY = @"broker_version";
69+
NSString *const MSID_SSO_PROVIDER_TYPE_KEY = @"sso_provider_type";
6970
NSString *const MSID_BROKER_IS_PERFORMING_CBA = @"broker_is_performing_cba";
7071
NSString *const MSID_ADAL_BROKER_MESSAGE_VERSION = @"2";
7172
NSString *const MSID_MSAL_BROKER_MESSAGE_VERSION = @"3";
@@ -77,6 +78,7 @@
7778
NSString *const MSID_BROKER_TYPES_OF_HEADER = @"types_of_header";
7879
NSString *const MSID_BROKER_REQUEST_SENT_TIMESTAMP = @"request_sent_timestamp";
7980
NSString *const MSID_BROKER_PREFERRED_AUTH_CONFIGURATION_KEY = @"preferred_auth_config";
81+
NSString *const MSID_BROKER_CLIENT_FLIGHTS_KEY = @"client_flights";
8082
NSString *const MSID_BROKER_ACCOUNT_HOME_TENANT_ID = @"account_home_tenant_id";
8183
NSString *const MSID_CLIENT_SKU_KEY = @"client_sku";
8284
NSString *const MSID_SKIP_VALIDATE_RESULT_ACCOUNT_KEY = @"skip_validate_result_account";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
//
3+
// Copyright (c) Microsoft Corporation.
4+
// All rights reserved.
5+
//
6+
// This code is licensed under the MIT License.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files(the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions :
14+
//
15+
// The above copyright notice and this permission notice shall be included in
16+
// all copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
// THE SOFTWARE.
25+
26+
#import <Foundation/Foundation.h>
27+
#import "MSIDFlightManager.h"
28+
29+
NS_ASSUME_NONNULL_BEGIN
30+
31+
@interface MSIDBrokerFlightProvider : NSObject <MSIDFlightManagerInterface>
32+
33+
- (instancetype _Nullable)initWithBase64EncodedFlightsPayload:(nullable NSString *)base64EncodedFlightsPayload NS_DESIGNATED_INITIALIZER;
34+
35+
- (instancetype _Nullable)init NS_UNAVAILABLE;
36+
+ (instancetype _Nullable)new NS_UNAVAILABLE;
37+
38+
@end
39+
40+
NS_ASSUME_NONNULL_END
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//
2+
// Copyright (c) Microsoft Corporation.
3+
// All rights reserved.
4+
//
5+
// This code is licensed under the MIT License.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files(the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions :
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
#import "MSIDBrokerFlightProvider.h"
26+
#import "NSJSONSerialization+MSIDExtensions.h"
27+
28+
@interface MSIDBrokerFlightProvider()
29+
30+
@property (nonatomic, nullable, readonly) NSDictionary *clientFlightsPayload;
31+
32+
@end
33+
34+
@implementation MSIDBrokerFlightProvider
35+
36+
- (instancetype _Nullable)initWithBase64EncodedFlightsPayload:(nullable NSString *)base64EncodedFlightsPayload
37+
{
38+
self = [super init];
39+
40+
if (self)
41+
{
42+
if ([NSString msidIsStringNilOrBlank:base64EncodedFlightsPayload])
43+
{
44+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo,nil, @"Broker client flights is nil or empty");
45+
return nil;
46+
}
47+
48+
NSDictionary *clientFlightsDict = nil;
49+
50+
NSData *decodedJsonData = [[base64EncodedFlightsPayload msidBase64UrlDecode] dataUsingEncoding:NSUTF8StringEncoding];
51+
if (decodedJsonData && [decodedJsonData length])
52+
{
53+
clientFlightsDict = [NSJSONSerialization msidNormalizedDictionaryFromJsonData:decodedJsonData error:nil];
54+
55+
if (![clientFlightsDict isKindOfClass:[NSDictionary class]])
56+
{
57+
MSID_LOG_WITH_CTX(MSIDLogLevelWarning,nil, @"Invalid broker client flight format");
58+
return nil;
59+
}
60+
}
61+
else
62+
{
63+
MSID_LOG_WITH_CTX(MSIDLogLevelWarning,nil, @"Failed to decode base64encoded client flights from broker");
64+
return nil;
65+
}
66+
67+
if (clientFlightsDict)
68+
{
69+
_clientFlightsPayload = clientFlightsDict;
70+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, nil, @"Client flights from broker is decoded successfully");
71+
}
72+
}
73+
74+
return self;
75+
}
76+
77+
#pragma mark - MSIDFlightManagerInterface
78+
79+
- (BOOL)boolForKey:(nonnull NSString *)flightKey
80+
{
81+
if (self.clientFlightsPayload)
82+
{
83+
id value = self.clientFlightsPayload[flightKey];
84+
85+
if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]])
86+
{
87+
return [value boolValue];
88+
}
89+
}
90+
91+
return NO;
92+
}
93+
94+
- (nullable NSString *)stringForKey:(nonnull NSString *)flightKey
95+
{
96+
if (self.clientFlightsPayload)
97+
{
98+
id value = self.clientFlightsPayload[flightKey];
99+
100+
if ([value isKindOfClass:[NSString class]])
101+
{
102+
return value;
103+
}
104+
}
105+
106+
return nil;
107+
}
108+
109+
110+
@end

0 commit comments

Comments
 (0)