diff --git a/packages/snjs/lib/Hosts.ts b/packages/snjs/lib/Hosts.ts index 9f88db3a3..83763652c 100644 --- a/packages/snjs/lib/Hosts.ts +++ b/packages/snjs/lib/Hosts.ts @@ -7,6 +7,7 @@ export const TRUSTED_FEATURE_HOSTS = [ 'extensions.standardnotes.com', 'extensions.standardnotes.org', 'features.standardnotes.com', + 'localhost', ] export enum ExtensionsServerURL { diff --git a/packages/snjs/lib/Services/Api/ApiService.ts b/packages/snjs/lib/Services/Api/ApiService.ts index 53a184c75..dadc13765 100644 --- a/packages/snjs/lib/Services/Api/ApiService.ts +++ b/packages/snjs/lib/Services/Api/ApiService.ts @@ -648,10 +648,10 @@ export class SNApiService throw Error('Cannot download offline repo without url and offlineKEy') } - const { host } = new URL(featuresUrl) + const { hostname } = new URL(featuresUrl) - if (!TRUSTED_FEATURE_HOSTS.includes(host)) { - return new ClientDisplayableError('This offline features host is not in the trusted allowlist.') + if (!TRUSTED_FEATURE_HOSTS.includes(hostname)) { + return new ClientDisplayableError(`The offline features host ${hostname} is not in the trusted allowlist.`) } const response = await this.request({ diff --git a/packages/snjs/lib/Services/Features/FeaturesService.ts b/packages/snjs/lib/Services/Features/FeaturesService.ts index d581531c1..aa419b9d0 100644 --- a/packages/snjs/lib/Services/Features/FeaturesService.ts +++ b/packages/snjs/lib/Services/Features/FeaturesService.ts @@ -282,7 +282,7 @@ export class SNFeaturesService void this.syncService.sync() return this.downloadOfflineFeatures(offlineRepo) } catch (err) { - return new ClientDisplayableError(API_MESSAGE_FAILED_OFFLINE_ACTIVATION) + return new ClientDisplayableError(`${API_MESSAGE_FAILED_OFFLINE_ACTIVATION}, ${err}`) } } @@ -392,12 +392,12 @@ export class SNFeaturesService } const offlineRepo = this.getOfflineRepo() - if (!offlineRepo) { + if (!offlineRepo || !offlineRepo.content.offlineFeaturesUrl) { return false } const hasFirstPartyOfflineSubscription = offlineRepo.content.offlineFeaturesUrl === PROD_OFFLINE_FEATURES_URL - return hasFirstPartyOfflineSubscription + return hasFirstPartyOfflineSubscription || new URL(offlineRepo.content.offlineFeaturesUrl).hostname === 'localhost' } async updateOnlineRolesAndFetchFeatures(userUuid: UuidString, roles: string[]): Promise {