diff --git a/home/HomeApp.js b/home/HomeApp.js index 9fbd0560c275b4..babc1c903435c3 100644 --- a/home/HomeApp.js +++ b/home/HomeApp.js @@ -16,7 +16,6 @@ import MenuView from './menu/MenuView'; import Store from './redux/Store'; import addListenerWithNativeCallback from './utils/addListenerWithNativeCallback'; -import getViewerUsernameAsync from './utils/getViewerUsernameAsync'; function cacheImages(images) { return images.map(image => Asset.fromModule(image).downloadAsync()); @@ -32,10 +31,6 @@ export default class App extends React.Component { componentDidMount() { this._initializeStateAsync(); - addListenerWithNativeCallback( - 'ExponentKernel.getIsValidHomeManifestToOpen', - this._getIsValidHomeManifestToOpen - ); } _isExpoHost = host => { @@ -63,37 +58,6 @@ export default class App extends React.Component { return !this._isExpoHost(host); }; - _getIsValidHomeManifestToOpen = async event => { - const { manifest, manifestUrl } = event; - let isValid = false; - if (!Constants.isDevice) { - // simulator has no restriction - isValid = true; - } else if (this._isThirdPartyHosted(manifestUrl)) { - // TODO(quin): figure out a long term solution for this - // allow self hosted applications to be loaded into the client - isValid = true; - } else if (manifest) { - if (manifest.developer && manifest.developer.tool) { - isValid = true; - } else if (manifest.slug === 'snack') { - isValid = true; - } else if (manifest.id) { - try { - let manifestAuthorComponents = manifest.id.split('/'); - let manifestAuthor = manifestAuthorComponents[0].substring(1); - - let username = await getViewerUsernameAsync(); - - if (username && manifestAuthor && manifestAuthor === username) { - isValid = true; - } - } catch (_) {} - } - } - return { isValid }; - }; - _initializeStateAsync = async () => { try { Store.dispatch(SettingsActions.loadSettings()); diff --git a/ios/Client/EXHomeAppManager.h b/ios/Client/EXHomeAppManager.h index 55e75171700b6d..4a4a6fc52df032 100644 --- a/ios/Client/EXHomeAppManager.h +++ b/ios/Client/EXHomeAppManager.h @@ -12,6 +12,5 @@ FOUNDATION_EXPORT NSString *kEXHomeManifestResourceName; - (void)addHistoryItemWithUrl:(NSURL *)manifestUrl manifest:(NSDictionary *)manifest; - (void)getHistoryUrlForExperienceId:(NSString *)experienceId completion:(void (^)(NSString *))completion; - (void)showQRReader; -- (void)getIsValidHomeManifestToOpen:(NSDictionary *)manifest manifestUrl:(NSURL *) manifestUrl completion:(void (^)(BOOL isValid))completion; @end diff --git a/ios/Client/EXHomeAppManager.m b/ios/Client/EXHomeAppManager.m index 627e8a58b70436..0479ad53f4c649 100644 --- a/ios/Client/EXHomeAppManager.m +++ b/ios/Client/EXHomeAppManager.m @@ -51,18 +51,6 @@ - (void)getHistoryUrlForExperienceId:(NSString *)experienceId completion:(void ( }]; } -- (void)getIsValidHomeManifestToOpen:(NSDictionary *)manifest manifestUrl:(NSURL *) manifestUrl completion:(void (^)(BOOL))completion -{ - [self _dispatchHomeJSEvent:@"getIsValidHomeManifestToOpen" - body:@{ @"manifest": manifest, @"manifestUrl": manifestUrl.absoluteString } - onSuccess:^(NSDictionary *result) { - BOOL isValid = [result[@"isValid"] boolValue]; - completion(isValid); - } onFailure:^(NSString *errorMessage) { - completion(NO); - }]; -} - - (void)showQRReader { [self _dispatchHomeJSEvent:@"showQRReader" body:@{} onSuccess:nil onFailure:nil]; diff --git a/ios/Client/EXRootViewController.m b/ios/Client/EXRootViewController.m index 5cc30ed51e1a96..295b338652ef88 100644 --- a/ios/Client/EXRootViewController.m +++ b/ios/Client/EXRootViewController.m @@ -160,11 +160,6 @@ - (void)addHistoryItemWithUrl:(NSURL *)manifestUrl manifest:(NSDictionary *)mani [[self _getHomeAppManager] addHistoryItemWithUrl:manifestUrl manifest:manifest]; } -- (void)getIsValidHomeManifestToOpen:(NSDictionary *)manifest manifestUrl:(NSURL *) manifestUrl completion:(void (^)(BOOL isValid))completion -{ - [[self _getHomeAppManager] getIsValidHomeManifestToOpen:manifest manifestUrl:(NSURL *) manifestUrl completion:completion]; -} - - (void)getHistoryUrlForExperienceId:(NSString *)experienceId completion:(void (^)(NSString *))completion { return [[self _getHomeAppManager] getHistoryUrlForExperienceId:experienceId completion:completion]; diff --git a/ios/Exponent/Kernel/Core/EXAppBrowserController.h b/ios/Exponent/Kernel/Core/EXAppBrowserController.h index 550b3105e6e3b5..f97ac2235d4176 100644 --- a/ios/Exponent/Kernel/Core/EXAppBrowserController.h +++ b/ios/Exponent/Kernel/Core/EXAppBrowserController.h @@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)showQRReader; - (void)addHistoryItemWithUrl:(NSURL *)manifestUrl manifest:(NSDictionary *)manifest; - (void)getHistoryUrlForExperienceId:(NSString *)experienceId completion:(void (^)(NSString * _Nullable))completion; -- (void)getIsValidHomeManifestToOpen:(NSDictionary *)manifest manifestUrl:(NSURL *) manifestUrl completion:(void (^)(BOOL isValid))completion; - (BOOL)isNuxFinished; - (void)setIsNuxFinished:(BOOL)isFinished; - (void)appDidFinishLoadingSuccessfully:(EXKernelAppRecord *)appRecord; diff --git a/ios/Exponent/Kernel/Core/EXKernel.h b/ios/Exponent/Kernel/Core/EXKernel.h index 3f8291c867edc1..b109818244458d 100644 --- a/ios/Exponent/Kernel/Core/EXKernel.h +++ b/ios/Exponent/Kernel/Core/EXKernel.h @@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN FOUNDATION_EXPORT NSString *kEXKernelErrorDomain; -FOUNDATION_EXPORT const NSUInteger kEXErrorCodeAppForbidden; typedef NS_ENUM(NSInteger, EXKernelErrorCode) { EXKernelErrorCodeModuleDeallocated, diff --git a/ios/Exponent/Kernel/Core/EXKernel.m b/ios/Exponent/Kernel/Core/EXKernel.m index a4c920b910b3e0..b2b2e616f7af24 100644 --- a/ios/Exponent/Kernel/Core/EXKernel.m +++ b/ios/Exponent/Kernel/Core/EXKernel.m @@ -23,8 +23,6 @@ NSString * const kEXDeviceInstallUUIDKey = @"EXDeviceInstallUUIDKey"; NSString * const kEXKernelClearJSCacheUserDefaultsKey = @"EXKernelClearJSCacheUserDefaultsKey"; -const NSUInteger kEXErrorCodeAppForbidden = 424242; - @interface EXKernel () @end diff --git a/ios/Exponent/Kernel/Views/EXAppViewController.m b/ios/Exponent/Kernel/Views/EXAppViewController.m index 230ea2f90b29a0..1553202cf7f300 100644 --- a/ios/Exponent/Kernel/Views/EXAppViewController.m +++ b/ios/Exponent/Kernel/Views/EXAppViewController.m @@ -219,12 +219,10 @@ - (void)backgroundControllers - (void)appLoader:(EXAppLoader *)appLoader didLoadOptimisticManifest:(NSDictionary *)manifest { - [self _whenManifestIsValidToOpen:manifest manifestUrl:appLoader.manifestUrl performBlock:^{ - if ([EXKernel sharedInstance].browserController) { - [[EXKernel sharedInstance].browserController addHistoryItemWithUrl:appLoader.manifestUrl manifest:manifest]; - } - [self _rebuildBridgeWithLoadingViewManifest:manifest]; - }]; + if ([EXKernel sharedInstance].browserController) { + [[EXKernel sharedInstance].browserController addHistoryItemWithUrl:appLoader.manifestUrl manifest:manifest]; + } + [self _rebuildBridgeWithLoadingViewManifest:manifest]; } - (void)appLoader:(EXAppLoader *)appLoader didLoadBundleWithProgress:(EXLoadingProgress *)progress @@ -236,12 +234,10 @@ - (void)appLoader:(EXAppLoader *)appLoader didLoadBundleWithProgress:(EXLoadingP - (void)appLoader:(EXAppLoader *)appLoader didFinishLoadingManifest:(NSDictionary *)manifest bundle:(NSData *)data { - [self _whenManifestIsValidToOpen:manifest manifestUrl:appLoader.manifestUrl performBlock:^{ - [self _rebuildBridgeWithLoadingViewManifest:manifest]; - if (self->_appRecord.appManager.status == kEXReactAppManagerStatusBridgeLoading) { - [self->_appRecord.appManager appLoaderFinished]; - } - }]; + [self _rebuildBridgeWithLoadingViewManifest:manifest]; + if (self->_appRecord.appManager.status == kEXReactAppManagerStatusBridgeLoading) { + [self->_appRecord.appManager appLoaderFinished]; + } } - (void)appLoader:(EXAppLoader *)appLoader didFailWithError:(NSError *)error @@ -430,9 +426,6 @@ - (void)setIsLoading:(BOOL)isLoading - (BOOL)_willAutoRecoverFromError:(NSError *)error { - if (error.code == kEXErrorCodeAppForbidden) { - return NO; - } if (![_appRecord.appManager enablesDeveloperTools]) { BOOL shouldRecover = [[EXKernel sharedInstance].serviceRegistry.errorRecoveryManager experienceIdShouldReloadOnError:_appRecord.experienceId]; if (shouldRecover) { @@ -456,26 +449,6 @@ - (void)_invalidateRecoveryTimer } } -// this is deprecated in favor of the server side check -// TODO(eric): remove -- (void)_whenManifestIsValidToOpen:(NSDictionary *)manifest manifestUrl:(NSURL *) manifestUrl performBlock:(void (^)(void))block -{ - if (self.appRecord.appManager.requiresValidManifests && [EXKernel sharedInstance].browserController) { - [[EXKernel sharedInstance].browserController getIsValidHomeManifestToOpen:manifest manifestUrl:manifestUrl completion:^(BOOL isValid) { - if (isValid) { - block(); - } else { - [self appLoader:self->_appRecord.appLoader didFailWithError:[NSError errorWithDomain:EXNetworkErrorDomain - code:kEXErrorCodeAppForbidden - userInfo:@{ NSLocalizedDescriptionKey: @"Expo Client can only be used to view your own projects. To view this project, please ensure you are signed in to the same Expo account that created it." }]]; - } - }]; - } else { - // no browser present, everything is valid - block(); - } -} - @end NS_ASSUME_NONNULL_END diff --git a/ios/Exponent/Kernel/Views/EXErrorView.m b/ios/Exponent/Kernel/Views/EXErrorView.m index 474c48f7d21898..4b3b0901e13d76 100644 --- a/ios/Exponent/Kernel/Views/EXErrorView.m +++ b/ios/Exponent/Kernel/Views/EXErrorView.m @@ -91,8 +91,6 @@ - (void)setType:(EXFatalErrorType)type _lblError.text = [NSString stringWithFormat:@"There was a problem loading %@.", appOwnerName]; if (_error.code == kCFURLErrorNotConnectedToInternet) { _lblError.text = [NSString stringWithFormat:@"%@ Make sure you're connected to the internet.", _lblError.text]; - } else if (_error.code == kEXErrorCodeAppForbidden) { - _lblError.text = [NSString stringWithFormat:@"Sorry, you are not allowed to load %@.", appOwnerName]; } else if (_appRecord.appLoader.manifestUrl) { NSString *url = _appRecord.appLoader.manifestUrl.absoluteString; if ([self _urlLooksLikeLAN:url]) {