Skip to content

Commit

Permalink
[release] 0.37.0
Browse files Browse the repository at this point in the history
  • Loading branch information
branch-sdkteam committed Jun 15, 2021
1 parent 6ec7b3b commit b42ae70
Show file tree
Hide file tree
Showing 45 changed files with 764 additions and 1,116 deletions.
2 changes: 1 addition & 1 deletion Branch-SDK/BNCConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
NSString * const BNC_API_BASE_URL = @"https://api2.branch.io";
NSString * const BNC_API_VERSION = @"v1";
NSString * const BNC_LINK_URL = @"https://bnc.lt";
NSString * const BNC_SDK_VERSION = @"0.36.0";
NSString * const BNC_SDK_VERSION = @"0.37.0";
31 changes: 31 additions & 0 deletions Branch-SDK/BNCPartnerParameters.h
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
73 changes: 73 additions & 0 deletions Branch-SDK/BNCPartnerParameters.m
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
9 changes: 5 additions & 4 deletions Branch-SDK/BNCPreferenceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
@property (strong, nonatomic) NSString *browserUserAgentString;
@property (strong, atomic) NSString *referringURL;
@property (strong, atomic) NSString *branchAPIURL;
@property (nonatomic, strong, readwrite) NSString *branchBlacklistURL;
@property (assign, atomic) BOOL limitFacebookTracking;
@property (strong, atomic) NSDate *previousAppBuildDate;
@property (assign, nonatomic, readwrite) BOOL disableAdNetworkCallouts;

@property (strong, nonatomic, readwrite) NSURL *faceBookAppLink;

@property (strong, atomic) NSArray<NSString*> *URLBlackList;
@property (assign, atomic) NSInteger URLBlackListVersion;
@property (assign, atomic) BOOL blacklistURLOpen;
@property (nonatomic, strong, readwrite) NSString *patternListURL;
@property (strong, atomic) NSArray<NSString*> *savedURLPatternList;
@property (assign, atomic) NSInteger savedURLPatternListVersion;
@property (assign, atomic) BOOL dropURLOpen;

@property (assign, nonatomic) BOOL sendCloseRequests;

Expand Down Expand Up @@ -85,6 +85,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);

- (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value;
- (NSMutableDictionary *)instrumentationDictionary;
- (NSDictionary *)instrumentationParameters; // a safe copy to use in a POST body
- (void)clearInstrumentationDictionary;

- (void)saveBranchAnalyticsData:(NSDictionary *)analyticsData;
Expand Down
35 changes: 22 additions & 13 deletions Branch-SDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ - (instancetype)init {
_persistPrefsQueue = [[NSOperationQueue alloc] init];
_persistPrefsQueue.maxConcurrentOperationCount = 1;

self.branchBlacklistURL = @"https://cdn.branch.io";
self.patternListURL = @"https://cdn.branch.io";
self.disableAdNetworkCallouts = NO;
}
return self;
Expand Down Expand Up @@ -492,6 +492,15 @@ - (void)setRequestMetadataKey:(NSString *)key value:(NSObject *)value {
}
}

- (NSDictionary *)instrumentationParameters {
@synchronized (self) {
if (_instrumentationDictionary.count == 0) {
return nil; // this avoids the .count check in prepareParamDict
}
return [[NSDictionary alloc] initWithDictionary:_instrumentationDictionary];
}
}

- (NSMutableDictionary *)instrumentationDictionary {
@synchronized (self) {
if (!_instrumentationDictionary) {
Expand Down Expand Up @@ -542,41 +551,41 @@ - (void) setPreviousAppBuildDate:(NSDate*)date {
}
}

- (NSArray<NSString*>*) URLBlackList {
- (NSArray<NSString*>*) savedURLPatternList {
@synchronized(self) {
id a = [self readObjectFromDefaults:@"URLBlackList"];
id a = [self readObjectFromDefaults:@"URLPatternList"];
if ([a isKindOfClass:NSArray.class]) return a;
return nil;
}
}

- (void) setURLBlackList:(NSArray<NSString *> *)URLBlackList {
- (void) setSavedURLPatternList:(NSArray<NSString *> *)URLPatternList {
@synchronized(self) {
[self writeObjectToDefaults:@"URLBlackList" value:URLBlackList];
[self writeObjectToDefaults:@"URLPatternList" value:URLPatternList];
}
}

- (NSInteger) URLBlackListVersion {
- (NSInteger) savedURLPatternListVersion {
@synchronized(self) {
return [self readIntegerFromDefaults:@"URLBlackListVersion"];
return [self readIntegerFromDefaults:@"URLPatternListVersion"];
}
}

- (void) setURLBlackListVersion:(NSInteger)URLBlackListVersion {
- (void) setSavedURLPatternListVersion:(NSInteger)URLPatternListVersion {
@synchronized(self) {
[self writeIntegerToDefaults:@"URLBlackListVersion" value:URLBlackListVersion];
[self writeIntegerToDefaults:@"URLPatternListVersion" value:URLPatternListVersion];
}
}

- (BOOL) blacklistURLOpen {
- (BOOL) dropURLOpen {
@synchronized(self) {
return [self readBoolFromDefaults:@"blacklistURLOpen"];
return [self readBoolFromDefaults:@"dropURLOpen"];
}
}

- (void) setBlacklistURLOpen:(BOOL)value {
- (void) setDropURLOpen:(BOOL)value {
@synchronized(self) {
[self writeBoolToDefaults:@"blacklistURLOpen" value:value];
[self writeBoolToDefaults:@"dropURLOpen" value:value];
}
}

Expand Down
8 changes: 5 additions & 3 deletions Branch-SDK/BNCServerInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@ - (NSMutableDictionary *)prepareParamDict:(NSDictionary *)params
fullParamDict[BRANCH_REQUEST_KEY_STATE] = metadata;
}
// we only send instrumentation info in the POST body request
if (self.preferenceHelper.instrumentationDictionary.count && [reqType isEqualToString:@"POST"]) {
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = self.preferenceHelper.instrumentationDictionary;
if ([reqType isEqualToString:@"POST"]) {
NSDictionary *instrumentationDictionary = self.preferenceHelper.instrumentationParameters;
if (instrumentationDictionary) {
fullParamDict[BRANCH_REQUEST_KEY_INSTRUMENTATION] = instrumentationDictionary;
}
}

return fullParamDict;
}

Expand Down
41 changes: 0 additions & 41 deletions Branch-SDK/BNCURLBlackList.h

This file was deleted.

41 changes: 41 additions & 0 deletions Branch-SDK/BNCURLFilter.h
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
Loading

0 comments on commit b42ae70

Please sign in to comment.