-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap ASAuthorizationProviderExtensionAuthorizationRequest methods #2347
base: dev
Are you sure you want to change the base?
Conversation
Cloned PR for sedemche/wrap_calling_app_bundle_id AI description (iteration 1)PR ClassificationNew feature PR SummaryThis pull request introduces methods to retrieve and display information about the calling application in the broker operation requests.
|
"### Step-by-Step Plan
Review and Suggestions
Refactored Code#import
NS_ASSUME_NONNULL_BEGIN
@interface MSIDBaseBrokerOperationRequest : NSObject
@property (nonatomic, class, readonly) NSString *operation;
@property (nonatomic, strong) NSUUID *correlationId;
@property (nonatomic, readonly) NSString *callerBundleIdentifier;
@property (nonatomic, readonly) NSString *callerTeamIdentifier API_AVAILABLE(ios(14.0), macos(11.0)) API_UNAVAILABLE(watchos, tvos);
@property (nonatomic, readonly) NSString *localizedCallerDisplayName API_AVAILABLE(ios(14.0), macos(11.0)) API_UNAVAILABLE(watchos, tvos);
@property (nonatomic, readonly) NSString *localizedApplicationInfo API_AVAILABLE(ios(14.0), macos(11.0)) API_UNAVAILABLE(watchos, tvos);
- (nullable NSString *)logInfo;
@end
NS_ASSUME_NONNULL_END Explanation of Changes
|
"### Step-by-Step Plan
Review and Suggestions
Refactored Code#import \"MSIDBrokerOperationRequest.h\"
NS_ASSUME_NONNULL_BEGIN
@interface MSIDBrokerOperationBrowserNativeMessageRequest : MSIDBrokerOperationRequest
@property (nonatomic, copy) NSDictionary *payloadJson; // Consider using copy if the dictionary is mutable
@property (nonatomic, copy) NSString *parentProcessBundleIdentifier; // Use copy for NSString properties
@property (nonatomic, copy) NSString *parentProcessTeamId; // Use copy for NSString properties
@property (nonatomic, copy) NSString *parentProcessLocalizedName; // Use copy for NSString properties
@property (nonatomic, readonly, copy) NSString *method; // Ensure readonly property is also copied
@end
NS_ASSUME_NONNULL_END Explanation
|
"### Step-by-Step Plan
Code Review and SuggestionsLogical and Syntactical Bugs
Refactoring Suggestions
Refactored Code#import \"MSIDBrokerOperationBrowserNativeMessageRequest.h\"
#import \"MSIDJsonSerializableTypes.h\"
#import \"MSIDJsonSerializableFactory.h\"
#import \"NSDictionary+MSIDExtensions.h\"
NSString *const MSID_BROWSER_NATIVE_MESSAGE_REQUEST_PAYLOAD_KEY = @\"payload\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_REQUEST_METHOD_KEY = @\"method\";
@implementation MSIDBrokerOperationBrowserNativeMessageRequest
+ (void)load
{
[MSIDJsonSerializableFactory registerClass:self forClassType:self.operation];
}
- (NSString *)method
{
return self.payloadJson[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_METHOD_KEY];
}
#pragma mark - MSIDBrokerOperationRequest
+ (NSString *)operation
{
return MSID_JSON_TYPE_OPERATION_REQUEST_BROWSER_NATIVE_MESSAGE;
}
- (NSString *)callerBundleIdentifier
{
return self.parentProcessBundleIdentifier ?: NSLocalizedString(@\"N/A\", nil);
}
- (NSString *)callerTeamIdentifier
{
return self.parentProcessTeamId ?: NSLocalizedString(@\"N/A\", nil);
}
- (NSString *)localizedCallerDisplayName
{
return self.parentProcessLocalizedName ?: NSLocalizedString(@\"N/A\", nil);
}
- (NSString *)localizedApplicationInfo
{
NSString *method = self.payloadJson[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_METHOD_KEY];
MSIDBrokerOperationRequest *brokerOperationRequest = [MSIDJsonSerializableFactory createFromJSONDictionary:self.payloadJson
classType:method
assertKindOfClass:MSIDBaseBrokerOperationRequest.class
error:nil];
if (![NSString msidIsStringNilOrBlank:brokerOperationRequest.localizedApplicationInfo])
{
return brokerOperationRequest.localizedApplicationInfo;
}
return NSLocalizedString(@\"N/A\", nil);
}
#pragma mark - MSIDJsonSerializable
- (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__autoreleasing*)error
{
self = [super initWithJSONDictionary:json error:error];
if (self)
{
if (![self validatePayloadInJSON:json error:error]) return nil;
_payloadJson = [NSDictionary msidDictionaryFromJSONString:json[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_PAYLOAD_KEY]];
if (!_payloadJson)
{
[self setError:error withMessage:@\"Failed to serialize payload.\"];
return nil;
}
if (![self validateMethodInPayload:error]) return nil;
_parentProcessBundleIdentifier = [json msidStringObjectForKey:@\"parent_process_bundle_identifier\"];
_parentProcessTeamId = [json msidStringObjectForKey:@\"parent_process_teamId\"];
_parentProcessLocalizedName = [json msidStringObjectForKey:@\"parent_process_localized_name\"];
}
return self;
}
- (BOOL)validatePayloadInJSON:(NSDictionary *)json error:(NSError *__autoreleasing*)error
{
return [json msidAssertType:NSString.class ofKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_PAYLOAD_KEY required:YES error:error];
}
- (BOOL)validateMethodInPayload:(NSError *__autoreleasing*)error
{
if (!_payloadJson[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_METHOD_KEY])
{
[self setError:error withMessage:@\"Payload is invalid: no 'method' found.\"];
return NO;
}
return YES;
}
- (void)setError:(NSError *__autoreleasing*)error withMessage:(NSString *)message
{
if (error)
{
*error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInternal, message, nil, nil, nil, nil, nil, YES);
}
}
- (NSDictionary *)jsonDictionary
{
NSMutableDictionary *json = [[super jsonDictionary] mutableCopy];
if (!json || !self.payloadJson) return nil;
json[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_PAYLOAD_KEY] = [self.payloadJson msidJSONSerializeWithContext:nil];
return json;
}
@end Summary of Changes
|
"I can help you with software development-related questions. However, the provided snippet is a changelog entry, not a class or code snippet. If you have a specific class or code snippet you want reviewed, please provide the actual code, and I can assist you with that. |
"### Plan
Review and SuggestionsLogical Bugs
Syntactical Bugs
Refactoring for Readability
Final Code#import \"MSIDBrowserNativeMessageGetTokenRequest.h\"
#import \"MSIDJsonSerializableFactory.h\"
#import \"MSIDAADAuthority.h\"
#import \"MSIDAccountIdentifier.h\"
#import \"MSIDConstants.h\"
#import \"MSIDPromptType_Internal.h\"
NSString *const MSID_BROWSER_NATIVE_MESSAGE_CORRELATION_KEY = @\"correlationId\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_CLIENT_ID_KEY = @\"clientId\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_AUTHORITY_KEY = @\"authority\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_SCOPE_KEY = @\"scope\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_REDIRECT_URI_KEY = @\"redirectUri\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_PROMPT_KEY = @\"prompt\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_NONCE_KEY = @\"nonce\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_IS_STS_KEY = @\"isSts\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_STATE_KEY = @\"state\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_LOGIN_HINT_KEY = @\"loginHint\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_INSTANCE_AWARE_KEY = @\"instance_aware\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_EXTRA_PARAMETERS_KEY = @\"extraParameters\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_REQUEST_KEY = @\"request\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_PLATFORM_SEQUENCE_KEY = @\"x-client-xtra-sku\";
NSString *const MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY = @\"canShowUI\";
@implementation MSIDBrowserNativeMessageGetTokenRequest
+ (void)load
{
[MSIDJsonSerializableFactory registerClass:self forClassType:self.operation];
}
+ (NSString *)operation
{
return @\"GetToken\";
}
#pragma mark - MSIDBrokerOperationRequest
- (NSString *)localizedApplicationInfo
{
if ([NSString msidIsStringNilOrBlank:self.clientId] && [NSString msidIsStringNilOrBlank:self.redirectUri])
{
return self.localizedCallerDisplayName;
}
__auto_type clientId = self.clientId ?: NSLocalizedString(@\"N/A\", nil);
__auto_type redirectUri = self.redirectUri ?: NSLocalizedString(@\"N/A\", nil);
NSString *clientIdKey = NSLocalizedString(@\"Client ID\", nil);
NSString *redirectUriKey = NSLocalizedString(@\"Redirect URI\", nil);
return [NSString stringWithFormat:@\"%@: %@ %@: %@\", clientIdKey, clientId, redirectUriKey, redirectUri];
}
#pragma mark - MSIDJsonSerializable
- (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__autoreleasing*)error
{
self = [super initWithJSONDictionary:json error:error];
if (!self) return nil;
if (![self validateRequestJson:json error:error]) return nil;
NSDictionary *requestJson = json[MSID_BROWSER_NATIVE_MESSAGE_REQUEST_KEY];
_loginHint = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_LOGIN_HINT_KEY];
NSString *homeAccountId = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_ACCOUNT_ID_KEY];
if (homeAccountId || _loginHint)
{
_accountId = [[MSIDAccountIdentifier alloc] initWithDisplayableId:_loginHint homeAccountId:homeAccountId];
}
_clientId = requestJson[MSID_BROWSER_NATIVE_MESSAGE_CLIENT_ID_KEY];
_authority = [self createAuthorityFromString:[requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_AUTHORITY_KEY] error:error];
if (!_authority) return nil;
_scopes = requestJson[MSID_BROWSER_NATIVE_MESSAGE_SCOPE_KEY];
_redirectUri = requestJson[MSID_BROWSER_NATIVE_MESSAGE_REDIRECT_URI_KEY];
_prompt = MSIDPromptTypeFromString([requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_PROMPT_KEY]);
_nonce = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_NONCE_KEY];
_isSts = [requestJson msidBoolObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_IS_STS_KEY];
_state = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_STATE_KEY];
_instanceAware = [requestJson msidBoolObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_INSTANCE_AWARE_KEY];
_extraParameters = requestJson[MSID_BROWSER_NATIVE_MESSAGE_EXTRA_PARAMETERS_KEY];
_correlationId = [self createCorrelationIdFromString:[requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CORRELATION_KEY]];
_platformSequence = [requestJson msidStringObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_PLATFORM_SEQUENCE_KEY];
_canShowUI = [requestJson msidBoolObjectForKey:MSID_BROWSER_NATIVE_MESSAGE_CAN_SHOW_UI_KEY] ?: YES;
return self;
}
- (BOOL)validateRequestJson:(NSDictionary *)json error:(NSError *__autoreleasing*)error
{
return [json msidAssertType:NSDictionary.class ofKey:MSID_BROWSER_NATIVE_MESSAGE_REQUEST_KEY required:YES error:error];
}
- (MSIDAADAuthority *)createAuthorityFromString:(NSString *)authorityString error:(NSError *__autoreleasing*)error
{
if (!authorityString) return nil;
NSError *localError;
MSIDAADAuthority *authority = [[MSIDAADAuthority alloc] initWithURL:[NSURL URLWithString:authorityString] rawTenant:nil context:nil error:&localError];
if (!authority && localError)
{
MSID_LOG_WITH_CTX_PII(MSIDLogLevelError, nil, @\"Non AAD authorities are not supported in broker - %@\", MSID_PII_LOG_MASKABLE(localError));
if (error) *error = localError;
}
return authority;
}
- (NSUUID *)createCorrelationIdFromString:(NSString *)uuidString
{
return uuidString ? [[NSUUID alloc] initWithUUIDString:uuidString] : [NSUUID UUID];
}
- (NSDictionary *)jsonDictionary
{
@throw MSIDException(MSIDGenericException, @\"Not implemented.\", nil);
}
@end AI-generated content may be incorrect |
Cloned PR for sedemche/wrap_calling_app_bundle_id AI description (iteration 1)PR ClassificationNew feature PR SummaryThis pull request adds support for handling parent process information in
|
"Added
AI-generated content may be incorrect |
"AI code review (iteration 1) Here is the suggested code: @property (nonatomic, copy) NSString *parentProcessBundleIdentifier;
@property (nonatomic, copy) NSString *parentProcessTeamId;
@property (nonatomic, copy) NSString *parentProcessLocalizedName; This comment refers to line 33 to 35 in the new file. |
Cloned PR for sedemche/wrap_calling_app_bundle_id AI description (iteration 1)PR ClassificationNew feature PR SummaryThis pull request adds support for handling parent process information in broker operation requests.
|
"Added
AI-generated content may be incorrect |
"AI code review (iteration 1) Here is the suggested code: @property (nonatomic, copy) NSString *parentProcessBundleIdentifier;
@property (nonatomic, copy) NSString *parentProcessTeamId;
@property (nonatomic, copy) NSString *parentProcessLocalizedName; This comment refers to line 33 to 35 in the new file. |
Proposed changes
Describe what this PR is trying to do.
Type of change
Risk
Additional information