Compare commits

...
Author SHA1 Message Date
StandardNotes CI e61e1ff86d chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
 - @standardnotes/[email protected].2
2023-08-06 18:40:42 +00:00
Aman Harwara 5473829c7e chore: fix Safari translucency issues [skip e2e] 2023-08-06 23:52:38 +05:30
Mo d2f8a36f19 refactor: merge themes into components (#2388) 2023-08-06 08:52:19 -05:00
StandardNotes CI 1d60af0243 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].2
 - @standardnotes/[email protected].1
2023-08-06 13:02:10 +00:00
Mo 8f3ed30c44 chore: fix infinite loop when installing desktop component 2023-08-06 07:20:24 -05:00
StandardNotes CI 3ae2b78116 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].1
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
2023-08-06 12:17:43 +00:00
Aman Harwara 4b24b58f21 feat: Improved link editing and creation in Super notes (#2382) [skip e2e] 2023-08-06 02:43:35 +05:30
Mo 07c23d24f0 chore: fix test (skip e2e) 2023-08-05 15:58:52 -05:00
Mo eb4a446274 chore: fix test 2023-08-05 14:24:57 -05:00
Mo d8d4052a52 refactor(web): dependency management (#2386) 2023-08-05 12:48:39 -05:00
StandardNotes CI b07da5b663 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].0
 - @standardnotes/[email protected].0
2023-08-05 15:25:25 +00:00
Aman Harwara ec309d6fb5 feat: Added translucency effect to menus, dialogs and alerts. Can be turned off from Preferences > Appeareance (#2387) [skip e2e] 2023-08-05 20:40:37 +05:30
Aman Harwara 83b83cd96d chore: don't show convert as-is button when changing to super if text is not json 2023-08-05 01:43:55 +05:30
359 changed files with 4986 additions and 4102 deletions
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.26.44](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/api
## [1.26.43](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/api
## [1.26.42](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/api
## [1.26.41](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/api
## [1.26.40](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/api
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api",
"version": "1.26.40",
"version": "1.26.44",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.144](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.143](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.142](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.141](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.140](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/clipper
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@standardnotes/clipper",
"description": "Web clipper browser extension for Standard Notes",
"version": "1.1.140",
"version": "1.1.144",
"private": true,
"scripts": {
"build-mv2": "yarn clean && webpack --config ./webpack.config.prod.js",
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.108.75](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.74](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.73](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.72](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.71](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/desktop
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@standardnotes/desktop",
"main": "./app/dist/index.js",
"version": "3.108.71",
"version": "3.108.75",
"license": "CC BY-NC-SA 4.0",
"author": "Standard Notes.",
"private": true,
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.21.66](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/encryption
## [1.21.65](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/encryption
## [1.21.64](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/encryption
## [1.21.63](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/encryption
## [1.21.62](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/encryption
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/encryption",
"version": "1.21.62",
"version": "1.21.66",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.28.76](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/filepicker
## [1.28.75](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/filepicker
## [1.28.74](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/filepicker
## [1.28.73](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/filepicker
## [1.28.72](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/filepicker
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/filepicker",
"version": "1.28.72",
"version": "1.28.76",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.22](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/files
## [1.16.21](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/files
## [1.16.20](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/files
## [1.16.19](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/files
## [1.16.18](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/files
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files",
"version": "1.16.18",
"version": "1.16.22",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.56.55](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.54](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.53](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.52](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.51](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/mobile
+2 -2
View File
@@ -723,7 +723,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
boost: a7c83b31436843459a1961bfd74b96033dc77234
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb
@@ -743,7 +743,7 @@ SPEC CHECKSUMS:
MMKV: 9c4663aa7ca255d478ff10f2f5cb7d17c1651ccd
MMKVCore: 89f5c8a66bba2dcd551779dea4d412eeec8ff5bb
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18
RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3
React: 13109005b5353095c052f26af37413340ccf7a5d
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/mobile",
"version": "3.56.51",
"version": "3.56.55",
"author": "Standard Notes.",
"private": true,
"license": "CC BY-NC-SA 4.0",
+18
View File
@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.47.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/models
## [1.47.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/models
## [1.47.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/models
# [1.47.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
### Features
* Added translucency effect to menus, dialogs and alerts. Can be turned off from Preferences > Appeareance ([#2387](https://github.com/standardnotes/app/issues/2387)) [skip e2e] ([ec309d6](https://github.com/standardnotes/app/commit/ec309d6fb54c6cbb28414d1fe9d6119db5943d9c))
## [1.46.21](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/models
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/models",
"version": "1.46.21",
"version": "1.47.3",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -28,6 +28,7 @@ export enum PayloadEmitSource {
RemoteRetrieved,
RemoteSaved,
DesktopComponentSync,
}
/**
@@ -12,10 +12,10 @@ import {
isThemeFeatureDescription,
} from '@standardnotes/features'
import { ComponentInterface } from '../../Syncable/Component/ComponentInterface'
import { isTheme } from '../../Syncable/Theme'
import { isItemBasedFeature, isNativeFeature } from './TypeGuards'
import { UIFeatureInterface } from './UIFeatureInterface'
import { Uuid } from '@standardnotes/domain-core'
import { ThemePackageInfo, isTheme } from '../../Syncable/Component'
export class UIFeature<F extends UIFeatureDescriptionTypes> implements UIFeatureInterface<F> {
constructor(public readonly item: ComponentInterface | F) {}
@@ -40,6 +40,14 @@ export class UIFeature<F extends UIFeatureDescriptionTypes> implements UIFeature
throw new Error('Cannot cast item to component')
}
get asTheme(): ComponentInterface<ThemePackageInfo> {
if (isItemBasedFeature(this.item)) {
return this.item
}
throw new Error('Cannot cast item to component')
}
get asFeatureDescription(): F {
if (isNativeFeature(this.item)) {
return this.item
@@ -145,7 +153,7 @@ export class UIFeature<F extends UIFeatureDescriptionTypes> implements UIFeature
get layerable(): boolean {
if (isItemBasedFeature(this.item) && isTheme(this.item)) {
return this.item.layerable
return this.item.layerableTheme
} else if (isThemeFeatureDescription(this.asFeatureDescription)) {
return this.asFeatureDescription.layerable ?? false
}
@@ -155,7 +163,7 @@ export class UIFeature<F extends UIFeatureDescriptionTypes> implements UIFeature
get dockIcon(): ThemeDockIcon | undefined {
if (isItemBasedFeature(this.item) && isTheme(this.item)) {
return this.item.package_info.dock_icon
return this.asTheme.package_info.dock_icon
} else if (isThemeFeatureDescription(this.asFeatureDescription)) {
return this.asFeatureDescription.dock_icon
}
@@ -2,14 +2,14 @@ import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource'
import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload'
import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { SNComponent } from './Component'
import { ComponentItem } from './Component'
import { ComponentContent } from './ComponentContent'
import { PayloadTimestampDefaults } from '../../Abstract/Payload'
import { NoteType } from '@standardnotes/features'
describe('component model', () => {
it('valid hosted url should ignore url', () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload(
{
uuid: String(Math.random()),
@@ -29,7 +29,7 @@ describe('component model', () => {
})
it('invalid hosted url should fallback to url', () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload(
{
uuid: String(Math.random()),
@@ -49,7 +49,7 @@ describe('component model', () => {
})
it('should return noteType as specified in package_info', () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload(
{
uuid: String(Math.random()),
@@ -69,7 +69,7 @@ describe('component model', () => {
})
it('should return unknown as noteType if no note type defined in package_info', () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload(
{
uuid: String(Math.random()),
@@ -17,34 +17,16 @@ import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/Dec
import { HistoryEntryInterface } from '../../Runtime/History'
import { ItemContent } from '../../Abstract/Content/ItemContent'
import { Predicate } from '../../Runtime/Predicate/Predicate'
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { DecryptedItemInterface } from './../../Abstract/Item/Interfaces/DecryptedItem'
import { ComponentPackageInfo } from './PackageInfo'
import { isDecryptedItem } from '../../Abstract/Item'
import { ComponentPackageInfo, ThemePackageInfo } from './PackageInfo'
import { ContentType } from '@standardnotes/domain-core'
export function isComponent(x: ItemInterface): x is ComponentInterface {
if (!isDecryptedItem(x as DecryptedItemInterface)) {
return false
}
return x.content_type === ContentType.TYPES.Component
}
export function isComponentOrTheme(x: ItemInterface): x is ComponentInterface {
if (!isDecryptedItem(x as DecryptedItemInterface)) {
return false
}
return x.content_type === ContentType.TYPES.Component || x.content_type === ContentType.TYPES.Theme
}
/**
* Components are mostly iframe based extensions that communicate with the SN parent
* via the postMessage API. However, a theme can also be a component, which is activated
* only by its url.
*/
export class SNComponent extends DecryptedItem<ComponentContent> implements ComponentInterface {
export class ComponentItem extends DecryptedItem<ComponentContent> implements ComponentInterface {
public readonly legacyComponentData: Record<string, unknown>
/** Items that have requested a component to be disabled in its context */
public readonly disassociatedItemIds: string[]
@@ -61,7 +43,6 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
public readonly valid_until: Date
public readonly legacyActive: boolean
public readonly legacy_url?: string
public readonly isMobileDefault: boolean
constructor(payload: DecryptedPayloadInterface<ComponentContent>) {
super(payload)
@@ -78,13 +59,18 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
this.valid_until = new Date(payload.content.valid_until || 0)
this.offlineOnly = payload.content.offlineOnly ?? false
this.name = payload.content.name
this.area = payload.content.area
if (this.content_type === ContentType.TYPES.Theme) {
this.area = ComponentArea.Themes
} else {
this.area = payload.content.area
}
this.package_info = payload.content.package_info || {}
this.permissions = payload.content.permissions || []
this.autoupdateDisabled = payload.content.autoupdateDisabled ?? false
this.disassociatedItemIds = payload.content.disassociatedItemIds || []
this.associatedItemIds = payload.content.associatedItemIds || []
this.isMobileDefault = payload.content.isMobileDefault ?? false
/**
* @legacy
@@ -116,15 +102,11 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
return FindNativeFeature(this.identifier)?.name || this.name
}
public override singletonPredicate(): Predicate<SNComponent> {
const uniqueIdentifierPredicate = new Predicate<SNComponent>('identifier', '=', this.identifier)
public override singletonPredicate(): Predicate<ComponentItem> {
const uniqueIdentifierPredicate = new Predicate<ComponentItem>('identifier', '=', this.identifier)
return uniqueIdentifierPredicate
}
public isEditor(): boolean {
return this.area === ComponentArea.Editor
}
public isTheme(): boolean {
return this.content_type === ContentType.TYPES.Theme || this.area === ComponentArea.Themes
}
@@ -134,10 +116,6 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
return this.getAppDomainValue(AppDataField.DefaultEditor) === true
}
public getLastSize(): unknown {
return this.getAppDomainValue(AppDataField.LastSize)
}
public hasValidHostedUrl(): boolean {
return (this.hosted_url || this.legacy_url) != undefined
}
@@ -149,19 +127,6 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
return [...componentKeys, ...superKeys] as (keyof ItemContent)[]
}
/**
* An associative component depends on being explicitly activated for a
* given item, compared to a dissaciative component, which is enabled by
* default in areas unrelated to a certain item.
*/
public static associativeAreas(): ComponentArea[] {
return [ComponentArea.Editor]
}
public isAssociative(): boolean {
return SNComponent.associativeAreas().includes(this.area)
}
public isExplicitlyEnabledForItem(uuid: string): boolean {
return this.associatedItemIds.indexOf(uuid) !== -1
}
@@ -199,4 +164,13 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
public get deprecationMessage(): string | undefined {
return this.package_info.deprecation_message
}
get layerableTheme(): boolean {
if (!this.isTheme()) {
return false
}
const themePackageInfo = this.package_info as ThemePackageInfo
return themePackageInfo?.layerable ?? false
}
}
@@ -21,7 +21,6 @@ export type ComponentContentSpecialized = {
valid_until: Date | number
legacy_url?: string
isMobileDefault?: boolean
isDeprecated?: boolean
/** @deprecated */
@@ -1,9 +1,10 @@
import { ComponentArea, ComponentPermission, NoteType, ThirdPartyFeatureDescription } from '@standardnotes/features'
import { ComponentPackageInfo } from './PackageInfo'
import { ComponentPackageInfo, ThemePackageInfo } from './PackageInfo'
import { DecryptedItemInterface } from '../../Abstract/Item'
import { ComponentContent } from './ComponentContent'
export interface ComponentInterface extends DecryptedItemInterface<ComponentContent> {
export interface ComponentInterface<P extends ComponentPackageInfo | ThemePackageInfo = ComponentPackageInfo>
extends DecryptedItemInterface<ComponentContent> {
/** Items that have requested a component to be disabled in its context */
disassociatedItemIds: string[]
@@ -16,16 +17,18 @@ export interface ComponentInterface extends DecryptedItemInterface<ComponentCont
offlineOnly: boolean
name: string
autoupdateDisabled: boolean
package_info: ComponentPackageInfo
package_info: P
area: ComponentArea
permissions: ComponentPermission[]
valid_until: Date
isMobileDefault: boolean
isDeprecated: boolean
isExplicitlyEnabledForItem(uuid: string): boolean
hasValidHostedUrl(): boolean
isTheme(): boolean
get layerableTheme(): boolean
isExplicitlyDisabledForItem(uuid: string): boolean
legacyIsDefaultEditor(): boolean
@@ -1,14 +1,9 @@
import { addIfUnique, removeFromArray } from '@standardnotes/utils'
import { ComponentFeatureDescription, ComponentPermission } from '@standardnotes/features'
import { AppDataField } from '../../Abstract/Item/Types/AppDataField'
import { ComponentContent } from './ComponentContent'
import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemMutator'
export class ComponentMutator extends DecryptedItemMutator<ComponentContent> {
set isMobileDefault(isMobileDefault: boolean) {
this.mutableContent.isMobileDefault = isMobileDefault
}
set package_info(package_info: ComponentFeatureDescription) {
this.mutableContent.package_info = package_info
}
@@ -56,8 +51,4 @@ export class ComponentMutator extends DecryptedItemMutator<ComponentContent> {
public removeDisassociatedItemId(uuid: string): void {
removeFromArray(this.mutableContent.disassociatedItemIds || [], uuid)
}
public setLastSize(size: string): void {
this.setAppDataItem(AppDataField.LastSize, size)
}
}
@@ -0,0 +1,29 @@
import { ComponentInterface } from './ComponentInterface'
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { DecryptedItemInterface } from '../../Abstract/Item/Interfaces/DecryptedItem'
import { isDecryptedItem } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/domain-core'
export function isComponent(x: ItemInterface): x is ComponentInterface {
if (!isDecryptedItem(x as DecryptedItemInterface)) {
return false
}
return x.content_type === ContentType.TYPES.Component
}
export function isTheme(x: ItemInterface): x is ComponentInterface {
if (!isDecryptedItem(x as DecryptedItemInterface)) {
return false
}
return x.content_type === ContentType.TYPES.Theme
}
export function isComponentOrTheme(x: ItemInterface): x is ComponentInterface {
if (!isDecryptedItem(x as DecryptedItemInterface)) {
return false
}
return x.content_type === ContentType.TYPES.Component || x.content_type === ContentType.TYPES.Theme
}
@@ -2,5 +2,5 @@ export * from './Component'
export * from './ComponentMutator'
export * from './ComponentContent'
export * from './ComponentInterface'
export * from '../../Runtime/Feature/UIFeature'
export * from './PackageInfo'
export * from './TypeGuards'
@@ -14,7 +14,7 @@ interface EditorContent extends ItemContent {
/**
* @deprecated
* Editor objects are depracated in favor of SNComponent objects
* Editor objects are depracated in favor of ComponentItem objects
*/
export class SNEditor extends DecryptedItem<EditorContent> {
public readonly notes: SNNote[] = []
@@ -1,18 +0,0 @@
import { ComponentArea } from '@standardnotes/features'
import { SNComponent } from '../Component/Component'
import { ItemInterface } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/domain-core'
import { useBoolean } from '@standardnotes/utils'
import { ThemePackageInfo } from '../Component/PackageInfo'
import { ThemeInterface } from './ThemeInterface'
export const isTheme = (x: ItemInterface): x is ThemeInterface => x.content_type === ContentType.TYPES.Theme
export class SNTheme extends SNComponent implements ThemeInterface {
public override area: ComponentArea = ComponentArea.Themes
public declare readonly package_info: ThemePackageInfo
get layerable(): boolean {
return useBoolean(this.package_info && this.package_info.layerable, false)
}
}
@@ -1,7 +0,0 @@
import { ComponentInterface } from '../Component'
import { ThemePackageInfo } from '../Component/PackageInfo'
export interface ThemeInterface extends ComponentInterface {
get layerable(): boolean
readonly package_info: ThemePackageInfo
}
@@ -1,4 +0,0 @@
import { ComponentContent } from '../Component/ComponentContent'
import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemMutator'
export class ThemeMutator extends DecryptedItemMutator<ComponentContent> {}
@@ -1,3 +0,0 @@
export * from './Theme'
export * from './ThemeMutator'
export * from './ThemeInterface'
@@ -28,6 +28,7 @@ export const PrefDefaults = {
[PrefKey.NotesHideTags]: false,
[PrefKey.NotesHideEditorIcon]: false,
[PrefKey.UseSystemColorScheme]: false,
[PrefKey.UseTranslucentUI]: true,
[PrefKey.AutoLightThemeIdentifier]: 'Default',
[PrefKey.AutoDarkThemeIdentifier]: NativeFeatureIdentifier.TYPES.DarkTheme,
[PrefKey.NoteAddToParentFolders]: true,
@@ -29,6 +29,7 @@ export enum PrefKey {
NotesHideTags = 'hideTags',
NotesHideEditorIcon = 'hideEditorIcon',
UseSystemColorScheme = 'useSystemColorScheme',
UseTranslucentUI = 'useTranslucentUI',
AutoLightThemeIdentifier = 'autoLightThemeIdentifier',
AutoDarkThemeIdentifier = 'autoDarkThemeIdentifier',
NoteAddToParentFolders = 'noteAddToParentFolders',
@@ -66,6 +67,7 @@ export type PrefValue = {
[PrefKey.NotesHideTags]: boolean
[PrefKey.NotesHideEditorIcon]: boolean
[PrefKey.UseSystemColorScheme]: boolean
[PrefKey.UseTranslucentUI]: boolean
[PrefKey.AutoLightThemeIdentifier]: string
[PrefKey.AutoDarkThemeIdentifier]: string
[PrefKey.NoteAddToParentFolders]: boolean
@@ -3,17 +3,15 @@ import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/Dec
import { FileItem } from '../../Syncable/File/File'
import { SNFeatureRepo } from '../../Syncable/FeatureRepo/FeatureRepo'
import { SNActionsExtension } from '../../Syncable/ActionsExtension/ActionsExtension'
import { SNComponent } from '../../Syncable/Component/Component'
import { ComponentItem } from '../../Syncable/Component/Component'
import { SNEditor } from '../../Syncable/Editor/Editor'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { SNNote } from '../../Syncable/Note/Note'
import { SmartView } from '../../Syncable/SmartView/SmartView'
import { SNTag } from '../../Syncable/Tag/Tag'
import { SNTheme } from '../../Syncable/Theme/Theme'
import { SNUserPrefs } from '../../Syncable/UserPrefs/UserPrefs'
import { FileMutator } from '../../Syncable/File/FileMutator'
import { MutationType } from '../../Abstract/Item/Types/MutationType'
import { ThemeMutator } from '../../Syncable/Theme/ThemeMutator'
import { UserPrefsMutator } from '../../Syncable/UserPrefs/UserPrefsMutator'
import { ActionsExtensionMutator } from '../../Syncable/ActionsExtension/ActionsExtensionMutator'
import { ComponentMutator } from '../../Syncable/Component/ComponentMutator'
@@ -58,7 +56,7 @@ const ContentTypeClassMapping: Partial<Record<string, MappingEntry>> = {
itemClass: SNActionsExtension,
mutatorClass: ActionsExtensionMutator,
},
[ContentType.TYPES.Component]: { itemClass: SNComponent, mutatorClass: ComponentMutator },
[ContentType.TYPES.Component]: { itemClass: ComponentItem, mutatorClass: ComponentMutator },
[ContentType.TYPES.KeySystemRootKey]: { itemClass: KeySystemRootKey, mutatorClass: KeySystemRootKeyMutator },
[ContentType.TYPES.TrustedContact]: { itemClass: TrustedContact, mutatorClass: TrustedContactMutator },
[ContentType.TYPES.VaultListing]: { itemClass: VaultListing, mutatorClass: VaultListingMutator },
@@ -68,7 +66,7 @@ const ContentTypeClassMapping: Partial<Record<string, MappingEntry>> = {
[ContentType.TYPES.Note]: { itemClass: SNNote, mutatorClass: NoteMutator },
[ContentType.TYPES.SmartView]: { itemClass: SmartView, mutatorClass: SmartViewMutator },
[ContentType.TYPES.Tag]: { itemClass: SNTag, mutatorClass: TagMutator },
[ContentType.TYPES.Theme]: { itemClass: SNTheme, mutatorClass: ThemeMutator },
[ContentType.TYPES.Theme]: { itemClass: ComponentItem, mutatorClass: ComponentMutator },
[ContentType.TYPES.UserPrefs]: { itemClass: SNUserPrefs, mutatorClass: UserPrefsMutator },
} as unknown as Partial<Record<string, MappingEntry>>
-1
View File
@@ -93,7 +93,6 @@ export * from './Syncable/ItemsKey/ItemsKeyMutatorInterface'
export * from './Syncable/Note'
export * from './Syncable/SmartView'
export * from './Syncable/Tag'
export * from './Syncable/Theme'
export * from './Syncable/UserPrefs'
export * from './Syncable/TrustedContact/TrustedContact'
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.427](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.426](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.425](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.424](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.423](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/releases
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/releases",
"version": "1.4.423",
"version": "1.4.427",
"license": "CC BY-NC-SA 4.0",
"main": "dist/releases.json",
"types": "dist/index.d.ts",
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.63.27](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/services
## [1.63.26](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/services
## [1.63.25](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/services
## [1.63.24](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/services
## [1.63.23](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/services
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/services",
"version": "1.63.23",
"version": "1.63.27",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -10,6 +10,8 @@ export interface LegacyApiServiceInterface
extends AbstractService<ApiServiceEvent, ApiServiceEventData>,
FilesApiInterface {
isThirdPartyHostUsed(): boolean
setHost(host: string): Promise<void>
getHost(): string
downloadOfflineFeaturesFromRepo(
repo: SNFeatureRepo,
@@ -24,4 +26,6 @@ export interface LegacyApiServiceInterface
limit: number,
sharedVaultUuids?: string[],
): HttpRequest
getNewSubscriptionToken(): Promise<string | undefined>
}
@@ -1,24 +1,27 @@
import { VaultUserServiceInterface, VaultInviteServiceInterface } from '@standardnotes/services'
import {
VaultUserServiceInterface,
VaultInviteServiceInterface,
StorageServiceInterface,
SyncServiceInterface,
FullyResolvedApplicationOptions,
ProtectionsClientInterface,
ChangeAndSaveItem,
GetHost,
SetHost,
LegacyApiServiceInterface,
StatusServiceInterface,
MfaServiceInterface,
} from '@standardnotes/services'
import { VaultLockServiceInterface } from './../VaultLock/VaultLockServiceInterface'
import { HistoryServiceInterface } from './../History/HistoryServiceInterface'
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
import { PreferenceServiceInterface } from './../Preferences/PreferenceServiceInterface'
import { AsymmetricMessageServiceInterface } from './../AsymmetricMessage/AsymmetricMessageServiceInterface'
import { SyncOptions } from './../Sync/SyncOptions'
import { ImportDataReturnType } from './../Mutator/ImportDataUseCase'
import { ChallengeServiceInterface } from './../Challenge/ChallengeServiceInterface'
import { VaultServiceInterface } from '../Vault/VaultServiceInterface'
import { ApplicationIdentifier } from '@standardnotes/common'
import {
BackupFile,
DecryptedItemInterface,
DecryptedItemMutator,
ItemStream,
PayloadEmitSource,
Platform,
PrefKey,
PrefValue,
} from '@standardnotes/models'
import { BackupFile, Environment, Platform, PrefKey, PrefValue } from '@standardnotes/models'
import { BackupServiceInterface, FilesClientInterface } from '@standardnotes/files'
import { AlertService } from '../Alert/AlertService'
@@ -37,7 +40,6 @@ import { DeinitSource } from './DeinitSource'
import { UserServiceInterface } from '../User/UserServiceInterface'
import { SessionsClientInterface } from '../Session/SessionsClientInterface'
import { HomeServerServiceInterface } from '../HomeServer/HomeServerServiceInterface'
import { User } from '@standardnotes/responses'
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
export interface ApplicationInterface {
@@ -53,49 +55,24 @@ export interface ApplicationInterface {
createDecryptedBackupFile(): Promise<BackupFile | undefined>
hasPasscode(): boolean
lock(): Promise<void>
softLockBiometrics(): void
setValue(key: string, value: unknown, mode?: StorageValueModes): void
getValue<T>(key: string, mode?: StorageValueModes): T
removeValue(key: string, mode?: StorageValueModes): Promise<void>
isLocked(): Promise<boolean>
getPreference<K extends PrefKey>(key: K): PrefValue[K] | undefined
getPreference<K extends PrefKey>(key: K, defaultValue: PrefValue[K]): PrefValue[K]
getPreference<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
setPreference<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
contentType: string | string[],
stream: ItemStream<I>,
): () => void
getUser(): User | undefined
hasAccount(): boolean
setCustomHost(host: string): Promise<void>
isThirdPartyHostUsed(): boolean
isUsingHomeServer(): Promise<boolean>
getNewSubscriptionToken(): Promise<string | undefined>
importData(data: BackupFile, awaitSync?: boolean): Promise<ImportDataReturnType>
/**
* Mutates a pre-existing item, marks it as dirty, and syncs it
*/
changeAndSaveItem<M extends DecryptedItemMutator = DecryptedItemMutator>(
itemToLookupUuidFor: DecryptedItemInterface,
mutate: (mutator: M) => void,
updateTimestamps?: boolean,
emitSource?: PayloadEmitSource,
syncOptions?: SyncOptions,
): Promise<DecryptedItemInterface | undefined>
/**
* Mutates pre-existing items, marks them as dirty, and syncs
*/
changeAndSaveItems<M extends DecryptedItemMutator = DecryptedItemMutator>(
itemsToLookupUuidsFor: DecryptedItemInterface[],
mutate: (mutator: M) => void,
updateTimestamps?: boolean,
emitSource?: PayloadEmitSource,
syncOptions?: SyncOptions,
): Promise<void>
get changeAndSaveItem(): ChangeAndSaveItem
get getHost(): GetHost
get setHost(): SetHost
get alerts(): AlertService
get asymmetric(): AsymmetricMessageServiceInterface
@@ -109,16 +86,24 @@ export interface ApplicationInterface {
get history(): HistoryServiceInterface
get homeServer(): HomeServerServiceInterface | undefined
get items(): ItemManagerInterface
get legacyApi(): LegacyApiServiceInterface
get mfa(): MfaServiceInterface
get mutator(): MutatorClientInterface
get preferences(): PreferenceServiceInterface
get protections(): ProtectionsClientInterface
get sessions(): SessionsClientInterface
get status(): StatusServiceInterface
get storage(): StorageServiceInterface
get subscriptions(): SubscriptionManagerInterface
get sync(): SyncServiceInterface
get user(): UserServiceInterface
get vaults(): VaultServiceInterface
get vaultLocks(): VaultLockServiceInterface
get vaultUsers(): VaultUserServiceInterface
get vaultInvites(): VaultInviteServiceInterface
get vaultLocks(): VaultLockServiceInterface
get vaults(): VaultServiceInterface
get vaultUsers(): VaultUserServiceInterface
readonly options: FullyResolvedApplicationOptions
readonly environment: Environment
readonly identifier: ApplicationIdentifier
readonly platform: Platform
device: DeviceInterface
@@ -14,8 +14,6 @@ export interface ChallengeServiceInterface extends AbstractService {
submitValuesForChallenge(challenge: ChallengeInterface, values: ChallengeValue[]): Promise<void>
cancelChallenge(challenge: ChallengeInterface): void
isPasscodeLocked(): Promise<boolean>
/**
* Resolves when the challenge has been completed.
* For non-validated challenges, will resolve when the first value is submitted.
@@ -4,4 +4,7 @@ export interface DesktopManagerInterface {
syncComponentsInstallation(components: ComponentInterface[]): void
registerUpdateObserver(callback: (component: ComponentInterface) => void): () => void
getExtServerHost(): string
saveDesktopBackup(): Promise<void>
searchText(text?: string): void
redoSearch(): void
}
@@ -24,6 +24,8 @@ import {
export interface EncryptionProviderInterface {
initialize(): Promise<void>
isPasscodeLocked(): Promise<boolean>
encryptSplitSingle(split: KeyedEncryptionSplit): Promise<EncryptedPayloadInterface>
encryptSplit(split: KeyedEncryptionSplit): Promise<EncryptedPayloadInterface[]>
decryptSplitSingle<
@@ -191,6 +191,7 @@ export class EncryptionService
return ProtocolVersionLatest
}
/** Unlike SessionManager.isSignedIn, hasAccount can be read before the application is unlocked and is based on the key state */
public hasAccount() {
return this.rootKeyManager.hasAccount()
}
@@ -625,7 +626,7 @@ export class EncryptionService
/**
* @returns True if the root key has not yet been unwrapped (passcode locked).
*/
public async isPasscodeLocked() {
public async isPasscodeLocked(): Promise<boolean> {
return (await this.rootKeyManager.hasRootKeyWrapper()) && this.rootKeyManager.getRootKey() == undefined
}
@@ -55,7 +55,5 @@ export enum ApplicationEvent {
UnprotectedSessionExpired = 'Application:UnprotectedSessionExpired',
/** Called when the app first launches and after first sync request made after sign in */
CompletedInitialSync = 'Application:CompletedInitialSync',
BiometricsSoftLockEngaged = 'Application:BiometricsSoftLockEngaged',
BiometricsSoftLockDisengaged = 'Application:BiometricsSoftLockDisengaged',
DidPurchaseSubscription = 'Application:DidPurchaseSubscription',
}
@@ -20,8 +20,8 @@ import {
FileItem,
VaultDisplayOptions,
NotesAndFilesDisplayControllerOptions,
ThemeInterface,
ComponentInterface,
ItemStream,
} from '@standardnotes/models'
import { AbstractService } from '../Service/AbstractService'
@@ -57,6 +57,11 @@ export interface ItemManagerInterface extends AbstractService {
callback: ItemManagerChangeObserverCallback<I>,
): () => void
streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
contentType: string | string[],
stream: ItemStream<I>,
): () => void
get items(): DecryptedItemInterface[]
getItems<T extends DecryptedItemInterface>(contentType: string | string[]): T[]
@@ -117,7 +122,7 @@ export interface ItemManagerInterface extends AbstractService {
getTagParent(itemToLookupUuidFor: SNTag): SNTag | undefined
isValidTagParent(parentTagToLookUpUuidFor: SNTag, childToLookUpUuidFor: SNTag): boolean
isSmartViewTitle(title: string): boolean
getDisplayableComponents(): (ComponentInterface | ThemeInterface)[]
getDisplayableComponents(): ComponentInterface[]
createItemFromPayload<T extends DecryptedItemInterface>(payload: DecryptedPayloadInterface): T
createPayloadFromObject(object: DecryptedTransferPayload): DecryptedPayloadInterface
getDisplayableFiles(): FileItem[]
@@ -1,11 +1,7 @@
export interface MfaProvider {
export interface MfaServiceInterface {
isMfaActivated(): Promise<boolean>
generateMfaSecret(): Promise<string>
getOtpToken(secret: string): Promise<string>
enableMfa(secret: string, otpToken: string): Promise<void>
disableMfa(): Promise<void>
}
@@ -6,9 +6,9 @@ export enum PreferencesServiceEvent {
}
export interface PreferenceServiceInterface extends AbstractService<PreferencesServiceEvent> {
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K] | undefined): PrefValue[K] | undefined
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K]): PrefValue[K]
getValue<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K] | undefined): PrefValue[K] | undefined
setValue<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
/** Set value without triggering sync or event notifications */
@@ -1,9 +1,14 @@
import { ApplicationServiceInterface } from './../Service/ApplicationServiceInterface'
import { DecryptedItem, DecryptedItemInterface, FileItem, SNNote } from '@standardnotes/models'
import { ChallengeInterface, ChallengeReason } from '../Challenge'
import { MobileUnlockTiming } from './MobileUnlockTiming'
import { TimingDisplayOption } from './TimingDisplayOption'
import { ProtectionEvent } from './ProtectionEvent'
export interface ProtectionsClientInterface extends ApplicationServiceInterface<ProtectionEvent, unknown> {
isLocked(): Promise<boolean>
softLockBiometrics(): void
export interface ProtectionsClientInterface {
createLaunchChallenge(): ChallengeInterface | undefined
authorizeProtectedActionForItems<T extends DecryptedItem>(files: T[], challengeReason: ChallengeReason): Promise<T[]>
authorizeItemAccess(item: DecryptedItem): Promise<boolean>
@@ -0,0 +1,6 @@
export enum ProtectionEvent {
UnprotectedSessionBegan = 'Protection:UnprotectedSessionBegan',
UnprotectedSessionExpired = 'Protection:UnprotectedSessionExpired',
BiometricsSoftLockEngaged = 'Protection:BiometricsSoftLockEngaged',
BiometricsSoftLockDisengaged = 'Protection:BiometricsSoftLockDisengaged',
}
@@ -20,6 +20,7 @@ export interface SessionsClientInterface {
getUser(): User | undefined
isSignedIn(): boolean
isSignedOut(): boolean
get userUuid(): string
getSureUser(): User
isSignedIntoFirstPartyServer(): boolean
@@ -0,0 +1,33 @@
import { SyncOptions } from './../Sync/SyncOptions'
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
import { DecryptedItemInterface, DecryptedItemMutator, MutationType, PayloadEmitSource } from '@standardnotes/models'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
export class ChangeAndSaveItem implements UseCaseInterface<DecryptedItemInterface | undefined> {
constructor(
private readonly items: ItemManagerInterface,
private mutator: MutatorClientInterface,
private sync: SyncServiceInterface,
) {}
async execute<M extends DecryptedItemMutator = DecryptedItemMutator>(
itemToLookupUuidFor: DecryptedItemInterface,
mutate: (mutator: M) => void,
updateTimestamps = true,
emitSource?: PayloadEmitSource,
syncOptions?: SyncOptions,
): Promise<Result<DecryptedItemInterface | undefined>> {
await this.mutator.changeItems(
[itemToLookupUuidFor],
mutate,
updateTimestamps ? MutationType.UpdateUserTimestamps : MutationType.NoUpdateUserTimestamps,
emitSource,
)
await this.sync.sync(syncOptions)
return Result.ok(this.items.findItem(itemToLookupUuidFor.uuid))
}
}
@@ -0,0 +1,10 @@
import { LegacyApiServiceInterface } from './../Api/LegacyApiServiceInterface'
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
export class GetHost implements SyncUseCaseInterface<string> {
constructor(private legacyApi: LegacyApiServiceInterface) {}
execute(): Result<string> {
return Result.ok(this.legacyApi.getHost())
}
}
@@ -0,0 +1,18 @@
import { HttpServiceInterface } from '@standardnotes/api'
import { LegacyApiServiceInterface } from '../Api/LegacyApiServiceInterface'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
export class SetHost implements UseCaseInterface<void> {
constructor(
private http: HttpServiceInterface,
private legacyApi: LegacyApiServiceInterface,
) {}
async execute(host: string): Promise<Result<string>> {
this.http.setHost(host)
await this.legacyApi.setHost(host)
return Result.ok()
}
}
+12 -3
View File
@@ -10,6 +10,10 @@ export * from './Application/ApplicationStage'
export * from './Application/DeinitCallback'
export * from './Application/DeinitMode'
export * from './Application/DeinitSource'
export * from './Application/Options/ApplicationOptions'
export * from './Application/Options/Defaults'
export * from './Application/Options/OptionalOptions'
export * from './Application/Options/RequiredOptions'
export * from './AsymmetricMessage/AsymmetricMessageService'
export * from './AsymmetricMessage/AsymmetricMessageServiceInterface'
export * from './AsymmetricMessage/UseCase/GetInboundMessages'
@@ -117,12 +121,14 @@ export * from './Item/StaticItemCounter'
export * from './ItemsEncryption/ItemsEncryption'
export * from './ItemsEncryption/ItemsEncryption'
export * from './KeySystem/KeySystemKeyManager'
export * from './Mfa/MfaServiceInterface'
export * from './Mutator/ImportDataUseCase'
export * from './Mutator/MutatorClientInterface'
export * from './Payloads/PayloadManagerInterface'
export * from './Preferences/PreferenceServiceInterface'
export * from './Protection/MobileUnlockTiming'
export * from './Protection/ProtectionClientInterface'
export * from './Protection/ProtectionEvent'
export * from './Protection/TimingDisplayOption'
export * from './Revision/RevisionClientInterface'
export * from './Revision/RevisionManager'
@@ -170,20 +176,23 @@ export * from './Sync/SyncOptions'
export * from './Sync/SyncQueueStrategy'
export * from './Sync/SyncServiceInterface'
export * from './Sync/SyncSource'
export * from './UseCase/ChangeAndSaveItem'
export * from './UseCase/DiscardItemsLocally'
export * from './UseCase/GetHost'
export * from './UseCase/SetHost'
export * from './User/AccountEvent'
export * from './User/AccountEventData'
export * from './User/CredentialsChangeFunctionResponse'
export * from './User/SignedInOrRegisteredEventPayload'
export * from './User/SignedOutEventPayload'
export * from './User/UserServiceInterface'
export * from './User/UserServiceInterface'
export * from './User/UserService'
export * from './User/UserServiceInterface'
export * from './User/UserServiceInterface'
export * from './UserEvent/NotificationService'
export * from './UserEvent/NotificationServiceEvent'
export * from './Vault/UseCase/ChangeVaultStorageMode'
export * from './Vault/UseCase/ChangeVaultKeyOptions'
export * from './Vault/UseCase/ChangeVaultKeyOptionsDTO'
export * from './Vault/UseCase/ChangeVaultStorageMode'
export * from './Vault/UseCase/CreateVault'
export * from './Vault/UseCase/DeleteVault'
export * from './Vault/UseCase/GetVault'
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.202.34](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/snjs
## [2.202.33](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/snjs
## [2.202.32](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/snjs
## [2.202.31](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
**Note:** Version bump only for package @standardnotes/snjs
## [2.202.30](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/snjs
+38 -164
View File
@@ -1,4 +1,4 @@
import { SNMfaService } from './../Services/Mfa/MfaService'
import { MfaService } from './../Services/Mfa/MfaService'
import { KeyRecoveryService } from './../Services/KeyRecovery/KeyRecoveryService'
import { WebSocketsService } from './../Services/Api/WebsocketsService'
import { MigrationService } from './../Services/Migration/MigrationService'
@@ -20,7 +20,6 @@ import {
ApplicationStageChangedEventPayload,
StorageValueModes,
ChallengeObserver,
SyncOptions,
ImportDataReturnType,
ImportDataUseCase,
StoragePersistencePolicies,
@@ -57,7 +56,6 @@ import {
ApplicationInterface,
EncryptionService,
EncryptionServiceEvent,
ChallengePrompt,
Challenge,
ErrorAlertStrings,
SessionsClientInterface,
@@ -75,32 +73,33 @@ import {
VaultInviteServiceInterface,
NotificationServiceEvent,
VaultLockServiceInterface,
ApplicationConstructorOptions,
FullyResolvedApplicationOptions,
ApplicationOptionsDefaults,
ChangeAndSaveItem,
ProtectionEvent,
GetHost,
SetHost,
MfaServiceInterface,
} from '@standardnotes/services'
import {
PayloadEmitSource,
SNNote,
PrefKey,
PrefValue,
DecryptedItemMutator,
BackupFile,
DecryptedItemInterface,
EncryptedItemInterface,
Environment,
ItemStream,
Platform,
MutationType,
} from '@standardnotes/models'
import {
HttpResponse,
SessionListResponse,
User,
SignInResponse,
ClientDisplayableError,
SessionListEntry,
} from '@standardnotes/responses'
import {
SyncService,
ProtectionEvent,
SettingsService,
ActionsService,
ChallengeResponse,
@@ -116,14 +115,13 @@ import {
UuidGenerator,
useBoolean,
LoggerInterface,
canBlockDeinit,
} from '@standardnotes/utils'
import { UuidString, ApplicationEventPayload } from '../Types'
import { applicationEventForSyncEvent } from '@Lib/Application/Event'
import { BackupServiceInterface, FilesClientInterface } from '@standardnotes/files'
import { ComputePrivateUsername } from '@standardnotes/encryption'
import { SNLog } from '../Log'
import { ApplicationConstructorOptions, FullyResolvedApplicationOptions } from './Options/ApplicationOptions'
import { ApplicationOptionsDefaults } from './Options/Defaults'
import { SignInWithRecoveryCodes } from '@Lib/Domain/UseCase/SignInWithRecoveryCodes/SignInWithRecoveryCodes'
import { UseCaseContainerInterface } from '@Lib/Domain/UseCase/UseCaseContainerInterface'
import { GetRecoveryCodes } from '@Lib/Domain/UseCase/GetRecoveryCodes/GetRecoveryCodes'
@@ -137,7 +135,6 @@ import { GetAuthenticatorAuthenticationResponse } from '@Lib/Domain/UseCase/GetA
import { GetAuthenticatorAuthenticationOptions } from '@Lib/Domain/UseCase/GetAuthenticatorAuthenticationOptions/GetAuthenticatorAuthenticationOptions'
import { Dependencies } from './Dependencies/Dependencies'
import { TYPES } from './Dependencies/Types'
import { canBlockDeinit } from './Dependencies/isDeinitable'
/** How often to automatically sync, in milliseconds */
const DEFAULT_AUTO_SYNC_INTERVAL = 30_000
@@ -165,7 +162,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
private eventHandlers: ApplicationObserver[] = []
private streamRemovers: ObserverRemover[] = []
private serviceObservers: ObserverRemover[] = []
private managedSubscribers: ObserverRemover[] = []
private autoSyncInterval!: ReturnType<typeof setInterval>
@@ -178,7 +174,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
private launched = false
/** Whether the application has been destroyed via .deinit() */
public dealloced = false
private isBiometricsSoftLockEngaged = false
private revokingSession = false
private handledFullSyncStage = false
@@ -561,13 +557,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
void this.migrations.handleApplicationEvent(event)
}
/**
* Whether the local database has completed loading local items.
*/
public isDatabaseLoaded(): boolean {
return this.sync.isDatabaseLoaded()
}
public getSessions(): Promise<HttpResponse<SessionListEntry[]>> {
return this.sessions.getSessionsList()
}
@@ -594,65 +583,12 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return compareVersions(userVersion, ProtocolVersion.V004) >= 0
}
/**
* Begin streaming items to display in the UI. The stream callback will be called
* immediately with the present items that match the constraint, and over time whenever
* items matching the constraint are added, changed, or deleted.
*/
public streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
contentType: string | string[],
stream: ItemStream<I>,
): () => void {
const removeItemManagerObserver = this.items.addObserver<I>(
contentType,
({ changed, inserted, removed, source }) => {
stream({ changed, inserted, removed, source })
},
)
const matches = this.items.getItems<I>(contentType)
stream({
inserted: matches,
changed: [],
removed: [],
source: PayloadEmitSource.InitialObserverRegistrationPush,
})
this.streamRemovers.push(removeItemManagerObserver)
return () => {
removeItemManagerObserver()
removeFromArray(this.streamRemovers, removeItemManagerObserver)
}
}
/**
* Set the server's URL
*/
public async setHost(host: string): Promise<void> {
this.http.setHost(host)
await this.legacyApi.setHost(host)
}
public getHost(): string {
return this.legacyApi.getHost()
}
public async setCustomHost(host: string): Promise<void> {
await this.setHost(host)
await this.setHost.execute(host)
this.sockets.setWebSocketUrl(undefined)
}
public getUser(): User | undefined {
if (!this.launched) {
throw Error('Attempting to access user before application unlocked')
}
return this.sessions.getUser()
}
public getUserPasswordCreationDate(): Date | undefined {
return this.encryption.getPasswordCreatedDate()
}
@@ -699,10 +635,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return result
}
public noAccount(): boolean {
return !this.hasAccount()
}
public hasAccount(): boolean {
return this.encryption.hasAccount()
}
@@ -715,10 +647,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return this.protections.hasProtectionSources()
}
public hasUnprotectedAccessSession(): boolean {
return this.protections.hasUnprotectedAccessSession()
}
/**
* When a user specifies a non-zero remember duration on a protection
* challenge, a session will be started during which protections are disabled.
@@ -746,10 +674,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return this.protections.authorizeAutolockIntervalChange()
}
public authorizeSearchingProtectedNotesText(): Promise<boolean> {
return this.protections.authorizeSearchingProtectedNotesText()
}
public async createEncryptedBackupFileForAutomatedDesktopBackups(): Promise<BackupFile | undefined> {
return this.encryption.createEncryptedBackupFile()
}
@@ -852,7 +776,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
this.serviceObservers.length = 0
this.managedSubscribers.length = 0
this.streamRemovers.length = 0
this.started = false
@@ -921,39 +844,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
})
}
public async changeAndSaveItem<M extends DecryptedItemMutator = DecryptedItemMutator>(
itemToLookupUuidFor: DecryptedItemInterface,
mutate: (mutator: M) => void,
updateTimestamps = true,
emitSource?: PayloadEmitSource,
syncOptions?: SyncOptions,
): Promise<DecryptedItemInterface | undefined> {
await this.mutator.changeItems(
[itemToLookupUuidFor],
mutate,
updateTimestamps ? MutationType.UpdateUserTimestamps : MutationType.NoUpdateUserTimestamps,
emitSource,
)
await this.sync.sync(syncOptions)
return this.items.findItem(itemToLookupUuidFor.uuid)
}
public async changeAndSaveItems<M extends DecryptedItemMutator = DecryptedItemMutator>(
itemsToLookupUuidsFor: DecryptedItemInterface[],
mutate: (mutator: M) => void,
updateTimestamps = true,
emitSource?: PayloadEmitSource,
syncOptions?: SyncOptions,
): Promise<void> {
await this.mutator.changeItems(
itemsToLookupUuidsFor,
mutate,
updateTimestamps ? MutationType.UpdateUserTimestamps : MutationType.NoUpdateUserTimestamps,
emitSource,
)
await this.sync.sync(syncOptions)
}
public async importData(data: BackupFile, awaitSync = false): Promise<ImportDataReturnType> {
const usecase = this.dependencies.get<ImportDataUseCase>(TYPES.ImportDataUseCase)
return usecase.execute(data, awaitSync)
@@ -991,42 +881,18 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return this.encryption.hasPasscode()
}
async isLocked(): Promise<boolean> {
if (!this.started) {
return Promise.resolve(true)
}
const isPasscodeLocked = await this.challenges.isPasscodeLocked()
return isPasscodeLocked || this.isBiometricsSoftLockEngaged
}
public async lock(): Promise<void> {
/** Because locking is a critical operation, we want to try to do it safely,
* but only up to a certain limit. */
/**
* Because locking is a critical operation, we want to try to do it safely,
* but only up to a certain limit.
*/
const MaximumWaitTime = 500
await this.prepareForDeinit(MaximumWaitTime)
return this.deinit(this.getDeinitMode(), DeinitSource.Lock)
}
public softLockBiometrics(): void {
const challenge = new Challenge(
[new ChallengePrompt(ChallengeValidation.Biometric)],
ChallengeReason.ApplicationUnlock,
false,
)
void this.challenges.promptForChallengeResponse(challenge)
this.isBiometricsSoftLockEngaged = true
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockEngaged)
this.addChallengeObserver(challenge, {
onComplete: () => {
this.isBiometricsSoftLockEngaged = false
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockDisengaged)
},
})
}
isNativeMobileWeb() {
return this.environment === Environment.Mobile
}
@@ -1102,10 +968,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
}
}
public getNewSubscriptionToken(): Promise<string | undefined> {
return this.legacyApi.getNewSubscriptionToken()
}
public isThirdPartyHostUsed(): boolean {
return this.legacyApi.isThirdPartyHostUsed()
}
@@ -1117,7 +979,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return false
}
return this.getHost() === (await homeServerService.getHomeServerUrl())
return this.getHost.execute().getValue() === (await homeServerService.getHomeServerUrl())
}
private createBackgroundDependencies() {
@@ -1361,14 +1223,30 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
return this.dependencies.get<SharedVaultServiceInterface>(TYPES.SharedVaultService)
}
private get migrations(): MigrationService {
return this.dependencies.get<MigrationService>(TYPES.MigrationService)
public get changeAndSaveItem(): ChangeAndSaveItem {
return this.dependencies.get<ChangeAndSaveItem>(TYPES.ChangeAndSaveItem)
}
private get legacyApi(): LegacyApiService {
public get getHost(): GetHost {
return this.dependencies.get<GetHost>(TYPES.GetHost)
}
public get setHost(): SetHost {
return this.dependencies.get<SetHost>(TYPES.SetHost)
}
public get legacyApi(): LegacyApiService {
return this.dependencies.get<LegacyApiService>(TYPES.LegacyApiService)
}
public get mfa(): MfaServiceInterface {
return this.dependencies.get<MfaService>(TYPES.MfaService)
}
private get migrations(): MigrationService {
return this.dependencies.get<MigrationService>(TYPES.MigrationService)
}
private get http(): HttpServiceInterface {
return this.dependencies.get<HttpServiceInterface>(TYPES.HttpService)
}
@@ -1376,8 +1254,4 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
private get sockets(): WebSocketsService {
return this.dependencies.get<WebSocketsService>(TYPES.WebSocketsService)
}
private get mfa(): SNMfaService {
return this.dependencies.get<SNMfaService>(TYPES.MfaService)
}
}
@@ -11,8 +11,8 @@ import { GetRecoveryCodes } from '../../Domain/UseCase/GetRecoveryCodes/GetRecov
import { SignInWithRecoveryCodes } from '../../Domain/UseCase/SignInWithRecoveryCodes/SignInWithRecoveryCodes'
import { ListedService } from '../../Services/Listed/ListedService'
import { MigrationService } from '../../Services/Migration/MigrationService'
import { SNMfaService } from '../../Services/Mfa/MfaService'
import { SNComponentManager } from '../../Services/ComponentManager/ComponentManager'
import { MfaService } from '../../Services/Mfa/MfaService'
import { ComponentManager } from '../../Services/ComponentManager/ComponentManager'
import { FeaturesService } from '@Lib/Services/Features/FeaturesService'
import { SettingsService } from '../../Services/Settings/SNSettingsService'
import { PreferencesService } from '../../Services/Preferences/PreferencesService'
@@ -126,6 +126,10 @@ import {
AlertService,
DesktopDeviceInterface,
ChangeVaultStorageMode,
ChangeAndSaveItem,
FullyResolvedApplicationOptions,
GetHost,
SetHost,
} from '@standardnotes/services'
import { ItemManager } from '../../Services/Items/ItemManager'
import { PayloadManager } from '../../Services/Payloads/PayloadManager'
@@ -151,10 +155,8 @@ import {
WebSocketApiService,
WebSocketServer,
} from '@standardnotes/api'
import { FullyResolvedApplicationOptions } from '../Options/ApplicationOptions'
import { TYPES } from './Types'
import { isDeinitable } from './isDeinitable'
import { Logger, isNotUndefined } from '@standardnotes/utils'
import { Logger, isNotUndefined, isDeinitable } from '@standardnotes/utils'
import { EncryptionOperators } from '@standardnotes/encryption'
import { AsymmetricMessagePayload, AsymmetricMessageSharedVaultInvite } from '@standardnotes/models'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
@@ -219,6 +221,14 @@ export class Dependencies {
)
})
this.factory.set(TYPES.GetHost, () => {
return new GetHost(this.get<LegacyApiService>(TYPES.LegacyApiService))
})
this.factory.set(TYPES.SetHost, () => {
return new SetHost(this.get<HttpService>(TYPES.HttpService), this.get<LegacyApiService>(TYPES.LegacyApiService))
})
this.factory.set(TYPES.GetKeyPairs, () => {
return new GetKeyPairs(this.get<RootKeyManager>(TYPES.RootKeyManager))
})
@@ -307,6 +317,14 @@ export class Dependencies {
return new GetVaults(this.get<ItemManager>(TYPES.ItemManager))
})
this.factory.set(TYPES.ChangeAndSaveItem, () => {
return new ChangeAndSaveItem(
this.get<ItemManager>(TYPES.ItemManager),
this.get<MutatorService>(TYPES.MutatorService),
this.get<SyncService>(TYPES.SyncService),
)
})
this.factory.set(TYPES.GetSharedVaults, () => {
return new GetSharedVaults(this.get<GetVaults>(TYPES.GetVaults))
})
@@ -1080,7 +1098,7 @@ export class Dependencies {
})
this.factory.set(TYPES.MfaService, () => {
return new SNMfaService(
return new MfaService(
this.get<SettingsService>(TYPES.SettingsService),
this.get<PureCryptoInterface>(TYPES.Crypto),
this.get<FeaturesService>(TYPES.FeaturesService),
@@ -1089,7 +1107,7 @@ export class Dependencies {
})
this.factory.set(TYPES.ComponentManager, () => {
return new SNComponentManager(
return new ComponentManager(
this.get<ItemManager>(TYPES.ItemManager),
this.get<MutatorService>(TYPES.MutatorService),
this.get<SyncService>(TYPES.SyncService),
@@ -156,6 +156,9 @@ export const TYPES = {
DecryptErroredPayloads: Symbol.for('DecryptErroredPayloads'),
GetKeyPairs: Symbol.for('GetKeyPairs'),
ChangeVaultStorageMode: Symbol.for('ChangeVaultStorageMode'),
ChangeAndSaveItem: Symbol.for('ChangeAndSaveItem'),
GetHost: Symbol.for('GetHost'),
SetHost: Symbol.for('SetHost'),
// Mappers
SessionStorageMapper: Symbol.for('SessionStorageMapper'),
+4 -4
View File
@@ -1,17 +1,17 @@
import { DecryptedItemInterface } from '@standardnotes/models'
import { ApplicationInterface } from '@standardnotes/services'
import { ItemManagerInterface } from '@standardnotes/services'
/** Keeps an item reference up to date with changes */
export class LiveItem<T extends DecryptedItemInterface> {
public item: T
private removeObserver: () => void
constructor(uuid: string, application: ApplicationInterface, onChange?: (item: T) => void) {
this.item = application.items.findSureItem(uuid)
constructor(uuid: string, items: ItemManagerInterface, onChange?: (item: T) => void) {
this.item = items.findSureItem(uuid)
onChange && onChange(this.item)
this.removeObserver = application.streamItems(this.item.content_type, ({ changed, inserted }) => {
this.removeObserver = items.streamItems(this.item.content_type, ({ changed, inserted }) => {
const matchingItem = [...changed, ...inserted].find((item) => {
return item.uuid === uuid
})
-1
View File
@@ -2,4 +2,3 @@ export * from './Application'
export * from './Event'
export * from './LiveItem'
export * from './Platforms'
export * from './Options/Defaults'
@@ -1,7 +1,7 @@
import { ApplicationStage } from '@standardnotes/services'
import { Migration } from '@Lib/Migrations/Migration'
import { ThemeInterface } from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { ComponentInterface } from '@standardnotes/models'
const NoDistractionIdentifier = 'org.standardnotes.theme-no-distraction'
@@ -18,7 +18,7 @@ export class Migration2_42_0 extends Migration {
}
private async deleteNoDistraction(): Promise<void> {
const themes = this.services.itemManager.getItems<ThemeInterface>(ContentType.TYPES.Theme).filter((theme) => {
const themes = this.services.itemManager.getItems<ComponentInterface>(ContentType.TYPES.Theme).filter((theme) => {
return theme.identifier === NoDistractionIdentifier
})
@@ -1,4 +1,4 @@
import { CompoundPredicate, Predicate, SNComponent } from '@standardnotes/models'
import { CompoundPredicate, Predicate, ComponentItem } from '@standardnotes/models'
import { Migration } from '@Lib/Migrations/Migration'
import { ApplicationStage } from '@standardnotes/services'
import { ContentType } from '@standardnotes/domain-core'
@@ -19,8 +19,8 @@ export class Migration2_7_0 extends Migration {
const batchMgrId = 'org.standardnotes.batch-manager'
const batchMgrPred = new CompoundPredicate('and', [
new Predicate<SNComponent>('content_type', '=', ContentType.TYPES.Component),
new Predicate<SNComponent>('identifier', '=', batchMgrId),
new Predicate<ComponentItem>('content_type', '=', ContentType.TYPES.Component),
new Predicate<ComponentItem>('identifier', '=', batchMgrId),
])
const batchMgrSingleton = this.services.singletonManager.findSingleton(ContentType.TYPES.Component, batchMgrPred)
@@ -1,7 +1,7 @@
import { RootKeyInterface } from '@standardnotes/models'
import { DiskStorageService } from '../Storage/DiskStorageService'
import { removeFromArray } from '@standardnotes/utils'
import { isValidProtectionSessionLength } from '../Protection/ProtectionService'
import { isValidProtectionSessionLength } from '../Protection/isValidProtectionSessionLength'
import {
AbstractService,
ChallengeServiceInterface,
@@ -158,10 +158,6 @@ export class ChallengeService extends AbstractService implements ChallengeServic
return { wrappingKey }
}
public isPasscodeLocked(): Promise<boolean> {
return this.encryptionService.isPasscodeLocked()
}
public addChallengeObserver(challenge: Challenge, observer: ChallengeObserver): () => void {
const observers = this.challengeObservers[challenge.id] || []
@@ -11,7 +11,7 @@ import {
} from '@standardnotes/services'
import { ItemManager } from '@Lib/Services/Items/ItemManager'
import { FeaturesService } from '@Lib/Services/Features/FeaturesService'
import { SNComponentManager } from './ComponentManager'
import { ComponentManager } from './ComponentManager'
import { SyncService } from '../Sync/SyncService'
import { LoggerInterface } from '@standardnotes/utils'
@@ -27,7 +27,7 @@ describe('featuresService', () => {
let logger: LoggerInterface
const createManager = (environment: Environment, platform: Platform) => {
const manager = new SNComponentManager(
const manager = new ComponentManager(
items,
mutator,
sync,
@@ -69,7 +69,7 @@ declare global {
* and other components. The component manager primarily deals with iframes, and orchestrates
* sending and receiving messages to and from frames via the postMessage API.
*/
export class SNComponentManager
export class ComponentManager
extends AbstractService<ComponentManagerEvent, ComponentManagerEventData>
implements ComponentManagerInterface
{
@@ -1,7 +1,7 @@
import { ItemManagerInterface, PreferenceServiceInterface } from '@standardnotes/services'
import { GetDefaultEditorIdentifier } from './GetDefaultEditorIdentifier'
import { ComponentArea, NativeFeatureIdentifier } from '@standardnotes/features'
import { SNComponent, SNTag } from '@standardnotes/models'
import { ComponentItem, SNTag } from '@standardnotes/models'
describe('getDefaultEditorIdentifier', () => {
let usecase: GetDefaultEditorIdentifier
@@ -49,7 +49,7 @@ describe('getDefaultEditorIdentifier', () => {
legacyIsDefaultEditor: jest.fn().mockReturnValue(true),
identifier: NativeFeatureIdentifier.TYPES.MarkdownProEditor,
area: ComponentArea.Editor,
} as unknown as jest.Mocked<SNComponent>
} as unknown as jest.Mocked<ComponentItem>
items.getDisplayableComponents = jest.fn().mockReturnValue([editor])
@@ -13,7 +13,7 @@ import {
Environment,
PayloadTimestampDefaults,
Platform,
SNComponent,
ComponentItem,
UIFeature,
} from '@standardnotes/models'
import { DesktopManagerInterface } from '@standardnotes/services'
@@ -26,7 +26,7 @@ const nativeFeatureAsUIFeature = <F extends UIFeatureDescriptionTypes>(identifie
}
const thirdPartyFeature = () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload({
uuid: '789',
content_type: ContentType.TYPES.Component,
@@ -58,7 +58,7 @@ describe('GetFeatureUrl', () => {
})
describe('desktop', () => {
let desktopManager: DesktopManagerInterface | undefined
let desktopManager: jest.Mocked<DesktopManagerInterface | undefined>
beforeEach(() => {
desktopManager = {
@@ -69,7 +69,7 @@ describe('GetFeatureUrl', () => {
getExtServerHost() {
return desktopExtHost
},
}
} as unknown as jest.Mocked<DesktopManagerInterface | undefined>
usecase = new GetFeatureUrl(desktopManager, Environment.Desktop, Platform.MacDesktop)
})
@@ -101,7 +101,7 @@ describe('GetFeatureUrl', () => {
})
it('returns hosted url for third party component with no local_url', () => {
const component = new SNComponent({
const component = new ComponentItem({
uuid: '789',
content_type: ContentType.TYPES.Component,
content: {
@@ -15,7 +15,6 @@ import {
FillItemContent,
PayloadEmitSource,
ComponentInterface,
ThemeInterface,
DecryptedItemInterface,
} from '@standardnotes/models'
import {
@@ -191,7 +190,7 @@ export class FeaturesService
void this.storage.setValue(StorageKey.ExperimentalFeatures, this.enabledExperimentalFeatures)
const component = this.items
.getItems<ComponentInterface | ThemeInterface>([ContentType.TYPES.Component, ContentType.TYPES.Theme])
.getItems<ComponentInterface>([ContentType.TYPES.Component, ContentType.TYPES.Theme])
.find((component) => component.identifier === identifier)
if (!component) {
return
@@ -28,6 +28,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
private collection!: Models.ItemCollection
private systemSmartViews: Models.SmartView[]
private itemCounter!: Models.ItemCounter
private streamDisposers: (() => void)[] = []
private navigationDisplayController!: Models.ItemDisplayController<
Models.SNNote | Models.FileItem,
@@ -36,7 +37,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
private tagDisplayController!: Models.ItemDisplayController<Models.SNTag, Models.TagsDisplayOptions>
private itemsKeyDisplayController!: Models.ItemDisplayController<SNItemsKey>
private componentDisplayController!: Models.ItemDisplayController<Models.ComponentInterface>
private themeDisplayController!: Models.ItemDisplayController<Models.ThemeInterface>
private themeDisplayController!: Models.ItemDisplayController<Models.ComponentInterface>
private fileDisplayController!: Models.ItemDisplayController<Models.FileItem>
private smartViewDisplayController!: Models.ItemDisplayController<Models.SmartView>
@@ -224,12 +225,13 @@ export class ItemManager extends Services.AbstractService implements Services.It
return this.itemsKeyDisplayController.items()
}
public getDisplayableComponents(): (Models.ComponentInterface | Models.ThemeInterface)[] {
public getDisplayableComponents(): Models.ComponentInterface[] {
return [...this.componentDisplayController.items(), ...this.themeDisplayController.items()]
}
public override deinit(): void {
this.unsubChangeObserver()
this.streamDisposers.length = 0
;(this.unsubChangeObserver as unknown) = undefined
;(this.payloadManager as unknown) = undefined
;(this.collection as unknown) = undefined
@@ -865,4 +867,34 @@ export class ItemManager extends Services.AbstractService implements Services.It
getNoteLinkedFiles(note: Models.SNNote): Models.FileItem[] {
return this.itemsReferencingItem(note).filter(Models.isFile)
}
/**
* Begin streaming items to display in the UI. The stream callback will be called
* immediately with the present items that match the constraint, and over time whenever
* items matching the constraint are added, changed, or deleted.
*/
public streamItems<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface>(
contentType: string | string[],
stream: Models.ItemStream<I>,
): () => void {
const removeItemManagerObserver = this.addObserver<I>(contentType, ({ changed, inserted, removed, source }) => {
stream({ changed, inserted, removed, source })
})
const matches = this.getItems<I>(contentType)
stream({
inserted: matches,
changed: [],
removed: [],
source: Models.PayloadEmitSource.InitialObserverRegistrationPush,
})
this.streamDisposers.push(removeItemManagerObserver)
return () => {
removeItemManagerObserver()
removeFromArray(this.streamDisposers, removeItemManagerObserver)
}
}
}
+2 -2
View File
@@ -3,9 +3,9 @@ import { SettingName } from '@standardnotes/settings'
import { SettingsService } from '../Settings'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { FeaturesService } from '../Features/FeaturesService'
import { AbstractService, InternalEventBusInterface, SignInStrings } from '@standardnotes/services'
import { AbstractService, InternalEventBusInterface, MfaServiceInterface, SignInStrings } from '@standardnotes/services'
export class SNMfaService extends AbstractService {
export class MfaService extends AbstractService implements MfaServiceInterface {
constructor(
private settingsService: SettingsService,
private crypto: PureCryptoInterface,
@@ -0,0 +1 @@
export const ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction = 30
@@ -29,45 +29,11 @@ import {
InternalEventInterface,
ApplicationEvent,
ApplicationStageChangedEventPayload,
ProtectionEvent,
} from '@standardnotes/services'
import { ContentType } from '@standardnotes/domain-core'
export enum ProtectionEvent {
UnprotectedSessionBegan = 'UnprotectedSessionBegan',
UnprotectedSessionExpired = 'UnprotectedSessionExpired',
}
export const ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction = 30
export enum UnprotectedAccessSecondsDuration {
OneMinute = 60,
FiveMinutes = 300,
OneHour = 3600,
OneWeek = 604800,
}
export function isValidProtectionSessionLength(number: unknown): boolean {
return typeof number === 'number' && Object.values(UnprotectedAccessSecondsDuration).includes(number)
}
export const ProtectionSessionDurations = [
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneMinute,
label: '1 Minute',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.FiveMinutes,
label: '5 Minutes',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneHour,
label: '1 Hour',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneWeek,
label: '1 Week',
},
]
import { isValidProtectionSessionLength } from './isValidProtectionSessionLength'
import { UnprotectedAccessSecondsDuration } from './UnprotectedAccessSecondsDuration'
/**
* Enforces certain actions to require extra authentication,
@@ -82,11 +48,14 @@ export class ProtectionService
private mobilePasscodeTiming: MobileUnlockTiming | undefined = MobileUnlockTiming.OnQuit
private mobileBiometricsTiming: MobileUnlockTiming | undefined = MobileUnlockTiming.OnQuit
private isBiometricsSoftLockEngaged = false
private applicationStarted = false
constructor(
private encryptionService: EncryptionService,
private encryption: EncryptionService,
private mutator: MutatorClientInterface,
private challengeService: ChallengeService,
private storageService: DiskStorageService,
private challenges: ChallengeService,
private storage: DiskStorageService,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
@@ -94,9 +63,9 @@ export class ProtectionService
public override deinit(): void {
clearTimeout(this.sessionExpiryTimeout)
;(this.encryptionService as unknown) = undefined
;(this.challengeService as unknown) = undefined
;(this.storageService as unknown) = undefined
;(this.encryption as unknown) = undefined
;(this.challenges as unknown) = undefined
;(this.storage as unknown) = undefined
super.deinit()
}
@@ -108,11 +77,42 @@ export class ProtectionService
this.mobilePasscodeTiming = this.getMobilePasscodeTiming()
this.mobileBiometricsTiming = this.getMobileBiometricsTiming()
}
} else if (event.type === ApplicationEvent.Started) {
this.applicationStarted = true
}
}
async isLocked(): Promise<boolean> {
if (!this.applicationStarted) {
return true
}
const isPasscodeLocked = await this.encryption.isPasscodeLocked()
return isPasscodeLocked || this.isBiometricsSoftLockEngaged
}
public softLockBiometrics(): void {
const challenge = new Challenge(
[new ChallengePrompt(ChallengeValidation.Biometric)],
ChallengeReason.ApplicationUnlock,
false,
)
void this.challenges.promptForChallengeResponse(challenge)
this.isBiometricsSoftLockEngaged = true
void this.notifyEvent(ProtectionEvent.BiometricsSoftLockEngaged)
this.challenges.addChallengeObserver(challenge, {
onComplete: () => {
this.isBiometricsSoftLockEngaged = false
void this.notifyEvent(ProtectionEvent.BiometricsSoftLockDisengaged)
},
})
}
public hasProtectionSources(): boolean {
return this.encryptionService.hasAccount() || this.encryptionService.hasPasscode() || this.hasBiometricsEnabled()
return this.encryption.hasAccount() || this.encryption.hasPasscode() || this.hasBiometricsEnabled()
}
public hasUnprotectedAccessSession(): boolean {
@@ -123,7 +123,7 @@ export class ProtectionService
}
public hasBiometricsEnabled(): boolean {
const biometricsState = this.storageService.getValue(StorageKey.BiometricsState, StorageValueModes.Nonwrapped)
const biometricsState = this.storage.getValue(StorageKey.BiometricsState, StorageValueModes.Nonwrapped)
return Boolean(biometricsState)
}
@@ -133,7 +133,7 @@ export class ProtectionService
return false
}
this.storageService.setValue(StorageKey.BiometricsState, true, StorageValueModes.Nonwrapped)
this.storage.setValue(StorageKey.BiometricsState, true, StorageValueModes.Nonwrapped)
return true
}
@@ -145,7 +145,7 @@ export class ProtectionService
}
if (await this.validateOrRenewSession(ChallengeReason.DisableBiometrics)) {
this.storageService.setValue(StorageKey.BiometricsState, false, StorageValueModes.Nonwrapped)
this.storage.setValue(StorageKey.BiometricsState, false, StorageValueModes.Nonwrapped)
return true
} else {
return false
@@ -157,7 +157,7 @@ export class ProtectionService
if (this.hasBiometricsEnabled()) {
prompts.push(new ChallengePrompt(ChallengeValidation.Biometric))
}
if (this.encryptionService.hasPasscode()) {
if (this.encryption.hasPasscode()) {
prompts.push(new ChallengePrompt(ChallengeValidation.LocalPasscode))
}
if (prompts.length > 0) {
@@ -316,7 +316,7 @@ export class ProtectionService
}
getMobileBiometricsTiming(): MobileUnlockTiming | undefined {
return this.storageService.getValue<MobileUnlockTiming | undefined>(
return this.storage.getValue<MobileUnlockTiming | undefined>(
StorageKey.MobileBiometricsTiming,
StorageValueModes.Nonwrapped,
MobileUnlockTiming.OnQuit,
@@ -324,7 +324,7 @@ export class ProtectionService
}
getMobilePasscodeTiming(): MobileUnlockTiming | undefined {
return this.storageService.getValue<MobileUnlockTiming | undefined>(
return this.storage.getValue<MobileUnlockTiming | undefined>(
StorageKey.MobilePasscodeTiming,
StorageValueModes.Nonwrapped,
MobileUnlockTiming.OnQuit,
@@ -332,21 +332,21 @@ export class ProtectionService
}
setMobileBiometricsTiming(timing: MobileUnlockTiming): void {
this.storageService.setValue(StorageKey.MobileBiometricsTiming, timing, StorageValueModes.Nonwrapped)
this.storage.setValue(StorageKey.MobileBiometricsTiming, timing, StorageValueModes.Nonwrapped)
this.mobileBiometricsTiming = timing
}
setMobilePasscodeTiming(timing: MobileUnlockTiming): void {
this.storageService.setValue(StorageKey.MobilePasscodeTiming, timing, StorageValueModes.Nonwrapped)
this.storage.setValue(StorageKey.MobilePasscodeTiming, timing, StorageValueModes.Nonwrapped)
this.mobilePasscodeTiming = timing
}
setMobileScreenshotPrivacyEnabled(isEnabled: boolean) {
return this.storageService.setValue(StorageKey.MobileScreenshotPrivacyEnabled, isEnabled, StorageValueModes.Default)
return this.storage.setValue(StorageKey.MobileScreenshotPrivacyEnabled, isEnabled, StorageValueModes.Default)
}
getMobileScreenshotPrivacyEnabled(): boolean {
return this.storageService.getValue(StorageKey.MobileScreenshotPrivacyEnabled, StorageValueModes.Default, false)
return this.storage.getValue(StorageKey.MobileScreenshotPrivacyEnabled, StorageValueModes.Default, false)
}
private async validateOrRenewSession(
@@ -363,19 +363,19 @@ export class ProtectionService
prompts.push(new ChallengePrompt(ChallengeValidation.Biometric))
}
if (this.encryptionService.hasPasscode()) {
if (this.encryption.hasPasscode()) {
prompts.push(new ChallengePrompt(ChallengeValidation.LocalPasscode))
}
if (requireAccountPassword) {
if (!this.encryptionService.hasAccount()) {
if (!this.encryption.hasAccount()) {
throw Error('Requiring account password for challenge with no account')
}
prompts.push(new ChallengePrompt(ChallengeValidation.AccountPassword))
}
if (prompts.length === 0) {
if (fallBackToAccountPassword && this.encryptionService.hasAccount()) {
if (fallBackToAccountPassword && this.encryption.hasAccount()) {
prompts.push(new ChallengePrompt(ChallengeValidation.AccountPassword))
} else {
return true
@@ -396,7 +396,7 @@ export class ProtectionService
),
)
const response = await this.challengeService.promptForChallengeResponse(new Challenge(prompts, reason, true))
const response = await this.challenges.promptForChallengeResponse(new Challenge(prompts, reason, true))
if (response) {
const length = response.values.find(
@@ -414,7 +414,7 @@ export class ProtectionService
}
public getSessionExpiryDate(): Date {
const expiresAt = this.storageService.getValue<number>(StorageKey.ProtectionExpirey)
const expiresAt = this.storage.getValue<number>(StorageKey.ProtectionExpirey)
if (expiresAt) {
return new Date(expiresAt)
} else {
@@ -428,15 +428,15 @@ export class ProtectionService
}
private setSessionExpiryDate(date: Date) {
this.storageService.setValue(StorageKey.ProtectionExpirey, date)
this.storage.setValue(StorageKey.ProtectionExpirey, date)
}
private getLastSessionLength(): UnprotectedAccessSecondsDuration | undefined {
return this.storageService.getValue(StorageKey.ProtectionSessionLength)
return this.storage.getValue(StorageKey.ProtectionSessionLength)
}
private setSessionLength(length: UnprotectedAccessSecondsDuration): void {
this.storageService.setValue(StorageKey.ProtectionSessionLength, length)
this.storage.setValue(StorageKey.ProtectionSessionLength, length)
const expiresAt = new Date()
expiresAt.setSeconds(expiresAt.getSeconds() + length)
this.setSessionExpiryDate(expiresAt)
@@ -0,0 +1,20 @@
import { UnprotectedAccessSecondsDuration } from './UnprotectedAccessSecondsDuration'
export const ProtectionSessionDurations = [
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneMinute,
label: '1 Minute',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.FiveMinutes,
label: '5 Minutes',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneHour,
label: '1 Hour',
},
{
valueInSeconds: UnprotectedAccessSecondsDuration.OneWeek,
label: '1 Week',
},
]
@@ -0,0 +1,6 @@
export enum UnprotectedAccessSecondsDuration {
OneMinute = 60,
FiveMinutes = 300,
OneHour = 3600,
OneWeek = 604800,
}
@@ -1 +1,5 @@
export * from './ProtectionService'
export * from './ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction'
export * from './ProtectionSessionDurations'
export * from './UnprotectedAccessSecondsDuration'
export * from './isValidProtectionSessionLength'
@@ -0,0 +1,5 @@
import { UnprotectedAccessSecondsDuration } from './UnprotectedAccessSecondsDuration'
export function isValidProtectionSessionLength(number: unknown): boolean {
return typeof number === 'number' && Object.values(UnprotectedAccessSecondsDuration).includes(number)
}
@@ -264,10 +264,15 @@ export class SessionManager
}
}
/** Unlike EncryptionService.hasAccount, isSignedIn can only be read once the application is unlocked */
public isSignedIn(): boolean {
return this.getUser() != undefined
}
public isSignedOut(): boolean {
return !this.isSignedIn()
}
public isSignedIntoFirstPartyServer(): boolean {
return this.isSignedIn() && !this.apiService.isThirdPartyHostUsed()
}
@@ -83,6 +83,7 @@ import {
SyncEventReceivedNotificationsData,
SyncEventReceivedAsymmetricMessagesData,
SyncOpStatus,
ApplicationSyncOptions,
} from '@standardnotes/services'
import { OfflineSyncResponse } from './Offline/Response'
import {
@@ -92,7 +93,6 @@ import {
SplitPayloadsByEncryptionType,
} from '@standardnotes/encryption'
import { CreatePayloadFromRawServerItem } from './Account/Utilities'
import { ApplicationSyncOptions } from '@Lib/Application/Options/OptionalOptions'
import { DecryptedServerConflictMap, TrustedServerConflictMap } from './Account/ServerConflictMap'
import { ContentType } from '@standardnotes/domain-core'
+2 -2
View File
@@ -79,8 +79,8 @@ describe('application instances', () => {
})
await recreatedContext.launch()
expect(recreatedContext.application.getHost()).to.not.equal('http://nonsense.host')
expect(recreatedContext.application.getHost()).to.equal(Factory.getDefaultHost())
expect(recreatedContext.application.getHost.execute().getValue()).to.not.equal('http://nonsense.host')
expect(recreatedContext.application.getHost.execute().getValue()).to.equal(Factory.getDefaultHost())
await recreatedContext.deinit()
})
@@ -85,7 +85,7 @@ describe('auth fringe cases', () => {
const serverText = 'server text'
await context.application.changeAndSaveItem(firstVersionOfNote, (mutator) => {
await context.application.changeAndSaveItem.execute(firstVersionOfNote, (mutator) => {
mutator.text = serverText
})
+1 -1
View File
@@ -141,7 +141,7 @@ describe('features', () => {
expect(await application.settings.getDoesSensitiveSettingExist(setting)).to.equal(false)
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
const promise = new Promise((resolve) => {
application.streamItems(ContentType.TYPES.ExtensionRepo, ({ changed }) => {
application.items.streamItems(ContentType.TYPES.ExtensionRepo, ({ changed }) => {
for (const item of changed) {
if (item.content.migratedToUserSetting) {
resolve()
+11 -9
View File
@@ -34,8 +34,8 @@ describe('history manager', () => {
await Factory.safeDeinit(this.application)
})
function setTextAndSync(application, item, text) {
return application.changeAndSaveItem(
async function setTextAndSync(application, item, text) {
const result = await application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.text = text
@@ -44,6 +44,8 @@ describe('history manager', () => {
undefined,
syncOptions,
)
return result.getValue()
}
function deleteCharsFromString(string, amount) {
@@ -59,7 +61,7 @@ describe('history manager', () => {
expect(this.history.sessionHistoryForItem(item).length).to.equal(0)
/** Sync with different contents, should create new entry */
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = Math.random()
@@ -79,7 +81,7 @@ describe('history manager', () => {
const context = await Factory.createAppContext({ identifier })
await context.launch()
expect(context.history.sessionHistoryForItem(item).length).to.equal(0)
await context.application.changeAndSaveItem(
await context.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = Math.random()
@@ -103,7 +105,7 @@ describe('history manager', () => {
await context.application.mutator.insertItem(item)
expect(context.history.sessionHistoryForItem(item).length).to.equal(0)
await context.application.changeAndSaveItem(
await context.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = Math.random()
@@ -243,7 +245,7 @@ describe('history manager', () => {
const payload = Factory.createNotePayload()
await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
const item = this.application.items.findItem(payload.uuid)
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = Math.random()
@@ -306,7 +308,7 @@ describe('history manager', () => {
expect(itemHistory.length).to.equal(1)
/** Sync with different contents, should not create a new entry */
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = Math.random()
@@ -327,7 +329,7 @@ describe('history manager', () => {
await Factory.sleep(Factory.ServerRevisionFrequency)
/** Sync with different contents, should create new entry */
const newTitleAfterFirstChange = `The title should be: ${Math.random()}`
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.title = newTitleAfterFirstChange
@@ -411,7 +413,7 @@ describe('history manager', () => {
await Factory.sleep(Factory.ServerRevisionFrequency)
const changedText = `${Math.random()}`
await this.application.changeAndSaveItem(note, (mutator) => {
await this.application.changeAndSaveItem.execute(note, (mutator) => {
mutator.title = changedText
})
await Factory.markDirtyAndSyncItem(this.application, note)
+18 -3
View File
@@ -49,13 +49,28 @@ export class VaultsContext extends AppContext {
await this.awaitPromiseOrThrow(promise, undefined, 'Waiting for invites to process')
}
async syncAndAwaitInviteAndMessageProcessing() {
const invitePromise = this.resolveWhenAsyncFunctionCompletes(this.vaultInvites, 'processInboundInvites')
const messagePromise = this.resolveWhenAsyncFunctionCompletes(
this.asymmetric,
'handleRemoteReceivedAsymmetricMessages',
)
await this.sync()
await Promise.all([
this.awaitPromiseOrThrow(invitePromise, undefined, 'Waiting for invites to process'),
this.awaitPromiseOrThrow(messagePromise, undefined, 'Waiting for messages to process'),
])
}
/**
* Run a request to keep refresh token from expiring due to long bouts of inactivity for contact context
* Keep refresh token from expiring due to long bouts of inactivity for contact context
* while main context changes password. Tests have a refresh token age of 10s typically, and changing password
* on CI environment may be time consuming.
*/
async runAnyRequestToPreventRefreshTokenFromExpiring() {
await this.asymmetric.getInboundMessages()
async forceRefreshSession() {
await this.application.http.refreshSession()
}
async createSharedPasswordVault(password) {
@@ -813,7 +813,7 @@ describe('importing', function () {
},
})
await application.launch(false)
await application.setHost(Factory.getDefaultHost())
await application.setHost.execute(Factory.getDefaultHost())
const backupFile = {
items: [
+112 -92
View File
@@ -50,17 +50,19 @@ describe('items', () => {
const item = this.application.items.items[0]
expect(item.pinned).to.not.be.ok
const refreshedItem = await this.application.changeAndSaveItem(
item,
(mutator) => {
mutator.pinned = true
mutator.archived = true
mutator.locked = true
},
undefined,
undefined,
syncOptions,
)
const refreshedItem = (
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.pinned = true
mutator.archived = true
mutator.locked = true
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(refreshedItem.pinned).to.equal(true)
expect(refreshedItem.archived).to.equal(true)
expect(refreshedItem.locked).to.equal(true)
@@ -77,94 +79,110 @@ describe('items', () => {
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
// items should ignore this field when checking for equality
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.userModifiedDate = new Date()
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.userModifiedDate = undefined
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.userModifiedDate = new Date()
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.userModifiedDate = undefined
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(false)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
expect(item2.isItemContentEqualWith(item1)).to.equal(true)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.content.references.length).to.equal(1)
expect(item2.content.references.length).to.equal(1)
expect(item1.isItemContentEqualWith(item2)).to.equal(false)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.removeItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.removeItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.removeItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.removeItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
expect(item1.content.references.length).to.equal(0)
@@ -179,15 +197,17 @@ describe('items', () => {
let item1 = this.application.items.getDisplayableNotes()[0]
const item2 = this.application.items.getDisplayableNotes()[1]
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.content.foo).to.equal('bar')
@@ -184,15 +184,17 @@ describe('notes and tags', () => {
expect(note.content.references.length).to.equal(0)
expect(tag.content.references.length).to.equal(1)
tag = await this.application.changeAndSaveItem(
tag,
(mutator) => {
mutator.removeItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
tag = (
await this.application.changeAndSaveItem.execute(
tag,
(mutator) => {
mutator.removeItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(this.application.items.itemsReferencingItem(note).length).to.equal(0)
expect(tag.noteCount).to.equal(0)
@@ -265,15 +267,17 @@ describe('notes and tags', () => {
const notePayload = Factory.createNotePayload()
await this.application.mutator.emitItemsFromPayloads([notePayload], PayloadEmitSource.LocalChanged)
let note = this.application.items.getItems([ContentType.TYPES.Note])[0]
note = await this.application.changeAndSaveItem(
note,
(mutator) => {
mutator.mutableContent.title = Math.random()
},
undefined,
undefined,
syncOptions,
)
note = (
await this.application.changeAndSaveItem.execute(
note,
(mutator) => {
mutator.mutableContent.title = Math.random()
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(note.content.title).to.not.equal(notePayload.content.title)
})
+3 -3
View File
@@ -382,19 +382,19 @@ describe('protections', function () {
this.foo = 'tar'
application = await Factory.createInitAppWithFakeCrypto()
await application.addPasscode('passcode')
expect(application.hasUnprotectedAccessSession()).to.be.false
expect(application.protections.hasUnprotectedAccessSession()).to.be.false
})
it('should return true when session length has been set', async function () {
application = await Factory.createInitAppWithFakeCrypto()
await application.addPasscode('passcode')
await application.protections.setSessionLength(UnprotectedAccessSecondsDuration.OneMinute)
expect(application.hasUnprotectedAccessSession()).to.be.true
expect(application.protections.hasUnprotectedAccessSession()).to.be.true
})
it('should return true when there are no protection sources', async function () {
application = await Factory.createInitAppWithFakeCrypto()
expect(application.hasUnprotectedAccessSession()).to.be.true
expect(application.protections.hasUnprotectedAccessSession()).to.be.true
})
})
@@ -298,7 +298,7 @@ describe('online conflict handling', function () {
await this.application.mutator.setItemDirty(note)
this.expectedItemCount++
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
note,
(mutator) => {
// client A
@@ -332,7 +332,7 @@ describe('online conflict handling', function () {
await this.application.mutator.setItemDirty(note)
this.expectedItemCount++
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
note,
(mutator) => {
// client A
@@ -602,15 +602,17 @@ describe('online conflict handling', function () {
*/
let tag = await Factory.createMappedTag(this.application)
let note = await Factory.createMappedNote(this.application)
tag = await this.application.changeAndSaveItem(
tag,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
tag = (
await this.application.changeAndSaveItem.execute(
tag,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
).getValue()
await this.application.mutator.setItemDirty(note)
this.expectedItemCount += 2
@@ -732,39 +734,42 @@ describe('online conflict handling', function () {
})
/** This test takes too long on Docker CI */
it.skip('registering for account with bulk offline data belonging to another account should be error-free', async function () {
/**
* When performing a multi-page sync request where we are uploading data imported from a backup,
* if the first page of the sync request returns conflicted items keys, we rotate their UUID.
* The second page of sync waiting to be sent up is still encrypted with the old items key UUID.
* This causes a problem because when that second page is returned as conflicts, we will be looking
* for an items_key_id that no longer exists (has been rotated). Rather than modifying the entire
* sync paradigm to allow multi-page requests to consider side-effects of each page, we will instead
* take the approach of making sure the decryption function is liberal with regards to searching
* for the right items key. It will now consider (as a result of this test) an items key as being
* the correct key to decrypt an item if the itemskey.uuid == item.items_key_id OR if the itemsKey.duplicateOf
* value is equal to item.items_key_id.
*/
it.skip(
'registering for account with bulk offline data belonging to another account should be error-free',
async function () {
/**
* When performing a multi-page sync request where we are uploading data imported from a backup,
* if the first page of the sync request returns conflicted items keys, we rotate their UUID.
* The second page of sync waiting to be sent up is still encrypted with the old items key UUID.
* This causes a problem because when that second page is returned as conflicts, we will be looking
* for an items_key_id that no longer exists (has been rotated). Rather than modifying the entire
* sync paradigm to allow multi-page requests to consider side-effects of each page, we will instead
* take the approach of making sure the decryption function is liberal with regards to searching
* for the right items key. It will now consider (as a result of this test) an items key as being
* the correct key to decrypt an item if the itemskey.uuid == item.items_key_id OR if the itemsKey.duplicateOf
* value is equal to item.items_key_id.
*/
/** Create bulk data belonging to another account and sync */
const largeItemCount = SyncUpDownLimit + 10
await Factory.createManyMappedNotes(this.application, largeItemCount)
await this.application.sync.sync(syncOptions)
const priorData = this.application.items.items
/** Create bulk data belonging to another account and sync */
const largeItemCount = SyncUpDownLimit + 10
await Factory.createManyMappedNotes(this.application, largeItemCount)
await this.application.sync.sync(syncOptions)
const priorData = this.application.items.items
/** Register new account and import this same data */
const newApp = await Factory.signOutApplicationAndReturnNew(this.application)
await Factory.registerUserToApplication({
application: newApp,
email: Utils.generateUuid(),
password: Utils.generateUuid(),
})
await newApp.mutator.emitItemsFromPayloads(priorData.map((i) => i.payload))
await newApp.sync.markAllItemsAsNeedingSyncAndPersist()
await newApp.sync.sync(syncOptions)
expect(newApp.payloads.invalidPayloads.length).to.equal(0)
await Factory.safeDeinit(newApp)
}).timeout(80000)
/** Register new account and import this same data */
const newApp = await Factory.signOutApplicationAndReturnNew(this.application)
await Factory.registerUserToApplication({
application: newApp,
email: Utils.generateUuid(),
password: Utils.generateUuid(),
})
await newApp.mutator.emitItemsFromPayloads(priorData.map((i) => i.payload))
await newApp.sync.markAllItemsAsNeedingSyncAndPersist()
await newApp.sync.sync(syncOptions)
expect(newApp.payloads.invalidPayloads.length).to.equal(0)
await Factory.safeDeinit(newApp)
},
).timeout(80000)
it('importing data belonging to another account should not result in duplication', async function () {
/** Create primary account and export data */
@@ -801,7 +806,7 @@ describe('online conflict handling', function () {
await createSyncedNoteWithTag(this.application)
const tag = this.application.items.getDisplayableTags()[0]
const note2 = await Factory.createMappedNote(this.application)
await this.application.changeAndSaveItem(tag, (mutator) => {
await this.application.changeAndSaveItem.execute(tag, (mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(note2)
})
let backupFile = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
@@ -98,7 +98,7 @@ describe('offline syncing', () => {
this.expectedItemCount++
await this.application.sync.sync(syncOptions)
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
expect(this.application.noAccount()).to.equal(true)
expect(this.application.getUser()).to.not.be.ok
expect(this.application.sessions.isSignedIn()).to.equal(false)
expect(this.application.sessions.getUser()).to.not.be.ok
})
})
@@ -600,7 +600,7 @@ describe('online syncing', function () {
it('saving an item after sync should persist it with content property', async function () {
const note = await Factory.createMappedNote(this.application)
const text = Factory.randomString(10000)
await this.application.changeAndSaveItem(
await this.application.changeAndSaveItem.execute(
note,
(mutator) => {
mutator.text = text
@@ -1015,7 +1015,7 @@ describe('online syncing', function () {
it('deleting an item permanently should include it in PayloadEmitSource.PreSyncSave item change observer', async function () {
let conditionMet = false
this.application.streamItems([ContentType.TYPES.Note], async ({ removed, source }) => {
this.application.items.streamItems([ContentType.TYPES.Note], async ({ removed, source }) => {
if (source === PayloadEmitSource.PreSyncSave && removed.length === 1) {
conditionMet = true
}
@@ -437,11 +437,12 @@ describe('asymmetric messages', function () {
SharedVaultUserPermission.PERMISSIONS.Write,
)
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
await context.forceRefreshSession()
await contactContext.forceRefreshSession()
await context.changePassword('new password')
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
await contactContext.forceRefreshSession()
/**
* When resending keypair changed messages here, we expect that one of their previous messages will fail to decrypt.
@@ -453,6 +454,8 @@ describe('asymmetric messages', function () {
await context.changePassword('new password 2')
await contactContext.forceRefreshSession()
const messages = await contactContext.asymmetric.getInboundMessages()
if (messages.isFailed()) {
console.error(messages.getError())
@@ -462,7 +465,7 @@ describe('asymmetric messages', function () {
expect(messages.getValue().length).to.equal(2)
contactContext.unlockSyncing()
await contactContext.syncAndAwaitInviteProcessing()
await contactContext.syncAndAwaitInviteAndMessageProcessing()
const invites = contactContext.vaultInvites.getCachedPendingInviteRecords()
expect(invites.length).to.equal(1)
@@ -39,19 +39,19 @@ describe('keypair change', function () {
publicKeyChain.push(context.publicKey)
signingPublicKeyChain.push(context.signingPublicKey)
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
await contactContext.forceRefreshSession()
await context.changePassword('new_password-2')
publicKeyChain.push(context.publicKey)
signingPublicKeyChain.push(context.signingPublicKey)
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
await contactContext.forceRefreshSession()
await context.changePassword('new_password-3')
publicKeyChain.push(context.publicKey)
signingPublicKeyChain.push(context.signingPublicKey)
await contactContext.runAnyRequestToPreventRefreshTokenFromExpiring()
await contactContext.forceRefreshSession()
await context.changeNoteTitleAndSync(note, 'new title')
@@ -74,7 +74,7 @@ describe('keypair change', function () {
expect(receivedNote.signatureData.result.passes).to.be.true
await deinitContactContext()
}).timeout(Factory.ThirtySecondTimeout)
}).timeout(Factory.SixtySecondTimeout)
it('should not trust messages sent with previous key pair', async () => {
const { sharedVault, contactContext, deinitContactContext } =
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/snjs",
"version": "2.202.30",
"version": "2.202.34",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+18
View File
@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.29.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/ui-services
## [1.29.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/ui-services
## [1.29.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-06)
**Note:** Version bump only for package @standardnotes/ui-services
# [1.29.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-05)
### Features
* Added translucency effect to menus, dialogs and alerts. Can be turned off from Preferences > Appeareance ([#2387](https://github.com/standardnotes/app/issues/2387)) [skip e2e] ([ec309d6](https://github.com/standardnotes/app/commit/ec309d6fb54c6cbb28414d1fe9d6119db5943d9c))
## [1.28.27](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/ui-services

Some files were not shown because too many files have changed in this diff Show More