-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ec7b3b
commit b42ae70
Showing
45 changed files
with
764 additions
and
1,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// BNCPartnerParameters.h | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 12/9/20. | ||
// Copyright © 2020 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
Parameters that clients wish to share with partners | ||
*/ | ||
@interface BNCPartnerParameters : NSObject | ||
|
||
+ (instancetype)shared; | ||
|
||
// FB partner parameters, see FB documentation for details | ||
// Values that do not look like a valid SHA-256 hash are ignored | ||
- (void)addFaceBookParameterWithName:(NSString *)name value:(NSString *)value; | ||
|
||
- (void)clearAllParameters; | ||
|
||
// reference to the internal json dictionary | ||
- (NSDictionary *)parameterJson; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// BNCPartnerParameters.m | ||
// Branch | ||
// | ||
// Created by Ernest Cho on 12/9/20. | ||
// Copyright © 2020 Branch, Inc. All rights reserved. | ||
// | ||
|
||
#import "BNCPartnerParameters.h" | ||
|
||
@interface BNCPartnerParameters() | ||
@property (nonatomic, strong, readwrite) NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, NSString *> *> *parameters; | ||
@end | ||
|
||
@implementation BNCPartnerParameters | ||
|
||
+ (instancetype)shared { | ||
static BNCPartnerParameters *partnerParameters; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
partnerParameters = [BNCPartnerParameters new]; | ||
}); | ||
return partnerParameters; | ||
} | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
if (self) { | ||
self.parameters = [NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, NSString *> *> new]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)clearAllParameters { | ||
self.parameters = [NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, NSString *> *> new]; | ||
} | ||
|
||
- (NSMutableDictionary<NSString *, NSString *> *)parametersForPartner:(NSString *)partnerName { | ||
NSMutableDictionary<NSString *, NSString *> *parametersForPartner = [self.parameters objectForKey:partnerName]; | ||
if (!parametersForPartner) { | ||
parametersForPartner = [NSMutableDictionary<NSString *, NSString *> new]; | ||
[self.parameters setObject:parametersForPartner forKey:partnerName]; | ||
} | ||
return parametersForPartner; | ||
} | ||
|
||
- (void)addParameterWithName:(NSString *)name value:(NSString *)value partnerName:(NSString *)partnerName { | ||
NSMutableDictionary<NSString *, NSString *> *parametersForPartner = [self parametersForPartner:partnerName]; | ||
[parametersForPartner setObject:value forKey:name]; | ||
} | ||
|
||
- (void)addFaceBookParameterWithName:(NSString *)name value:(NSString *)value { | ||
if ([self sha256HashSanityCheckValue:value]) { | ||
[self addParameterWithName:name value:value partnerName:@"fb"]; | ||
} else { | ||
// TODO: log a warning that the parameter looks invalid and will be ignored. Do not log the value as it may be PII that was inadvertently passed in. | ||
} | ||
} | ||
|
||
- (BOOL)sha256HashSanityCheckValue:(NSString *)value { | ||
return ([value length] == 64 && [self isStringHex:value]); | ||
} | ||
|
||
- (BOOL)isStringHex:(NSString *)string { | ||
NSCharacterSet *chars = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"] invertedSet]; | ||
return (NSNotFound == [[string uppercaseString] rangeOfCharacterFromSet:chars].location); | ||
} | ||
|
||
- (NSDictionary *)parameterJson { | ||
return self.parameters; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
@file BNCURLFilter.h | ||
@package Branch-SDK | ||
@brief Manages a list of sensitive URLs such as login data that should not be handled by Branch. | ||
@author Edward Smith | ||
@date February 14, 2018 | ||
@copyright Copyright © 2018 Branch. All rights reserved. | ||
*/ | ||
|
||
#if __has_feature(modules) | ||
@import Foundation; | ||
#else | ||
#import <Foundation/Foundation.h> | ||
#endif | ||
|
||
@interface BNCURLFilter : NSObject | ||
|
||
/** | ||
@brief Checks if a given URL should be ignored. | ||
@param url The URL to be checked. | ||
@return Returns true if the provided URL should be ignored. | ||
*/ | ||
- (BOOL) shouldIgnoreURL:(NSURL*_Nullable)url; | ||
|
||
/** | ||
@brief Returns the pattern that matches a URL, if any. | ||
@param url The URL to be checked. | ||
@return Returns the pattern matching the URL or `nil` if no patterns match. | ||
*/ | ||
- (NSString*_Nullable) patternMatchingURL:(NSURL*_Nullable)url; | ||
|
||
/// Refreshes the list of ignored URLs from the server. | ||
- (void) updatePatternListWithCompletion:(void (^_Nullable) (NSError*_Nullable error, NSArray*_Nullable list))completion; | ||
|
||
/// Is YES if the listed has already been updated from the server. | ||
@property (assign, readonly) BOOL hasUpdatedPatternList; | ||
@property (strong) NSArray<NSString*>*_Nullable patternList; | ||
@end |
Oops, something went wrong.