Compare commits

...
Author SHA1 Message Date
StandardNotes CI 4ca0e89fcd 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].4
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].5
 - @standardnotes/[email protected]
2023-08-07 21:41:33 +00:00
Mo b731c73cb2 chore: fix dependency events 2023-08-07 15:58:46 -05:00
Mo 3b531ce8bb tests: vault locking (#2394) 2023-08-07 15:27:06 -05:00
StandardNotes CI a9edf671b1 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-07 18:52:26 +00:00
Aman Harwara 9f50ad28b0 chore: vaults improvements 2023-08-07 23:40:33 +05:30
StandardNotes CI bff2fb624d chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].9
2023-08-07 17:34:55 +00:00
Mo 0f1c8ef030 chore: update tests 2023-08-07 11:53:00 -05:00
Aman Harwara 653af36363 chore: fix empty table nodes when copying from external sources in super 2023-08-07 22:06:13 +05:30
Karol Sójko 5b88deeddb chore: safe-guard UI on shared vault limit creation (#2392) 2023-08-07 17:53:56 +02:00
StandardNotes CI 022be7d792 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].8
2023-08-07 14:56:02 +00:00
Karol Sójko 695d37beaa chore: fix existing e2e test for shared vaults to consider limitations (#2393)
* chore: fix existing e2e test for shared vaults to consider limitations

* chore: add paid subscription on the multiple vaults test
2023-08-07 16:11:20 +02:00
StandardNotes CI b08cff4dc2 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].7
2023-08-07 13:49:57 +00:00
Aman Harwara 1585d6b8ca chore: vaults improvements 2023-08-07 18:39:04 +05:30
StandardNotes CI 0a51034b80 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].6
2023-08-07 12:56:50 +00:00
Aman Harwara e253da6333 chore: release [skip e2e] 2023-08-07 18:07:42 +05:30
Aman Harwara 8a029950ec chore: fix issue where tag could not be added to vault 2023-08-07 17:53:28 +05:30
StandardNotes CI f0b3d939c5 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-07 12:11:39 +00:00
Aman Harwara a87d3c71f3 chore: Fixed issue where app would not launch correctly when using AppImage on Linux 2023-08-07 16:54:24 +05:30
StandardNotes CI e4258a3e12 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
 - @standardnotes/[email protected].5
2023-08-07 10:52:11 +00:00
Aman Harwara e2215f9a1f chore: minor vaults ui improvements 2023-08-07 15:36:34 +05:30
Mo ee473fe34d chore: fix uuid generation for importers 2023-08-07 05:06:11 -05:00
Karol Sójko cedd8e1006 chore: add e2e tests covering invalidation of other sessions (#2385) 2023-08-07 05:01:04 -05:00
Karol Sójko 4b278c4193 chore: fix session modal to show session creation date instead of update date (#2390) 2023-08-07 11:44:53 +02:00
StandardNotes CI 52ef2a8a70 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].8
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].4
2023-08-06 21:04:39 +00:00
Mo 8655bdb5dd tests: fix memory leaks (#2389) 2023-08-06 15:23:31 -05:00
StandardNotes CI d59e1befff chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected].3
2023-08-06 19:40:57 +00:00
Aman Harwara a295b4f2f7 chore: fix style issues [skip e2e] 2023-08-07 00:54:00 +05:30
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
StandardNotes CI 3a0f929261 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-04 19:34:34 +00:00
Aman Harwara cf73edc524 chore: release [skip e2e] 2023-08-05 00:49:05 +05:30
Aman Harwara de778de951 chore: fix error when trying to change invalid super note to another note type 2023-08-05 00:48:29 +05:30
StandardNotes CI 89f91178f8 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-04 18:51:42 +00:00
Aman Harwara 7c959e7305 chore: fix alert dialogs [skip e2e] 2023-08-05 00:07:47 +05:30
StandardNotes CI 7205cf9bd6 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]
2023-08-04 15:11:54 +00:00
Mo 494436bdb6 refactor: key rotation (#2383) 2023-08-04 09:25:28 -05:00
StandardNotes CI a7f266bb68 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-04 13:30:52 +00:00
Karol Sójko c42a559955 chore: remove e2e tests that are invalid due to session invalidation upon password change (#2384)
* chore: remove e2e tests that are invalid due to session invalidation upon password change

* chore: move invalid session e2e tests to a skipped suite for revisiting
2023-08-04 15:02:31 +02:00
StandardNotes CI afc32121ee chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-04 11:26:54 +00:00
Aman Harwara 1abacff890 chore: fix blur issues on alert dialogs on chrome [skip e2e] 2023-08-04 16:37:28 +05:30
Aman Harwara fc500b08d2 chore: fix issue where popovers & modals are sometimes blurry on chrome 2023-08-04 16:22:14 +05:30
StandardNotes CI 0642b589ff chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-03 19:48:59 +00:00
Aman Harwara f7a1c6ea65 fix: Fixed issue where moving the floating keyboard on iPad would lead to blank space on screen 2023-08-04 00:30:12 +05:30
StandardNotes CI e8c7c10358 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]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-03 14:42:10 +00:00
Aman Harwara b3eab998f9 chore: fix colors 2023-08-03 19:17:47 +05:30
Aman Harwara c76ffc764b clipper: handle clipped note sync in background (#2367) 2023-08-03 18:43:04 +05:30
Aman Harwara 5602a4014e chore: improve super formatting toolbar contrast 2023-08-03 18:24:50 +05:30
StandardNotes CI 0a544e936c 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]
 - @standardnotes/[email protected]
2023-08-03 12:13:07 +00:00
Karol Sójko 027dd41147 fix: exit interview discount link not working (#2381) 2023-08-03 13:28:27 +02:00
StandardNotes CI 2036689dd6 chore(release): publish
- @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-02 19:14:59 +00:00
Mo 25596e70a8 refactor: test 2023-08-02 13:27:13 -05:00
Mo 9961f83246 chore: vault tests on (#2380) 2023-08-02 11:02:04 -05:00
StandardNotes CI 6caf7c959a 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]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
 - @standardnotes/[email protected]
2023-08-02 13:01:51 +00:00
Mo 8ebb0949f7 chore: skip test 2023-08-02 07:28:50 -05:00
Mo 846e5b3ca8 chore: password tests 2023-08-02 06:54:18 -05:00
Mo 4b6bd452f7 chore: test skip 2023-08-01 20:46:14 -05:00
Mo 66d26ff44b chore: test timeout 2023-08-01 18:38:40 -05:00
Karol Sójko 247daddf5a chore: vault tests refactors and lint (#2374) 2023-08-01 17:23:56 -05:00
Mo a0bc1d2488 chore: readme [no ci] 2023-08-01 16:53:53 -05:00
562 changed files with 13670 additions and 10517 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ Questions? Find answers on our [Help page](https://standardnotes.com/help).
### Docker setup
Docker is the quickest way to try out Standard Notes. We recommend using our official [Docker hub image](https://hub.docker.com/repository/docker/standardnotes/web).
If you'd like to self-host the web application, we recommend using our official [Docker hub image](https://hub.docker.com/repository/docker/standardnotes/web).
```
docker run -d -p 3001:3001 --env-file=.env.sample standardnotes/web:stable
+1
View File
@@ -27,6 +27,7 @@
"build:services": "yarn workspaces foreach -pt --topological-dev --verbose -R --from @standardnotes/services run build",
"build:api": "yarn workspaces foreach -pt --topological-dev --verbose -R --from @standardnotes/api run build",
"e2e": "lerna run start:test-server --scope=@standardnotes/snjs",
"e2e:test": "yarn dlx mocha-headless-chrome --timeout 1800000 -f http://localhost:9001/mocha/test.html",
"reset": "find . -type dir -name node_modules | xargs rm -rf && rm -rf yarn.lock && yarn install",
"release:prod": "lerna version --conventional-commits --yes -m \"chore(release): publish\"",
"publish:prod": "lerna publish from-git --yes --no-verify-access --loglevel verbose",
+34
View File
@@ -3,6 +3,40 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.26.45](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/api
## [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.26.39](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
### Bug Fixes
* exit interview discount link not working ([#2381](https://github.com/standardnotes/app/issues/2381)) ([027dd41](https://github.com/standardnotes/app/commit/027dd4114720d46cccf215a71c04b67f91315ddc))
## [1.26.38](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/api
## [1.26.37](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/api
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api",
"version": "1.26.37",
"version": "1.26.45",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -58,7 +58,7 @@ export class UserApiService implements UserApiServiceInterface {
return response
} catch (error) {
throw new ApiCallError(ErrorMessage.GenericRegistrationFail)
throw new ApiCallError(ErrorMessage.GenericFail)
}
}
@@ -4,12 +4,14 @@ import { FetchRequestHandler } from './FetchRequestHandler'
import { HttpErrorResponseBody, HttpRequest } from '@standardnotes/responses'
import { ErrorMessage } from '../Error'
import { LoggerInterface } from '@standardnotes/utils'
describe('FetchRequestHandler', () => {
const snjsVersion = 'snjsVersion'
const appVersion = 'appVersion'
const environment = Environment.Web
const requestHandler = new FetchRequestHandler(snjsVersion, appVersion, environment)
const logger: LoggerInterface = {} as jest.Mocked<LoggerInterface>
const requestHandler = new FetchRequestHandler(snjsVersion, appVersion, environment, logger)
it('should create a request', () => {
const httpRequest: HttpRequest = {
@@ -11,12 +11,14 @@ import { RequestHandlerInterface } from './RequestHandlerInterface'
import { Environment } from '@standardnotes/models'
import { isString } from 'lodash'
import { ErrorMessage } from '../Error'
import { LoggerInterface } from '@standardnotes/utils'
export class FetchRequestHandler implements RequestHandlerInterface {
constructor(
protected readonly snjsVersion: string,
protected readonly appVersion: string,
protected readonly environment: Environment,
private logger: LoggerInterface,
) {}
async handleRequest<T>(httpRequest: HttpRequest): Promise<HttpResponse<T>> {
@@ -122,7 +124,7 @@ export class FetchRequestHandler implements RequestHandlerInterface {
}
}
} catch (error) {
console.error(error)
this.logger.error(JSON.stringify(error))
}
if (httpStatus >= HttpStatusCode.Success && httpStatus < HttpStatusCode.InternalServerError) {
+9 -3
View File
@@ -1,4 +1,4 @@
import { joinPaths, sleep } from '@standardnotes/utils'
import { LoggerInterface, joinPaths, sleep } from '@standardnotes/utils'
import { Environment } from '@standardnotes/models'
import { LegacySession, Session, SessionToken } from '@standardnotes/domain-core'
import {
@@ -21,6 +21,7 @@ export class HttpService implements HttpServiceInterface {
private session?: Session | LegacySession
private __latencySimulatorMs?: number
private declare host: string
loggingEnabled = false
private inProgressRefreshSessionPromise?: Promise<boolean>
private updateMetaCallback!: (meta: HttpResponseMeta) => void
@@ -32,8 +33,9 @@ export class HttpService implements HttpServiceInterface {
private environment: Environment,
private appVersion: string,
private snjsVersion: string,
private logger: LoggerInterface,
) {
this.requestHandler = new FetchRequestHandler(this.snjsVersion, this.appVersion, this.environment)
this.requestHandler = new FetchRequestHandler(this.snjsVersion, this.appVersion, this.environment, this.logger)
}
setCallbacks(
@@ -150,6 +152,10 @@ export class HttpService implements HttpServiceInterface {
const response = await this.requestHandler.handleRequest<T>(httpRequest)
if (this.loggingEnabled && isErrorResponse(response)) {
this.logger.error('Request failed', httpRequest, response)
}
if (response.meta && !httpRequest.external) {
this.updateMetaCallback?.(response.meta)
}
@@ -175,7 +181,7 @@ export class HttpService implements HttpServiceInterface {
return response
}
private async refreshSession(): Promise<boolean> {
async refreshSession(): Promise<boolean> {
if (!this.session) {
return false
}
@@ -14,6 +14,7 @@ export interface HttpServiceInterface {
runHttp<T>(httpRequest: HttpRequest): Promise<HttpResponse<T>>
setSession(session: Session | LegacySession): void
refreshSession(): Promise<boolean>
setCallbacks(
updateMetaCallback: (meta: HttpResponseMeta) => void,
refreshSessionCallback: (session: Session) => void,
+1
View File
@@ -1,3 +1,4 @@
export * from './HttpService'
export * from './FetchRequestHandler'
export * from './HttpServiceInterface'
export * from './XMLHttpRequestState'
+92
View File
@@ -3,6 +3,98 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.153](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.152](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.151](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.150](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.149](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.148](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.147](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.146](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.145](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.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.139](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.138](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.137](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.136](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.135](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.134](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.133](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.132](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.131](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/clipper
## [1.1.130](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**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.130",
"version": "1.1.153",
"private": true,
"scripts": {
"build-mv2": "yarn clean && webpack --config ./webpack.config.prod.js",
@@ -1,5 +1,7 @@
import { runtime, action, browserAction, windows, storage, tabs } from 'webextension-polyfill'
import { ClipPayload, RuntimeMessage, RuntimeMessageTypes } from '../types/message'
import { Environment, FetchRequestHandler, Logger, SnjsVersion } from '@standardnotes/snjs'
import packageInfo from '../../package.json'
const isFirefox = navigator.userAgent.indexOf('Firefox/') !== -1
@@ -22,6 +24,9 @@ const openPopupAndClipSelection = async (payload: ClipPayload) => {
void openPopup()
}
const logger = new Logger('clipper')
const requestHandler = new FetchRequestHandler(SnjsVersion, packageInfo.version, Environment.Clipper, logger)
runtime.onMessage.addListener(async (message: RuntimeMessage) => {
if (message.type === RuntimeMessageTypes.OpenPopupWithSelection) {
if (!message.payload) {
@@ -32,5 +37,7 @@ runtime.onMessage.addListener(async (message: RuntimeMessage) => {
return await tabs.captureVisibleTab(undefined, {
format: 'png',
})
} else if (message.type === RuntimeMessageTypes.RunHttpRequest) {
requestHandler.handleRequest(message.payload).catch(console.error)
}
})
+14 -1
View File
@@ -1,3 +1,5 @@
import { HttpRequest } from '@standardnotes/snjs'
export const RuntimeMessageTypes = {
GetArticle: 'get-article',
GetSelection: 'get-selection',
@@ -7,6 +9,7 @@ export const RuntimeMessageTypes = {
StartNodeSelection: 'start-node-selection',
ToggleScreenshotMode: 'toggle-screenshot-mode',
CaptureVisibleTab: 'capture-visible-tab',
RunHttpRequest: 'run-http-request',
} as const
export type RuntimeMessageType = (typeof RuntimeMessageTypes)[keyof typeof RuntimeMessageTypes]
@@ -29,6 +32,7 @@ export type RuntimeMessageReturnTypes = {
[RuntimeMessageTypes.OpenPopupWithSelection]: void
[RuntimeMessageTypes.StartNodeSelection]: void
[RuntimeMessageTypes.ToggleScreenshotMode]: void
[RuntimeMessageTypes.RunHttpRequest]: void
}
export type RuntimeMessage =
@@ -36,10 +40,19 @@ export type RuntimeMessage =
type: MessagesWithClipPayload
payload: ClipPayload
}
| {
type: typeof RuntimeMessageTypes.RunHttpRequest
payload: HttpRequest
}
| {
type: typeof RuntimeMessageTypes.ToggleScreenshotMode
enabled: boolean
}
| {
type: Exclude<RuntimeMessageType, MessagesWithClipPayload | typeof RuntimeMessageTypes.ToggleScreenshotMode>
type: Exclude<
RuntimeMessageType,
| MessagesWithClipPayload
| typeof RuntimeMessageTypes.ToggleScreenshotMode
| typeof RuntimeMessageTypes.RunHttpRequest
>
}
+96
View File
@@ -3,6 +3,102 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.108.85](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.84](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.83](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.82](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.81](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.80](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.79](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.78](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.77](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.76](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.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
## [3.108.70](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.69](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.68](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.67](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.66](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.65](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.64](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.63](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.62](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/desktop
## [3.108.61](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/desktop
@@ -6,7 +6,9 @@ export function initializeZoomManager(window: BrowserWindow, store: Store): void
window.webContents.on('dom-ready', () => {
const zoomFactor = store.get(StoreKeys.ZoomFactor)
if (zoomFactor) {
window.webContents.zoomFactor = zoomFactor
window.once('ready-to-show', () => {
window.webContents.zoomFactor = zoomFactor
})
}
})
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@standardnotes/desktop",
"main": "./app/dist/index.js",
"version": "3.108.61",
"version": "3.108.85",
"license": "CC BY-NC-SA 4.0",
"author": "Standard Notes.",
"private": true,
+28
View File
@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.21.67](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/encryption
## [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.21.61](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/encryption
## [1.21.60](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/encryption
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/encryption",
"version": "1.21.60",
"version": "1.21.67",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+28
View File
@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.28.77](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/filepicker
## [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.28.71](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/filepicker
## [1.28.70](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/filepicker
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/filepicker",
"version": "1.28.70",
"version": "1.28.77",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+28
View File
@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.23](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/files
## [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.16.17](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/files
## [1.16.16](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/files
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files",
"version": "1.16.16",
"version": "1.16.23",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
-5
View File
@@ -1,5 +0,0 @@
recursive: true
timeout: 120000
bail: true
file:
- e2e/init.js
+94
View File
@@ -3,6 +3,100 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.56.64](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.63](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.62](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.61](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.60](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.59](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.58](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.57](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.56](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.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
## [3.56.50](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.49](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.48](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.47](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.46](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
### Bug Fixes
* Fixed issue where moving the floating keyboard on iPad would lead to blank space on screen ([f7a1c6e](https://github.com/standardnotes/app/commit/f7a1c6ea65201af80ca6859c0e83c5b49c94e11d))
## [3.56.45](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.44](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.43](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.42](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/mobile
## [3.56.41](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**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.41",
"version": "3.56.64",
"author": "Standard Notes.",
"private": true,
"license": "CC BY-NC-SA 4.0",
@@ -2,7 +2,7 @@
import { ApplicationEvent, ReactNativeToWebEvent } from '@standardnotes/snjs'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Button, Keyboard, Platform, Text, View } from 'react-native'
import { Button, Dimensions, Keyboard, Platform, Text, View } from 'react-native'
import VersionInfo from 'react-native-version-info'
import { WebView, WebViewMessageEvent } from 'react-native-webview'
import { OnShouldStartLoadWithRequest } from 'react-native-webview/lib/WebViewTypes'
@@ -84,7 +84,11 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
JSON.stringify({
reactNativeEvent: ReactNativeToWebEvent.KeyboardFrameWillChange,
messageType: 'event',
messageData: { height: e.endCoordinates.height, contentHeight: e.endCoordinates.screenY },
messageData: {
height: e.endCoordinates.height,
contentHeight: e.endCoordinates.screenY,
isFloatingKeyboard: e.endCoordinates.width !== Dimensions.get('window').width,
},
}),
)
})
+30
View File
@@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.47.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/models
## [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.46.20](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/models
## [1.46.19](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/models
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/models",
"version": "1.46.19",
"version": "1.47.4",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -28,6 +28,7 @@ export enum PayloadEmitSource {
RemoteRetrieved,
RemoteSaved,
DesktopComponentSync,
}
/**
@@ -2,4 +2,5 @@ export enum Environment {
Web = 1,
Desktop = 2,
Mobile = 3,
Clipper = 4,
}
@@ -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[] = []
@@ -52,4 +52,8 @@ export class KeySystemRootKey extends DecryptedItem<KeySystemRootKeyContent> imp
override get shared_vault_uuid(): undefined {
return undefined
}
isEqual(other: KeySystemRootKeyInterface): boolean {
return this.itemsKey === other.itemsKey && this.token === other.token
}
}
@@ -35,4 +35,6 @@ export interface KeySystemRootKeyInterface extends DecryptedItemInterface<KeySys
*/
get key_system_identifier(): undefined
get shared_vault_uuid(): undefined
isEqual(other: KeySystemRootKeyInterface): boolean
}
@@ -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'
+96
View File
@@ -3,6 +3,102 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.437](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.436](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.435](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.434](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.433](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.432](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.431](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.430](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.429](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.428](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.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.4.422](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.421](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.420](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.419](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-04)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.418](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.417](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.416](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.415](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.414](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/releases
## [1.4.413](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/releases
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/releases",
"version": "1.4.413",
"version": "1.4.437",
"license": "CC BY-NC-SA 4.0",
"main": "dist/releases.json",
"types": "dist/index.d.ts",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.13.36](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/responses
## [1.13.35](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
**Note:** Version bump only for package @standardnotes/responses
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/responses",
"version": "1.13.35",
"version": "1.13.36",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -3,7 +3,7 @@ import { ApiEndpointParam } from './ApiEndpointParam'
import { ConflictParams } from './ConflictParams'
import { ServerItemResponse } from './ServerItemResponse'
import { SharedVaultServerHash } from '../SharedVaults/SharedVaultServerHash'
import { UserEventServerHash } from '../UserEvent/UserEventServerHash'
import { NotificationServerHash } from '../Notification/NotificationServerHash'
import { AsymmetricMessageServerHash } from '../AsymmetricMessage/AsymmetricMessageServerHash'
export type RawSyncData = {
@@ -16,7 +16,7 @@ export type RawSyncData = {
unsaved?: ConflictParams[]
shared_vaults?: SharedVaultServerHash[]
shared_vault_invites?: SharedVaultInviteServerHash[]
notifications?: UserEventServerHash[]
notifications?: NotificationServerHash[]
messages?: AsymmetricMessageServerHash[]
status?: number
}
@@ -1,4 +1,4 @@
export type UserEventServerHash = {
export type NotificationServerHash = {
uuid: string
user_uuid: string
type: string
+1 -1
View File
@@ -66,4 +66,4 @@ export * from './User/PostSubscriptionTokensResponse'
export * from './User/SettingData'
export * from './User/UpdateSettingResponse'
export * from './UserEvent/UserEventServerHash'
export * from './Notification/NotificationServerHash'
+40
View File
@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.63.29](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/services
## [1.63.28](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-07)
**Note:** Version bump only for package @standardnotes/services
## [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.63.22](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/services
## [1.63.21](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-03)
**Note:** Version bump only for package @standardnotes/services
## [1.63.20](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-02)
**Note:** Version bump only for package @standardnotes/services
## [1.63.19](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-01)
### Bug Fixes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/services",
"version": "1.63.19",
"version": "1.63.29",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -2,18 +2,30 @@ import { FilesApiInterface } from '@standardnotes/files'
import { AbstractService } from '../Service/AbstractService'
import { ApiServiceEvent } from './ApiServiceEvent'
import { ApiServiceEventData } from './ApiServiceEventData'
import { SNFeatureRepo } from '@standardnotes/models'
import { ClientDisplayableError, HttpResponse } from '@standardnotes/responses'
import { SNFeatureRepo, ServerSyncPushContextualPayload } from '@standardnotes/models'
import { ClientDisplayableError, HttpRequest, HttpResponse } from '@standardnotes/responses'
import { AnyFeatureDescription } from '@standardnotes/features'
export interface LegacyApiServiceInterface
extends AbstractService<ApiServiceEvent, ApiServiceEventData>,
FilesApiInterface {
isThirdPartyHostUsed(): boolean
setHost(host: string): Promise<void>
getHost(): string
downloadOfflineFeaturesFromRepo(
repo: SNFeatureRepo,
): Promise<{ features: AnyFeatureDescription[]; roles: string[] } | ClientDisplayableError>
downloadFeatureUrl(url: string): Promise<HttpResponse>
getSyncHttpRequest(
payloads: ServerSyncPushContextualPayload[],
lastSyncToken: string | undefined,
paginationToken: string | undefined,
limit: number,
sharedVaultUuids?: string[],
): HttpRequest
getNewSubscriptionToken(): Promise<string | undefined>
}
@@ -1,24 +1,28 @@
import { VaultUserServiceInterface, VaultInviteServiceInterface } from '@standardnotes/services'
import {
VaultUserServiceInterface,
VaultInviteServiceInterface,
StorageServiceInterface,
SyncServiceInterface,
FullyResolvedApplicationOptions,
ProtectionsClientInterface,
ChangeAndSaveItem,
GetHost,
SetHost,
LegacyApiServiceInterface,
StatusServiceInterface,
MfaServiceInterface,
GenerateUuid,
} 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'
@@ -34,10 +38,9 @@ import { StorageValueModes } from '../Storage/StorageTypes'
import { DeinitMode } from './DeinitMode'
import { DeinitSource } from './DeinitSource'
import { UserClientInterface } from '../User/UserClientInterface'
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 +56,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
@@ -108,17 +86,26 @@ export interface ApplicationInterface {
get files(): FilesClientInterface
get history(): HistoryServiceInterface
get homeServer(): HomeServerServiceInterface | undefined
get generateUuid(): GenerateUuid
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 user(): UserClientInterface
get vaults(): VaultServiceInterface
get vaultLocks(): VaultLockServiceInterface
get vaultUsers(): VaultUserServiceInterface
get sync(): SyncServiceInterface
get user(): UserServiceInterface
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
@@ -1,3 +1,4 @@
import { GetKeyPairs } from './../Encryption/UseCase/GetKeyPairs'
import { GetVault } from './../Vault/UseCase/GetVault'
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
@@ -25,6 +26,7 @@ import {
KeySystemRootKeyContentSpecialized,
TrustedContactInterface,
} from '@standardnotes/models'
import { Result } from '@standardnotes/domain-core'
describe('AsymmetricMessageService', () => {
let sync: jest.Mocked<SyncServiceInterface>
@@ -47,6 +49,7 @@ describe('AsymmetricMessageService', () => {
const getOutboundMessagesUseCase = {} as jest.Mocked<GetOutboundMessages>
const getInboundMessagesUseCase = {} as jest.Mocked<GetInboundMessages>
const getUntrustedPayload = {} as jest.Mocked<GetUntrustedPayload>
const getKeyPairs = {} as jest.Mocked<GetKeyPairs>
sync = {} as jest.Mocked<SyncServiceInterface>
sync.sync = jest.fn()
@@ -61,6 +64,7 @@ describe('AsymmetricMessageService', () => {
encryption,
mutator,
sessions,
sync,
messageServer,
createOrEditContact,
findContact,
@@ -71,6 +75,7 @@ describe('AsymmetricMessageService', () => {
getOutboundMessagesUseCase,
getInboundMessagesUseCase,
getUntrustedPayload,
getKeyPairs,
eventBus,
)
})
@@ -115,6 +120,45 @@ describe('AsymmetricMessageService', () => {
})
})
describe('handleTrustedMessageResult', () => {
it('should not double handle the same message', async () => {
/**
* Because message retrieval is based on a syncToken, and the server aligns syncTokens to items sent back
* rather than messages, we may receive the same message twice. We want to keep track of processed messages
* and avoid double processing.
*/
const message: AsymmetricMessageServerHash = {
uuid: 'message',
recipient_uuid: '1',
sender_uuid: '2',
encrypted_message: 'encrypted_message',
created_at_timestamp: 2,
updated_at_timestamp: 2,
}
const decryptedMessagePayload: AsymmetricMessageTrustedContactShare = {
type: AsymmetricMessagePayloadType.ContactShare,
data: {
recipientUuid: '1',
trustedContact: {} as TrustedContactInterface,
},
}
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(Result.ok(decryptedMessagePayload))
service.handleTrustedContactShareMessage = jest.fn()
await service.handleTrustedMessageResult(message, decryptedMessagePayload)
expect(service.handleTrustedContactShareMessage).toHaveBeenCalledTimes(1)
service.handleTrustedContactShareMessage = jest.fn()
await service.handleTrustedMessageResult(message, decryptedMessagePayload)
expect(service.handleTrustedContactShareMessage).toHaveBeenCalledTimes(0)
})
})
it('should process incoming messages oldest first', async () => {
const messages: AsymmetricMessageServerHash[] = [
{
@@ -139,7 +183,7 @@ describe('AsymmetricMessageService', () => {
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(trustedPayloadMock)
.mockReturnValue(Result.ok(trustedPayloadMock))
const handleTrustedContactShareMessageMock = jest.fn()
service.handleTrustedContactShareMessage = handleTrustedContactShareMessageMock
@@ -171,7 +215,7 @@ describe('AsymmetricMessageService', () => {
service.handleTrustedContactShareMessage = jest.fn()
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await service.handleRemoteReceivedAsymmetricMessages([message])
@@ -200,7 +244,7 @@ describe('AsymmetricMessageService', () => {
service.handleTrustedSenderKeypairChangedMessage = jest.fn()
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await service.handleRemoteReceivedAsymmetricMessages([message])
@@ -228,7 +272,7 @@ describe('AsymmetricMessageService', () => {
service.handleTrustedSharedVaultRootKeyChangedMessage = jest.fn()
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await service.handleRemoteReceivedAsymmetricMessages([message])
@@ -258,7 +302,7 @@ describe('AsymmetricMessageService', () => {
service.handleTrustedVaultMetadataChangedMessage = jest.fn()
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await service.handleRemoteReceivedAsymmetricMessages([message])
@@ -284,7 +328,7 @@ describe('AsymmetricMessageService', () => {
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await expect(service.handleRemoteReceivedAsymmetricMessages([message])).rejects.toThrow(
'Shared vault invites payloads are not handled as part of asymmetric messages',
@@ -313,7 +357,7 @@ describe('AsymmetricMessageService', () => {
service.handleTrustedContactShareMessage = jest.fn()
service.getTrustedMessagePayload = service.getUntrustedMessagePayload = jest
.fn()
.mockReturnValue(decryptedMessagePayload)
.mockReturnValue(Result.ok(decryptedMessagePayload))
await service.handleRemoteReceivedAsymmetricMessages([message])
@@ -1,6 +1,8 @@
import { GetKeyPairs } from './../Encryption/UseCase/GetKeyPairs'
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
import { AsymmetricMessageServerHash, ClientDisplayableError, isClientDisplayableError } from '@standardnotes/responses'
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
import { SyncEvent, SyncEventReceivedAsymmetricMessagesData } from '../Event/SyncEvent'
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { InternalEventHandlerInterface } from '../Internal/InternalEventHandlerInterface'
@@ -20,7 +22,6 @@ import {
VaultListingInterface,
} from '@standardnotes/models'
import { HandleRootKeyChangedMessage } from './UseCase/HandleRootKeyChangedMessage'
import { SessionEvent } from '../Session/SessionEvent'
import { AsymmetricMessageServer } from '@standardnotes/api'
import { GetOutboundMessages } from './UseCase/GetOutboundMessages'
import { GetInboundMessages } from './UseCase/GetInboundMessages'
@@ -31,15 +32,19 @@ import { FindContact } from '../Contacts/UseCase/FindContact'
import { CreateOrEditContact } from '../Contacts/UseCase/CreateOrEditContact'
import { ReplaceContactData } from '../Contacts/UseCase/ReplaceContactData'
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
import { Result } from '@standardnotes/domain-core'
export class AsymmetricMessageService
extends AbstractService
implements AsymmetricMessageServiceInterface, InternalEventHandlerInterface
{
private handledMessages = new Set<string>()
constructor(
private encryption: EncryptionProviderInterface,
private mutator: MutatorClientInterface,
private sessions: SessionsClientInterface,
private sync: SyncServiceInterface,
private messageServer: AsymmetricMessageServer,
private _createOrEditContact: CreateOrEditContact,
private _findContact: FindContact,
@@ -50,6 +55,7 @@ export class AsymmetricMessageService
private _getOutboundMessagesUseCase: GetOutboundMessages,
private _getInboundMessagesUseCase: GetInboundMessages,
private _getUntrustedPayload: GetUntrustedPayload,
private _getKeyPairs: GetKeyPairs,
eventBus: InternalEventBusInterface,
) {
super(eventBus)
@@ -73,30 +79,27 @@ export class AsymmetricMessageService
async handleEvent(event: InternalEventInterface): Promise<void> {
switch (event.type) {
case SessionEvent.UserKeyPairChanged:
void this.messageServer.deleteAllInboundMessages()
break
case SyncEvent.ReceivedAsymmetricMessages:
void this.handleRemoteReceivedAsymmetricMessages(event.payload as SyncEventReceivedAsymmetricMessagesData)
break
}
}
public async getOutboundMessages(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError> {
public async getOutboundMessages(): Promise<Result<AsymmetricMessageServerHash[]>> {
return this._getOutboundMessagesUseCase.execute()
}
public async getInboundMessages(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError> {
public async getInboundMessages(): Promise<Result<AsymmetricMessageServerHash[]>> {
return this._getInboundMessagesUseCase.execute()
}
public async downloadAndProcessInboundMessages(): Promise<void> {
const messages = await this.getInboundMessages()
if (isClientDisplayableError(messages)) {
if (messages.isFailed()) {
return
}
await this.handleRemoteReceivedAsymmetricMessages(messages)
await this.handleRemoteReceivedAsymmetricMessages(messages.getValue())
}
sortServerMessages(messages: AsymmetricMessageServerHash[]): AsymmetricMessageServerHash[] {
@@ -143,11 +146,11 @@ export class AsymmetricMessageService
getServerMessageType(message: AsymmetricMessageServerHash): AsymmetricMessagePayloadType | undefined {
const result = this.getUntrustedMessagePayload(message)
if (!result) {
if (result.isFailed()) {
return undefined
}
return result.type
return result.getValue().type
}
async handleRemoteReceivedAsymmetricMessages(messages: AsymmetricMessageServerHash[]): Promise<void> {
@@ -159,18 +162,26 @@ export class AsymmetricMessageService
for (const message of sortedMessages) {
const trustedPayload = this.getTrustedMessagePayload(message)
if (!trustedPayload) {
if (trustedPayload.isFailed()) {
continue
}
await this.handleTrustedMessageResult(message, trustedPayload)
await this.handleTrustedMessageResult(message, trustedPayload.getValue())
}
void this.sync.sync()
}
private async handleTrustedMessageResult(
async handleTrustedMessageResult(
message: AsymmetricMessageServerHash,
payload: AsymmetricMessagePayload,
): Promise<void> {
if (this.handledMessages.has(message.uuid)) {
return
}
this.handledMessages.add(message.uuid)
if (payload.type === AsymmetricMessagePayloadType.ContactShare) {
await this.handleTrustedContactShareMessage(message, payload)
} else if (payload.type === AsymmetricMessagePayloadType.SenderKeypairChanged) {
@@ -186,37 +197,47 @@ export class AsymmetricMessageService
await this.deleteMessageAfterProcessing(message)
}
getUntrustedMessagePayload(message: AsymmetricMessageServerHash): AsymmetricMessagePayload | undefined {
getUntrustedMessagePayload(message: AsymmetricMessageServerHash): Result<AsymmetricMessagePayload> {
const keys = this._getKeyPairs.execute()
if (keys.isFailed()) {
return Result.fail(keys.getError())
}
const result = this._getUntrustedPayload.execute({
privateKey: this.encryption.getKeyPair().privateKey,
privateKey: keys.getValue().encryption.privateKey,
message,
})
if (result.isFailed()) {
return undefined
return Result.fail(result.getError())
}
return result.getValue()
return result
}
getTrustedMessagePayload(message: AsymmetricMessageServerHash): AsymmetricMessagePayload | undefined {
getTrustedMessagePayload(message: AsymmetricMessageServerHash): Result<AsymmetricMessagePayload> {
const contact = this._findContact.execute({ userUuid: message.sender_uuid })
if (contact.isFailed()) {
return undefined
return Result.fail(contact.getError())
}
const keys = this._getKeyPairs.execute()
if (keys.isFailed()) {
return Result.fail(keys.getError())
}
const result = this._getTrustedPayload.execute({
privateKey: this.encryption.getKeyPair().privateKey,
privateKey: keys.getValue().encryption.privateKey,
sender: contact.getValue(),
ownUserUuid: this.sessions.userUuid,
message,
})
if (result.isFailed()) {
return undefined
return Result.fail(result.getError())
}
return result.getValue()
return result
}
async deleteMessageAfterProcessing(message: AsymmetricMessageServerHash): Promise<void> {
@@ -1,7 +1,8 @@
import { AsymmetricMessageServerHash, ClientDisplayableError } from '@standardnotes/responses'
import { Result } from '@standardnotes/domain-core'
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
export interface AsymmetricMessageServiceInterface {
getOutboundMessages(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError>
getInboundMessages(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError>
getOutboundMessages(): Promise<Result<AsymmetricMessageServerHash[]>>
getInboundMessages(): Promise<Result<AsymmetricMessageServerHash[]>>
downloadAndProcessInboundMessages(): Promise<void>
}
@@ -1,16 +1,17 @@
import { ClientDisplayableError, isErrorResponse, AsymmetricMessageServerHash } from '@standardnotes/responses'
import { isErrorResponse, AsymmetricMessageServerHash, getErrorFromErrorResponse } from '@standardnotes/responses'
import { AsymmetricMessageServerInterface } from '@standardnotes/api'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
export class GetInboundMessages {
export class GetInboundMessages implements UseCaseInterface<AsymmetricMessageServerHash[]> {
constructor(private messageServer: AsymmetricMessageServerInterface) {}
async execute(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError> {
async execute(): Promise<Result<AsymmetricMessageServerHash[]>> {
const response = await this.messageServer.getMessages()
if (isErrorResponse(response)) {
return ClientDisplayableError.FromNetworkError(response)
return Result.fail(getErrorFromErrorResponse(response).message)
}
return response.data.messages
return Result.ok(response.data.messages)
}
}
@@ -1,16 +1,17 @@
import { ClientDisplayableError, isErrorResponse, AsymmetricMessageServerHash } from '@standardnotes/responses'
import { isErrorResponse, AsymmetricMessageServerHash, getErrorFromErrorResponse } from '@standardnotes/responses'
import { AsymmetricMessageServerInterface } from '@standardnotes/api'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
export class GetOutboundMessages {
export class GetOutboundMessages implements UseCaseInterface<AsymmetricMessageServerHash[]> {
constructor(private messageServer: AsymmetricMessageServerInterface) {}
async execute(): Promise<AsymmetricMessageServerHash[] | ClientDisplayableError> {
async execute(): Promise<Result<AsymmetricMessageServerHash[]>> {
const response = await this.messageServer.getOutboundUserMessages()
if (isErrorResponse(response)) {
return ClientDisplayableError.FromNetworkError(response)
return Result.fail(getErrorFromErrorResponse(response).message)
}
return response.data.messages
return Result.ok(response.data.messages)
}
}
@@ -11,14 +11,14 @@ import {
import { ContentType } from '@standardnotes/domain-core'
import { GetVault } from '../../Vault/UseCase/GetVault'
import { EncryptionProviderInterface } from '../../Encryption/EncryptionProviderInterface'
import { DecryptErroredPayloads } from '../../Encryption/UseCase/DecryptErroredPayloads'
export class HandleRootKeyChangedMessage {
constructor(
private mutator: MutatorClientInterface,
private sync: SyncServiceInterface,
private encryption: EncryptionProviderInterface,
private getVault: GetVault,
private _getVault: GetVault,
private _decryptErroredPayloads: DecryptErroredPayloads,
) {}
async execute(message: AsymmetricMessageSharedVaultRootKeyChanged): Promise<void> {
@@ -30,14 +30,16 @@ export class HandleRootKeyChangedMessage {
true,
)
const vault = this.getVault.execute<VaultListingInterface>({ keySystemIdentifier: rootKeyContent.systemIdentifier })
const vault = this._getVault.execute<VaultListingInterface>({
keySystemIdentifier: rootKeyContent.systemIdentifier,
})
if (!vault.isFailed()) {
await this.mutator.changeItem<VaultListingMutator>(vault.getValue(), (mutator) => {
mutator.rootKeyParams = rootKeyContent.keyParams
})
}
await this.encryption.decryptErroredPayloads()
await this._decryptErroredPayloads.execute()
void this.sync.sync({ sourceDescription: 'Not awaiting due to this event handler running from sync response' })
}
@@ -16,13 +16,13 @@ export class ProcessAcceptedVaultInvite {
constructor(
private mutator: MutatorClientInterface,
private sync: SyncServiceInterface,
private createOrEditContact: CreateOrEditContact,
private _createOrEditContact: CreateOrEditContact,
) {}
async execute(
message: AsymmetricMessageSharedVaultInvite,
sharedVaultUuid: string,
senderUuid: string,
ownerUuid: string,
): Promise<void> {
const { rootKey: rootKeyContent, trustedContacts, metadata } = message.data
@@ -34,7 +34,7 @@ export class ProcessAcceptedVaultInvite {
description: metadata.description,
sharing: {
sharedVaultUuid: sharedVaultUuid,
ownerUserUuid: senderUuid,
ownerUserUuid: ownerUuid,
},
}
@@ -47,7 +47,7 @@ export class ProcessAcceptedVaultInvite {
await this.mutator.createItem(ContentType.TYPES.VaultListing, FillItemContentSpecialized(content), true)
for (const contact of trustedContacts) {
await this.createOrEditContact.execute({
await this._createOrEditContact.execute({
name: contact.name,
contactUuid: contact.contactUuid,
publicKey: contact.publicKeySet.encryption,
@@ -0,0 +1,124 @@
import { ResendAllMessages } from './ResendAllMessages'
import { Result } from '@standardnotes/domain-core'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import { AsymmetricMessagePayloadType } from '@standardnotes/models'
describe('ResendAllMessages', () => {
let mockDecryptOwnMessage: any
let mockMessageServer: any
let mockResendMessage: any
let mockFindContact: any
let useCase: ResendAllMessages
let params: {
keys: { encryption: PkcKeyPair; signing: PkcKeyPair }
previousKeys?: { encryption: PkcKeyPair; signing: PkcKeyPair }
}
beforeEach(() => {
jest.clearAllMocks()
mockDecryptOwnMessage = {
execute: jest.fn(),
}
mockMessageServer = {
getOutboundUserMessages: jest.fn(),
deleteMessage: jest.fn(),
}
mockResendMessage = {
execute: jest.fn(),
}
mockFindContact = {
execute: jest.fn(),
}
useCase = new ResendAllMessages(mockResendMessage, mockDecryptOwnMessage, mockMessageServer, mockFindContact)
params = {
keys: {
encryption: { publicKey: 'new_public_key', privateKey: 'new_private_key' },
signing: { publicKey: 'new_public_key', privateKey: 'new_private_key' },
},
}
})
it('should successfully resend all messages', async () => {
const messages = {
data: { messages: [{ recipient_uuid: 'uuid', uuid: 'uuid', encrypted_message: 'encrypted_message' }] },
}
const recipient = { publicKeySet: { encryption: 'public_key' } }
const decryptedMessage = { type: AsymmetricMessagePayloadType.ContactShare }
mockMessageServer.getOutboundUserMessages.mockReturnValue(messages)
mockFindContact.execute.mockReturnValue(Result.ok(recipient))
mockDecryptOwnMessage.execute.mockReturnValue(Result.ok(decryptedMessage))
const result = await useCase.execute(params)
expect(result).toEqual(Result.ok())
expect(mockMessageServer.getOutboundUserMessages).toHaveBeenCalled()
expect(mockFindContact.execute).toHaveBeenCalled()
expect(mockDecryptOwnMessage.execute).toHaveBeenCalled()
expect(mockResendMessage.execute).toHaveBeenCalled()
expect(mockMessageServer.deleteMessage).toHaveBeenCalled()
})
it('should handle errors while getting outbound user messages', async () => {
mockMessageServer.getOutboundUserMessages.mockReturnValue({ data: { error: 'Error' } })
const result = await useCase.execute(params)
expect(result.isFailed()).toBeTruthy()
expect(result.getError()).toBe('Failed to get outbound user messages')
})
it('should handle errors while finding contact', async () => {
const messages = {
data: { messages: [{ recipient_uuid: 'uuid', uuid: 'uuid', encrypted_message: 'encrypted_message' }] },
}
mockMessageServer.getOutboundUserMessages.mockReturnValue(messages)
mockFindContact.execute.mockReturnValue(Result.fail('Contact not found'))
const result = await useCase.execute(params)
expect(result.isFailed()).toBeTruthy()
expect(result.getError()).toContain('Contact not found')
})
it('should skip messages of excluded types', async () => {
const messages = {
data: {
messages: [
{ recipient_uuid: 'uuid', uuid: 'uuid', encrypted_message: 'encrypted_message' },
{ recipient_uuid: 'uuid2', uuid: 'uuid2', encrypted_message: 'encrypted_message2' },
],
},
}
const recipient = { publicKeySet: { encryption: 'public_key' } }
const decryptedMessage1 = { type: AsymmetricMessagePayloadType.SenderKeypairChanged }
const decryptedMessage2 = { type: AsymmetricMessagePayloadType.ContactShare }
mockMessageServer.getOutboundUserMessages.mockReturnValue(messages)
mockFindContact.execute.mockReturnValue(Result.ok(recipient))
mockDecryptOwnMessage.execute
.mockReturnValueOnce(Result.ok(decryptedMessage1))
.mockReturnValueOnce(Result.ok(decryptedMessage2))
const result = await useCase.execute(params)
expect(result).toEqual(Result.ok())
expect(mockMessageServer.getOutboundUserMessages).toHaveBeenCalled()
expect(mockFindContact.execute).toHaveBeenCalledTimes(2)
expect(mockDecryptOwnMessage.execute).toHaveBeenCalledTimes(2)
expect(mockResendMessage.execute).toHaveBeenCalledTimes(1)
expect(mockMessageServer.deleteMessage).toHaveBeenCalledTimes(1)
expect(mockResendMessage.execute).toHaveBeenCalledWith(
expect.objectContaining({ rawMessage: messages.data.messages[1] }),
)
expect(mockMessageServer.deleteMessage).toHaveBeenCalledWith({ messageUuid: messages.data.messages[1].uuid })
})
})
@@ -1,17 +1,28 @@
import { DecryptOwnMessage } from './../../Encryption/UseCase/Asymmetric/DecryptOwnMessage'
import { AsymmetricMessageServerHash, isErrorResponse } from '@standardnotes/responses'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
import { AsymmetricMessageServerInterface } from '@standardnotes/api'
import { ResendMessage } from './ResendMessage'
import { FindContact } from '../../Contacts/UseCase/FindContact'
import { AsymmetricMessagePayload, AsymmetricMessagePayloadType } from '@standardnotes/models'
export class ResendAllMessages implements UseCaseInterface<void> {
constructor(
private resendMessage: ResendMessage,
private decryptOwnMessage: DecryptOwnMessage<AsymmetricMessagePayload>,
private messageServer: AsymmetricMessageServerInterface,
private findContact: FindContact,
) {}
messagesToExcludeFromResending(): AsymmetricMessagePayloadType[] {
/**
* Sender key pair changed messages should never be re-encrypted with new keys as they must use the
* previous keys used by the sender before their keypair changed.
*/
return [AsymmetricMessagePayloadType.SenderKeypairChanged]
}
async execute(params: {
keys: {
encryption: PkcKeyPair
@@ -37,10 +48,27 @@ export class ResendAllMessages implements UseCaseInterface<void> {
continue
}
const decryptionResult = this.decryptOwnMessage.execute({
message: message.encrypted_message,
privateKey: params.previousKeys?.encryption.privateKey ?? params.keys.encryption.privateKey,
recipientPublicKey: recipient.getValue().publicKeySet.encryption,
})
if (decryptionResult.isFailed()) {
errors.push(`Failed to decrypt message ${message.uuid}`)
continue
}
const decryptedMessage = decryptionResult.getValue()
if (this.messagesToExcludeFromResending().includes(decryptedMessage.type)) {
continue
}
await this.resendMessage.execute({
keys: params.keys,
previousKeys: params.previousKeys,
message: message,
decryptedMessage: decryptedMessage,
rawMessage: message,
recipient: recipient.getValue(),
})
@@ -1,4 +1,3 @@
import { DecryptOwnMessage } from '../../Encryption/UseCase/Asymmetric/DecryptOwnMessage'
import { AsymmetricMessagePayload, TrustedContactInterface } from '@standardnotes/models'
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
@@ -8,7 +7,6 @@ import { SendMessage } from './SendMessage'
export class ResendMessage implements UseCaseInterface<void> {
constructor(
private decryptOwnMessage: DecryptOwnMessage<AsymmetricMessagePayload>,
private sendMessage: SendMessage,
private encryptMessage: EncryptMessage,
) {}
@@ -23,22 +21,11 @@ export class ResendMessage implements UseCaseInterface<void> {
signing: PkcKeyPair
}
recipient: TrustedContactInterface
message: AsymmetricMessageServerHash
rawMessage: AsymmetricMessageServerHash
decryptedMessage: AsymmetricMessagePayload
}): Promise<Result<AsymmetricMessageServerHash>> {
const decryptionResult = this.decryptOwnMessage.execute({
message: params.message.encrypted_message,
privateKey: params.previousKeys?.encryption.privateKey ?? params.keys.encryption.privateKey,
recipientPublicKey: params.recipient.publicKeySet.encryption,
})
if (decryptionResult.isFailed()) {
return Result.fail(decryptionResult.getError())
}
const decryptedMessage = decryptionResult.getValue()
const encryptedMessage = this.encryptMessage.execute({
message: decryptedMessage,
message: params.decryptedMessage,
keys: params.keys,
recipientPublicKey: params.recipient.publicKeySet.encryption,
})
@@ -50,7 +37,7 @@ export class ResendMessage implements UseCaseInterface<void> {
const sendMessageResult = await this.sendMessage.execute({
recipientUuid: params.recipient.contactUuid,
encryptedMessage: encryptedMessage.getValue(),
replaceabilityIdentifier: params.message.replaceabilityIdentifier,
replaceabilityIdentifier: params.rawMessage.replaceabilityIdentifier,
})
return sendMessageResult
@@ -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.
@@ -1,10 +1,5 @@
import { SendOwnContactChangeMessage } from './UseCase/SendOwnContactChangeMessage'
import { DeleteContact } from './UseCase/DeleteContact'
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
import { UserKeyPairChangedEventData } from './../Session/UserKeyPairChangedEventData'
import { SessionEvent } from './../Session/SessionEvent'
import { InternalEventInterface } from './../Internal/InternalEventInterface'
import { InternalEventHandlerInterface } from './../Internal/InternalEventHandlerInterface'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { SharedVaultInviteServerHash, SharedVaultUserServerHash } from '@standardnotes/responses'
import { TrustedContactInterface, TrustedContactMutator, DecryptedItemInterface } from '@standardnotes/models'
@@ -13,7 +8,7 @@ import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
import { SessionsClientInterface } from '../Session/SessionsClientInterface'
import { ContactServiceEvent, ContactServiceInterface } from '../Contacts/ContactServiceInterface'
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { UserClientInterface } from '../User/UserClientInterface'
import { UserServiceInterface } from '../User/UserServiceInterface'
import { CollaborationIDData, Version1CollaborationId } from './CollaborationID'
import { ValidateItemSigner } from './UseCase/ValidateItemSigner'
import { ItemSignatureValidationResult } from './UseCase/Types/ItemSignatureValidationResult'
@@ -25,16 +20,13 @@ import { GetAllContacts } from './UseCase/GetAllContacts'
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
import { Result } from '@standardnotes/domain-core'
export class ContactService
extends AbstractService<ContactServiceEvent>
implements ContactServiceInterface, InternalEventHandlerInterface
{
export class ContactService extends AbstractService<ContactServiceEvent> implements ContactServiceInterface {
constructor(
private sync: SyncServiceInterface,
private mutator: MutatorClientInterface,
private session: SessionsClientInterface,
private crypto: PureCryptoInterface,
private user: UserClientInterface,
private user: UserServiceInterface,
private selfContactManager: SelfContactManager,
private encryption: EncryptionProviderInterface,
private _deleteContact: DeleteContact,
@@ -43,48 +35,25 @@ export class ContactService
private _createOrEditContact: CreateOrEditContact,
private _editContact: EditContact,
private _validateItemSigner: ValidateItemSigner,
private _sendOwnContactChangedMessage: SendOwnContactChangeMessage,
eventBus: InternalEventBusInterface,
) {
super(eventBus)
eventBus.addEventHandler(this, SessionEvent.UserKeyPairChanged)
}
async handleEvent(event: InternalEventInterface): Promise<void> {
if (event.type === SessionEvent.UserKeyPairChanged) {
const data = event.payload as UserKeyPairChangedEventData
await this.selfContactManager.updateWithNewPublicKeySet({
encryption: data.current.encryption.publicKey,
signing: data.current.signing.publicKey,
})
void this.sendOwnContactChangeEventToAllContacts(event.payload as UserKeyPairChangedEventData)
}
}
private async sendOwnContactChangeEventToAllContacts(data: UserKeyPairChangedEventData): Promise<void> {
if (!data.previous) {
return
}
const contacts = this._getAllContacts.execute()
if (contacts.isFailed()) {
return
}
for (const contact of contacts.getValue()) {
if (contact.isMe) {
continue
}
await this._sendOwnContactChangedMessage.execute({
senderOldKeyPair: data.previous.encryption,
senderOldSigningKeyPair: data.previous.signing,
senderNewKeyPair: data.current.encryption,
senderNewSigningKeyPair: data.current.signing,
contact,
})
}
override deinit(): void {
super.deinit()
;(this.sync as unknown) = undefined
;(this.mutator as unknown) = undefined
;(this.session as unknown) = undefined
;(this.crypto as unknown) = undefined
;(this.user as unknown) = undefined
;(this.selfContactManager as unknown) = undefined
;(this.encryption as unknown) = undefined
;(this._findContact as unknown) = undefined
;(this._getAllContacts as unknown) = undefined
;(this._createOrEditContact as unknown) = undefined
;(this._editContact as unknown) = undefined
;(this._validateItemSigner as unknown) = undefined
}
getSelfContact(): TrustedContactInterface | undefined {
@@ -183,6 +152,8 @@ export class ContactService
): Promise<TrustedContactInterface> {
const updatedContact = await this._editContact.execute(contact, params)
void this.sync.sync()
return updatedContact
}
@@ -194,6 +165,9 @@ export class ContactService
isMe?: boolean
}): Promise<TrustedContactInterface | undefined> {
const contact = await this._createOrEditContact.execute(params)
void this.sync.sync()
return contact
}
@@ -233,20 +207,4 @@ export class ContactService
getItemSignatureStatus(item: DecryptedItemInterface): ItemSignatureValidationResult {
return this._validateItemSigner.execute(item)
}
override deinit(): void {
super.deinit()
;(this.sync as unknown) = undefined
;(this.mutator as unknown) = undefined
;(this.session as unknown) = undefined
;(this.crypto as unknown) = undefined
;(this.user as unknown) = undefined
;(this.selfContactManager as unknown) = undefined
;(this.encryption as unknown) = undefined
;(this._findContact as unknown) = undefined
;(this._getAllContacts as unknown) = undefined
;(this._createOrEditContact as unknown) = undefined
;(this._editContact as unknown) = undefined
;(this._validateItemSigner as unknown) = undefined
}
}
@@ -17,9 +17,7 @@ import {
TrustedContactContent,
TrustedContactContentSpecialized,
TrustedContactInterface,
PortablePublicKeySet,
} from '@standardnotes/models'
import { CreateOrEditContact } from './UseCase/CreateOrEditContact'
import { ContentType } from '@standardnotes/domain-core'
const SelfContactName = 'Me'
@@ -35,7 +33,6 @@ export class SelfContactManager implements InternalEventHandlerInterface {
items: ItemManagerInterface,
private session: SessionsClientInterface,
private singletons: SingletonManagerInterface,
private createOrEditContact: CreateOrEditContact,
) {
this.eventDisposers.push(
sync.addEventObserver((event) => {
@@ -82,23 +79,6 @@ export class SelfContactManager implements InternalEventHandlerInterface {
)
}
public async updateWithNewPublicKeySet(publicKeySet: PortablePublicKeySet) {
if (!InternalFeatureService.get().isFeatureEnabled(InternalFeature.Vaults)) {
return
}
if (!this.selfContact) {
return
}
await this.createOrEditContact.execute({
name: SelfContactName,
contactUuid: this.selfContact.contactUuid,
publicKey: publicKeySet.encryption,
signingPublicKey: publicKeySet.signing,
})
}
private async reloadSelfContactAndCreateIfNecessary() {
if (!InternalFeatureService.get().isFeatureEnabled(InternalFeature.Vaults)) {
return
@@ -146,6 +126,5 @@ export class SelfContactManager implements InternalEventHandlerInterface {
this.eventDisposers.forEach((disposer) => disposer())
;(this.session as unknown) = undefined
;(this.singletons as unknown) = undefined
;(this.createOrEditContact as unknown) = undefined
}
}
@@ -1,4 +1,3 @@
import { SyncServiceInterface } from '../../Sync/SyncServiceInterface'
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
import {
ContactPublicKeySet,
@@ -15,7 +14,6 @@ import { ContentType } from '@standardnotes/domain-core'
export class CreateOrEditContact {
constructor(
private mutator: MutatorClientInterface,
private sync: SyncServiceInterface,
private findContact: FindContact,
private editContact: EditContact,
) {}
@@ -54,8 +52,6 @@ export class CreateOrEditContact {
true,
)
await this.sync.sync()
return contact
}
}
@@ -18,7 +18,7 @@ export class DeleteContact implements UseCaseInterface<void> {
throw new Error('Cannot delete self')
}
const vaults = this.getOwnedVaults.execute({ userUuid: dto.ownUserUuid })
const vaults = this.getOwnedVaults.execute()
if (vaults.isFailed()) {
return Result.fail('Failed to get owned vaults')
}
@@ -1,12 +1,8 @@
import { SyncServiceInterface } from '../../Sync/SyncServiceInterface'
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
import { TrustedContactInterface, TrustedContactMutator } from '@standardnotes/models'
export class EditContact {
constructor(
private mutator: MutatorClientInterface,
private sync: SyncServiceInterface,
) {}
constructor(private mutator: MutatorClientInterface) {}
async execute(
contact: TrustedContactInterface,
@@ -28,8 +24,6 @@ export class EditContact {
},
)
await this.sync.sync()
return updatedContact
}
}
@@ -8,16 +8,20 @@ export class FindContact implements SyncUseCaseInterface<TrustedContactInterface
execute(query: FindContactQuery): Result<TrustedContactInterface> {
if ('userUuid' in query && query.userUuid) {
const contact = this.items.itemsMatchingPredicate<TrustedContactInterface>(
const contacts = this.items.itemsMatchingPredicate<TrustedContactInterface>(
ContentType.TYPES.TrustedContact,
new Predicate<TrustedContactInterface>('contactUuid', '=', query.userUuid),
)[0]
)
if (contact) {
return Result.ok(contact)
} else {
return Result.fail('Contact not found')
if (contacts.length === 0) {
return Result.fail(`Contact not found for user ${query.userUuid}`)
}
if (contacts.length > 1) {
return Result.fail(`Multiple contacts found for user ${query.userUuid}`)
}
return Result.ok(contacts[0])
}
if ('signingPublicKey' in query && query.signingPublicKey) {
@@ -0,0 +1,161 @@
import { HandleKeyPairChange } from './HandleKeyPairChange'
import { Result } from '@standardnotes/domain-core'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import { LoggerInterface } from '@standardnotes/utils'
describe('HandleKeyPairChange', () => {
let useCase: HandleKeyPairChange
let mockSelfContactManager: any
let mockInvitesServer: any
let mockMessageServer: any
let mockReuploadAllInvites: any
let mockResendAllMessages: any
let mockGetAllContacts: any
let mockCreateOrEditContact: any
let mockSendOwnContactChangedMessage: any
let logger: LoggerInterface
const dto = {
newKeys: {
encryption: <PkcKeyPair>{
publicKey: 'new-encryption-public-key',
privateKey: 'new-encryption-private-key',
},
signing: <PkcKeyPair>{
publicKey: 'new-signing-public-key',
privateKey: 'new-signing-private-key',
},
},
previousKeys: {
encryption: <PkcKeyPair>{
publicKey: 'previous-encryption-public-key',
privateKey: 'previous-encryption-private-key',
},
signing: <PkcKeyPair>{
publicKey: 'previous-signing-public-key',
privateKey: 'previous-signing-private-key',
},
},
}
beforeEach(() => {
mockSelfContactManager = {
updateWithNewPublicKeySet: jest.fn().mockReturnValue({}),
}
mockInvitesServer = {
deleteAllInboundInvites: jest.fn().mockReturnValue({}),
}
mockMessageServer = {
deleteAllInboundMessages: jest.fn().mockReturnValue({}),
}
mockReuploadAllInvites = {
execute: jest.fn().mockReturnValue(Result.ok()),
}
mockResendAllMessages = {
execute: jest.fn().mockReturnValue(Result.ok()),
}
mockGetAllContacts = {
execute: jest.fn().mockReturnValue(Result.ok()),
}
mockSendOwnContactChangedMessage = {
execute: jest.fn().mockReturnValue(Result.ok()),
}
mockCreateOrEditContact = {
execute: jest.fn().mockReturnValue(Result.ok()),
}
logger = {} as jest.Mocked<LoggerInterface>
logger.error = jest.fn()
useCase = new HandleKeyPairChange(
mockSelfContactManager,
mockInvitesServer,
mockMessageServer,
mockReuploadAllInvites,
mockResendAllMessages,
mockGetAllContacts,
mockSendOwnContactChangedMessage,
mockCreateOrEditContact,
logger,
)
})
it('should handle key pair change correctly', async () => {
mockGetAllContacts.execute.mockReturnValue(Result.ok([]))
const result = await useCase.execute(dto)
expect(mockReuploadAllInvites.execute).toBeCalledWith({ keys: dto.newKeys, previousKeys: dto.previousKeys })
expect(mockResendAllMessages.execute).toBeCalledWith({ keys: dto.newKeys, previousKeys: dto.previousKeys })
expect(mockSendOwnContactChangedMessage.execute).not.toBeCalled()
expect(mockMessageServer.deleteAllInboundMessages).toBeCalled()
expect(mockInvitesServer.deleteAllInboundInvites).toBeCalled()
expect(result.isFailed()).toBe(false)
})
it('should handle sending contact change event to all contacts', async () => {
const contact = { isMe: false }
mockGetAllContacts.execute.mockReturnValue(Result.ok([contact]))
await useCase.execute(dto)
expect(mockSendOwnContactChangedMessage.execute).toBeCalledWith({
senderOldKeyPair: dto.previousKeys.encryption,
senderOldSigningKeyPair: dto.previousKeys.signing,
senderNewKeyPair: dto.newKeys.encryption,
senderNewSigningKeyPair: dto.newKeys.signing,
contact,
})
})
it('should not send contact change event if previous keys are missing', async () => {
const contact = { isMe: false }
mockGetAllContacts.execute.mockReturnValue(Result.ok([contact]))
await useCase.execute({ newKeys: dto.newKeys })
expect(mockSendOwnContactChangedMessage.execute).not.toBeCalled()
})
it('should not send contact change event if getAllContacts fails', async () => {
mockGetAllContacts.execute.mockReturnValue(Result.fail('Some error'))
await useCase.execute(dto)
expect(mockSendOwnContactChangedMessage.execute).not.toBeCalled()
})
it('should not send contact change event for self contact', async () => {
const contact = { isMe: true }
mockGetAllContacts.execute.mockReturnValue(Result.ok([contact]))
await useCase.execute(dto)
expect(mockSendOwnContactChangedMessage.execute).not.toBeCalled()
})
it('should reupload invites and resend messages before sending contact change message', async () => {
const contact = { isMe: false }
mockGetAllContacts.execute.mockReturnValue(Result.ok([contact]))
await useCase.execute(dto)
const callOrder = [
mockReuploadAllInvites.execute,
mockResendAllMessages.execute,
mockSendOwnContactChangedMessage.execute,
].map((fn) => fn.mock.invocationCallOrder[0])
for (let i = 0; i < callOrder.length - 1; i++) {
expect(callOrder[i]).toBeLessThan(callOrder[i + 1])
}
})
})
@@ -1,34 +1,121 @@
import { InternalFeatureService } from './../../InternalFeatures/InternalFeatureService'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import { ReuploadAllInvites } from '../../VaultInvite/UseCase/ReuploadAllInvites'
import { ResendAllMessages } from '../../AsymmetricMessage/UseCase/ResendAllMessages'
import { SelfContactManager } from '../SelfContactManager'
import { GetAllContacts } from './GetAllContacts'
import { SendOwnContactChangeMessage } from './SendOwnContactChangeMessage'
import { AsymmetricMessageServer, SharedVaultInvitesServer } from '@standardnotes/api'
import { PortablePublicKeySet } from '@standardnotes/models'
import { InternalFeature } from '../../InternalFeatures/InternalFeature'
import { CreateOrEditContact } from './CreateOrEditContact'
import { isErrorResponse } from '@standardnotes/responses'
import { LoggerInterface } from '@standardnotes/utils'
type Dto = {
newKeys: {
encryption: PkcKeyPair
signing: PkcKeyPair
}
previousKeys?: {
encryption: PkcKeyPair
signing: PkcKeyPair
}
}
export class HandleKeyPairChange implements UseCaseInterface<void> {
constructor(
private reuploadAllInvites: ReuploadAllInvites,
private resendAllMessages: ResendAllMessages,
private selfContactManager: SelfContactManager,
private invitesServer: SharedVaultInvitesServer,
private messageServer: AsymmetricMessageServer,
private _reuploadAllInvites: ReuploadAllInvites,
private _resendAllMessages: ResendAllMessages,
private _getAllContacts: GetAllContacts,
private _sendOwnContactChangedMessage: SendOwnContactChangeMessage,
private _createOrEditContact: CreateOrEditContact,
private logger: LoggerInterface,
) {}
async execute(dto: {
newKeys: {
encryption: PkcKeyPair
signing: PkcKeyPair
}
previousKeys?: {
encryption: PkcKeyPair
signing: PkcKeyPair
}
}): Promise<Result<void>> {
await this.reuploadAllInvites.execute({
keys: dto.newKeys,
previousKeys: dto.previousKeys,
async execute(dto: Dto): Promise<Result<void>> {
await this.updateSelfContact({
encryption: dto.newKeys.encryption.publicKey,
signing: dto.newKeys.signing.publicKey,
})
await this.resendAllMessages.execute({
keys: dto.newKeys,
previousKeys: dto.previousKeys,
})
const results = await Promise.all([
this._reuploadAllInvites.execute({
keys: dto.newKeys,
previousKeys: dto.previousKeys,
}),
this._resendAllMessages.execute({
keys: dto.newKeys,
previousKeys: dto.previousKeys,
}),
])
for (const result of results) {
if (result.isFailed()) {
this.logger.error(result.getError())
}
}
await this.sendOwnContactChangeEventToAllContacts(dto)
const deleteResponses = await Promise.all([
this.messageServer.deleteAllInboundMessages(),
this.invitesServer.deleteAllInboundInvites(),
])
for (const response of deleteResponses) {
if (isErrorResponse(response)) {
this.logger.error(JSON.stringify(response))
}
}
return Result.ok()
}
private async updateSelfContact(publicKeySet: PortablePublicKeySet) {
if (!InternalFeatureService.get().isFeatureEnabled(InternalFeature.Vaults)) {
return
}
const selfContact = this.selfContactManager.selfContact
if (!selfContact) {
return
}
await this._createOrEditContact.execute({
contactUuid: selfContact.contactUuid,
publicKey: publicKeySet.encryption,
signingPublicKey: publicKeySet.signing,
})
}
private async sendOwnContactChangeEventToAllContacts(data: Dto): Promise<void> {
if (!data.previousKeys) {
return
}
const contacts = this._getAllContacts.execute()
if (contacts.isFailed()) {
return
}
for (const contact of contacts.getValue()) {
if (contact.isMe) {
continue
}
await this._sendOwnContactChangedMessage.execute({
senderOldKeyPair: data.previousKeys.encryption,
senderOldSigningKeyPair: data.previousKeys.signing,
senderNewKeyPair: data.newKeys.encryption,
senderNewSigningKeyPair: data.newKeys.signing,
contact,
})
}
}
}
@@ -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
}
@@ -20,11 +20,12 @@ import {
KeySystemRootKeyParamsInterface,
PortablePublicKeySet,
} from '@standardnotes/models'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
export interface EncryptionProviderInterface {
initialize(): Promise<void>
isPasscodeLocked(): Promise<boolean>
encryptSplitSingle(split: KeyedEncryptionSplit): Promise<EncryptedPayloadInterface>
encryptSplit(split: KeyedEncryptionSplit): Promise<EncryptedPayloadInterface[]>
decryptSplitSingle<
@@ -72,7 +73,6 @@ export interface EncryptionProviderInterface {
}
>
decryptErroredPayloads(): Promise<void>
deleteWorkspaceSpecificKeyStateFromDevice(): Promise<void>
unwrapRootKey(wrappingKey: RootKeyInterface): Promise<void>
@@ -110,9 +110,6 @@ export interface EncryptionProviderInterface {
rootKeyToken: string,
): KeySystemItemsKeyInterface
getKeyPair(): PkcKeyPair
getSigningKeyPair(): PkcKeyPair
asymmetricSignatureVerifyDetached(
encryptedString: AsymmetricallyEncryptedString,
): AsymmetricSignatureVerificationDetachedResult
@@ -1,3 +1,4 @@
import { GetKeyPairs } from './UseCase/GetKeyPairs'
import { FindDefaultItemsKey } from './UseCase/ItemsKey/FindDefaultItemsKey'
import { InternalEventInterface } from './../Internal/InternalEventInterface'
import { InternalEventHandlerInterface } from './../Internal/InternalEventHandlerInterface'
@@ -43,7 +44,7 @@ import {
PortablePublicKeySet,
RootKeyParamsInterface,
} from '@standardnotes/models'
import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import {
extendArray,
isNotUndefined,
@@ -73,7 +74,6 @@ import { DecryptedParameters } from '@standardnotes/encryption/src/Domain/Types/
import { RootKeyManager } from '../RootKeyManager/RootKeyManager'
import { RootKeyManagerEvent } from '../RootKeyManager/RootKeyManagerEvent'
import { CreateNewItemsKeyWithRollback } from './UseCase/ItemsKey/CreateNewItemsKeyWithRollback'
import { DecryptErroredTypeAPayloads } from './UseCase/TypeA/DecryptErroredPayloads'
import { CreateNewDefaultItemsKey } from './UseCase/ItemsKey/CreateNewDefaultItemsKey'
import { DecryptTypeAPayload } from './UseCase/TypeA/DecryptPayload'
import { DecryptTypeAPayloadWithKeyLookup } from './UseCase/TypeA/DecryptPayloadWithKeyLookup'
@@ -126,12 +126,12 @@ export class EncryptionService
private crypto: PureCryptoInterface,
private _createNewItemsKeyWithRollback: CreateNewItemsKeyWithRollback,
private _findDefaultItemsKey: FindDefaultItemsKey,
private _decryptErroredRootPayloads: DecryptErroredTypeAPayloads,
private _rootKeyEncryptPayloadWithKeyLookup: EncryptTypeAPayloadWithKeyLookup,
private _rootKeyEncryptPayload: EncryptTypeAPayload,
private _rootKeyDecryptPayload: DecryptTypeAPayload,
private _rootKeyDecryptPayloadWithKeyLookup: DecryptTypeAPayloadWithKeyLookup,
private _createDefaultItemsKey: CreateNewDefaultItemsKey,
private _getKeyPairs: GetKeyPairs,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
@@ -157,7 +157,6 @@ export class EncryptionService
;(this.crypto as unknown) = undefined
;(this._createNewItemsKeyWithRollback as unknown) = undefined
;(this._findDefaultItemsKey as unknown) = undefined
;(this._decryptErroredRootPayloads as unknown) = undefined
;(this._rootKeyEncryptPayloadWithKeyLookup as unknown) = undefined
;(this._rootKeyEncryptPayload as unknown) = undefined
;(this._rootKeyDecryptPayload as unknown) = undefined
@@ -167,28 +166,6 @@ export class EncryptionService
super.deinit()
}
/** @throws */
getKeyPair(): PkcKeyPair {
const rootKey = this.getRootKey()
if (!rootKey?.encryptionKeyPair) {
throw new Error('Account keypair not found')
}
return rootKey.encryptionKeyPair
}
/** @throws */
getSigningKeyPair(): PkcKeyPair {
const rootKey = this.getRootKey()
if (!rootKey?.signingKeyPair) {
throw new Error('Account keypair not found')
}
return rootKey.signingKeyPair
}
hasSigningKeyPair(): boolean {
return !!this.getRootKey()?.signingKeyPair
}
@@ -214,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()
}
@@ -244,12 +222,6 @@ export class EncryptionService
return this._createNewItemsKeyWithRollback.execute()
}
public async decryptErroredPayloads(): Promise<void> {
await this._decryptErroredRootPayloads.execute()
await this.itemsEncryption.decryptErroredItemPayloads()
}
public itemsKeyForEncryptedPayload(
payload: EncryptedPayloadInterface,
): ItemsKeyInterface | KeySystemItemsKeyInterface | undefined {
@@ -279,7 +251,9 @@ export class EncryptionService
usesKeySystemRootKeyWithKeyLookup,
} = split
const signingKeyPair = this.hasSigningKeyPair() ? this.getSigningKeyPair() : undefined
const keys = this._getKeyPairs.execute()
const signingKeyPair = keys.isFailed() ? undefined : keys.getValue().signing
if (usesRootKey) {
const rootKeyEncrypted = await this._rootKeyEncryptPayload.executeMany(
@@ -652,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
}
@@ -36,12 +36,15 @@ import {
RootKeyParamsInterface,
} from '@standardnotes/models'
import { ClientDisplayableError } from '@standardnotes/responses'
import { extendArray } from '@standardnotes/utils'
import { extendArray, LoggerInterface } from '@standardnotes/utils'
import { EncryptionService } from '../EncryptionService'
import { ContentType } from '@standardnotes/domain-core'
export class DecryptBackupFile {
constructor(private encryption: EncryptionService) {}
constructor(
private encryption: EncryptionService,
private logger: LoggerInterface,
) {}
async execute(
file: BackupFile,
@@ -273,7 +276,7 @@ export class DecryptBackupFile {
errorDecrypting: true,
}),
)
console.error('Error decrypting payload', encryptedPayload, e)
this.logger.error('Error decrypting payload', encryptedPayload, e)
}
}
@@ -0,0 +1,18 @@
import { DecryptErroredTypeAPayloads } from './TypeA/DecryptErroredPayloads'
import { ItemsEncryptionService } from './../../ItemsEncryption/ItemsEncryption'
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
export class DecryptErroredPayloads implements UseCaseInterface<void> {
constructor(
private itemsEncryption: ItemsEncryptionService,
private _decryptErroredRootPayloads: DecryptErroredTypeAPayloads,
) {}
async execute(): Promise<Result<void>> {
await this._decryptErroredRootPayloads.execute()
await this.itemsEncryption.decryptErroredItemPayloads()
return Result.ok()
}
}
@@ -0,0 +1,25 @@
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import { RootKeyManager } from '../../RootKeyManager/RootKeyManager'
type UsecaseResult = {
encryption: PkcKeyPair
signing: PkcKeyPair
}
export class GetKeyPairs implements SyncUseCaseInterface<UsecaseResult> {
constructor(private rootKeyManager: RootKeyManager) {}
execute(): Result<UsecaseResult> {
const rootKey = this.rootKeyManager.getRootKey()
if (!rootKey?.encryptionKeyPair || !rootKey?.signingKeyPair) {
return Result.fail('Account keypair not found')
}
return Result.ok({
encryption: rootKey.encryptionKeyPair,
signing: rootKey.signingKeyPair,
})
}
}
@@ -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',
}
@@ -2,7 +2,7 @@ import {
AsymmetricMessageServerHash,
SharedVaultInviteServerHash,
SharedVaultServerHash,
UserEventServerHash,
NotificationServerHash,
} from '@standardnotes/responses'
/* istanbul ignore file */
@@ -31,11 +31,11 @@ export enum SyncEvent {
SyncRequestsIntegrityCheck = 'sync:requests-integrity-check',
ReceivedRemoteSharedVaults = 'received-shared-vaults',
ReceivedSharedVaultInvites = 'received-shared-vault-invites',
ReceivedUserEvents = 'received-user-events',
ReceivedNotifications = 'received-user-events',
ReceivedAsymmetricMessages = 'received-asymmetric-messages',
}
export type SyncEventReceivedRemoteSharedVaultsData = SharedVaultServerHash[]
export type SyncEventReceivedSharedVaultInvitesData = SharedVaultInviteServerHash[]
export type SyncEventReceivedAsymmetricMessagesData = AsymmetricMessageServerHash[]
export type SyncEventReceivedUserEventsData = UserEventServerHash[]
export type SyncEventReceivedNotificationsData = NotificationServerHash[]
@@ -11,6 +11,7 @@ import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
import { FileService } from './FileService'
import { BackupServiceInterface } from '@standardnotes/files'
import { HttpServiceInterface } from '@standardnotes/api'
import { LoggerInterface } from '@standardnotes/utils'
describe('fileService', () => {
let apiService: LegacyApiServiceInterface
@@ -26,6 +27,8 @@ describe('fileService', () => {
let backupService: BackupServiceInterface
let http: HttpServiceInterface
let logger: LoggerInterface
beforeEach(() => {
apiService = {} as jest.Mocked<LegacyApiServiceInterface>
apiService.addEventObserver = jest.fn()
@@ -82,6 +85,9 @@ describe('fileService', () => {
backupService.readEncryptedFileFromBackup = jest.fn()
backupService.getFileBackupInfo = jest.fn()
logger = {} as jest.Mocked<LoggerInterface>
logger.info = jest.fn()
http = {} as jest.Mocked<HttpServiceInterface>
fileService = new FileService(
@@ -94,6 +100,7 @@ describe('fileService', () => {
alertService,
crypto,
internalEventBus,
logger,
backupService,
)
@@ -19,7 +19,7 @@ import {
SharedVaultListingInterface,
} from '@standardnotes/models'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { spaceSeparatedStrings, UuidGenerator } from '@standardnotes/utils'
import { LoggerInterface, spaceSeparatedStrings, UuidGenerator } from '@standardnotes/utils'
import { SNItemsKey } from '@standardnotes/encryption'
import {
DownloadAndDecryptFileOperation,
@@ -47,7 +47,6 @@ import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface
import { AbstractService } from '../Service/AbstractService'
import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
import { DecryptItemsKeyWithUserFallback } from '../Encryption/Functions'
import { log, LoggingDomain } from '../Logging'
import { SharedVaultServer, SharedVaultServerInterface, HttpServiceInterface } from '@standardnotes/api'
import { ContentType } from '@standardnotes/domain-core'
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
@@ -68,6 +67,7 @@ export class FileService extends AbstractService implements FilesClientInterface
private alertService: AlertService,
private crypto: PureCryptoInterface,
protected override internalEventBus: InternalEventBusInterface,
private logger: LoggerInterface,
private backupsService?: BackupServiceInterface,
) {
super(internalEventBus)
@@ -317,19 +317,19 @@ export class FileService extends AbstractService implements FilesClientInterface
const fileBackup = await this.backupsService?.getFileBackupInfo(file)
if (this.backupsService && fileBackup) {
log(LoggingDomain.FilesService, 'Downloading file from backup', fileBackup)
this.logger.info('Downloading file from backup', fileBackup)
await readAndDecryptBackupFileUsingBackupService(file, this.backupsService, this.crypto, async (chunk) => {
log(LoggingDomain.FilesService, 'Got local file chunk', chunk.progress)
this.logger.info('Got local file chunk', chunk.progress)
return onDecryptedBytes(chunk.data, chunk.progress)
})
log(LoggingDomain.FilesService, 'Finished downloading file from backup')
this.logger.info('Finished downloading file from backup')
return undefined
} else {
log(LoggingDomain.FilesService, 'Downloading file from network')
this.logger.info('Downloading file from network')
const addToCache = file.encryptedSize < this.encryptedCache.maxSize
@@ -8,14 +8,16 @@ import { IntegrityApiInterface } from './IntegrityApiInterface'
import { IntegrityService } from './IntegrityService'
import { PayloadManagerInterface } from '../Payloads/PayloadManagerInterface'
import { IntegrityPayload } from '@standardnotes/responses'
import { LoggerInterface } from '@standardnotes/utils'
describe('IntegrityService', () => {
let integrityApi: IntegrityApiInterface
let itemApi: ItemsServerInterface
let payloadManager: PayloadManagerInterface
let logger: LoggerInterface
let internalEventBus: InternalEventBusInterface
const createService = () => new IntegrityService(integrityApi, itemApi, payloadManager, internalEventBus)
const createService = () => new IntegrityService(integrityApi, itemApi, payloadManager, logger, internalEventBus)
beforeEach(() => {
integrityApi = {} as jest.Mocked<IntegrityApiInterface>
@@ -29,6 +31,10 @@ describe('IntegrityService', () => {
internalEventBus = {} as jest.Mocked<InternalEventBusInterface>
internalEventBus.publishSync = jest.fn()
logger = {} as jest.Mocked<LoggerInterface>
logger.info = jest.fn()
logger.error = jest.fn()
})
it('should check integrity of payloads and publish mismatches', async () => {
@@ -63,7 +69,7 @@ describe('IntegrityService', () => {
uuid: '1-2-3',
},
],
source: "AfterDownloadFirst",
source: 'AfterDownloadFirst',
},
type: 'IntegrityCheckCompleted',
},
@@ -90,7 +96,7 @@ describe('IntegrityService', () => {
{
payload: {
rawPayloads: [],
source: "AfterDownloadFirst",
source: 'AfterDownloadFirst',
},
type: 'IntegrityCheckCompleted',
},
@@ -140,7 +146,7 @@ describe('IntegrityService', () => {
{
payload: {
rawPayloads: [],
source: "AfterDownloadFirst",
source: 'AfterDownloadFirst',
},
type: 'IntegrityCheckCompleted',
},
@@ -10,6 +10,7 @@ import { SyncEvent } from '../Event/SyncEvent'
import { IntegrityEventPayload } from './IntegrityEventPayload'
import { SyncSource } from '../Sync/SyncSource'
import { PayloadManagerInterface } from '../Payloads/PayloadManagerInterface'
import { LoggerInterface } from '@standardnotes/utils'
export class IntegrityService
extends AbstractService<IntegrityEvent, IntegrityEventPayload>
@@ -19,6 +20,7 @@ export class IntegrityService
private integrityApi: IntegrityApiInterface,
private itemApi: ItemsServerInterface,
private payloadManager: PayloadManagerInterface,
private logger: LoggerInterface,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
@@ -31,7 +33,7 @@ export class IntegrityService
const integrityCheckResponse = await this.integrityApi.checkIntegrity(this.payloadManager.integrityPayloads)
if (isErrorResponse(integrityCheckResponse)) {
this.log(`Could not obtain integrity check: ${integrityCheckResponse.data.error?.message}`)
this.logger.error(`Could not obtain integrity check: ${integrityCheckResponse.data.error?.message}`)
return
}
@@ -50,7 +52,7 @@ export class IntegrityService
isErrorResponse(serverItemResponse) ||
!('item' in serverItemResponse.data)
) {
this.log(
this.logger.error(
`Could not obtain item for integrity adjustments: ${
isErrorResponse(serverItemResponse) ? serverItemResponse.data.error?.message : ''
}`,
@@ -10,7 +10,6 @@ import {
SNTag,
ItemInterface,
AnyItemInterface,
KeySystemIdentifier,
ItemCollection,
SNNote,
SmartView,
@@ -20,8 +19,8 @@ import {
FileItem,
VaultDisplayOptions,
NotesAndFilesDisplayControllerOptions,
ThemeInterface,
ComponentInterface,
ItemStream,
} from '@standardnotes/models'
import { AbstractService } from '../Service/AbstractService'
@@ -57,6 +56,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[]
@@ -102,7 +106,6 @@ export interface ItemManagerInterface extends AbstractService {
findItemsIncludingBlanks<T extends DecryptedItemInterface>(uuids: string[]): (T | undefined)[]
get trashedItems(): SNNote[]
itemsBelongingToKeySystem(systemIdentifier: KeySystemIdentifier): DecryptedItemInterface[]
hasTagsNeedingFoldersMigration(): boolean
get invalidNonVaultedItems(): EncryptedItemInterface[]
isTemplateItem(item: DecryptedItemInterface): boolean
@@ -117,7 +120,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[]
@@ -0,0 +1,222 @@
import { ItemsEncryptionService } from './ItemsEncryption'
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
import { PayloadManagerInterface } from '../Payloads/PayloadManagerInterface'
import { StorageServiceInterface } from '../Storage/StorageServiceInterface'
import {
DecryptedParameters,
EncryptionOperatorsInterface,
KeySystemItemsKey,
StandardException,
} from '@standardnotes/encryption'
import { KeySystemKeyManagerInterface } from '../KeySystem/KeySystemKeyManagerInterface'
import { FindDefaultItemsKey } from './../Encryption/UseCase/ItemsKey/FindDefaultItemsKey'
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { EncryptedOutputParameters } from '@standardnotes/encryption'
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
import {
DecryptedPayloadInterface,
EncryptedPayloadInterface,
ItemsKeyInterface,
KeySystemItemsKeyInterface,
} from '@standardnotes/models'
describe('ItemsEncryptionService', () => {
let itemsEncryptionService: ItemsEncryptionService
let mockItems: jest.Mocked<ItemManagerInterface>
let mockPayloads: jest.Mocked<PayloadManagerInterface>
let mockStorage: jest.Mocked<StorageServiceInterface>
let mockOperators: jest.Mocked<EncryptionOperatorsInterface>
let mockKeys: jest.Mocked<KeySystemKeyManagerInterface>
let mockFindDefaultItemsKey: jest.Mocked<FindDefaultItemsKey>
let mockInternalEventBus: jest.Mocked<InternalEventBusInterface>
beforeEach(() => {
mockItems = {
addObserver: jest.fn(),
} as unknown as jest.Mocked<ItemManagerInterface>
mockPayloads = {} as jest.Mocked<PayloadManagerInterface>
mockStorage = {} as jest.Mocked<StorageServiceInterface>
mockOperators = {} as jest.Mocked<EncryptionOperatorsInterface>
mockKeys = {} as jest.Mocked<KeySystemKeyManagerInterface>
mockFindDefaultItemsKey = {} as jest.Mocked<FindDefaultItemsKey>
mockInternalEventBus = {} as jest.Mocked<InternalEventBusInterface>
itemsEncryptionService = new ItemsEncryptionService(
mockItems,
mockPayloads,
mockStorage,
mockOperators,
mockKeys,
mockFindDefaultItemsKey,
mockInternalEventBus,
)
})
describe('decryptPayloadWithKeyLookup', () => {
it('returns decrypted parameters when a key is found', async () => {
const mockPayload = {
uuid: 'payload-uuid',
} as EncryptedPayloadInterface
const mockKey = {
uuid: 'key-uuid',
} as KeySystemItemsKey
const mockDecryptedParameters = {
uuid: 'decrypted-uuid',
content: {},
} as DecryptedParameters
itemsEncryptionService.keyToUseForDecryptionOfPayload = jest.fn().mockReturnValue(mockKey)
itemsEncryptionService.decryptPayload = jest.fn().mockResolvedValue(mockDecryptedParameters)
const result = await itemsEncryptionService.decryptPayloadWithKeyLookup(mockPayload)
expect(itemsEncryptionService.keyToUseForDecryptionOfPayload).toHaveBeenCalledWith(mockPayload)
expect(itemsEncryptionService.decryptPayload).toHaveBeenCalledWith(mockPayload, mockKey)
expect(result).toEqual(mockDecryptedParameters)
})
it('returns error parameters when no key is found', async () => {
const mockPayload = {
uuid: 'payload-uuid',
} as EncryptedPayloadInterface
itemsEncryptionService.keyToUseForDecryptionOfPayload = jest.fn().mockReturnValue(undefined)
const result = await itemsEncryptionService.decryptPayloadWithKeyLookup(mockPayload)
expect(itemsEncryptionService.keyToUseForDecryptionOfPayload).toHaveBeenCalledWith(mockPayload)
expect(result).toEqual({
uuid: mockPayload.uuid,
errorDecrypting: true,
waitingForKey: true,
})
})
})
describe('keyToUseForDecryptionOfPayload', () => {
it('returns itemsKey when payload has items_key_id', () => {
const mockPayload: EncryptedPayloadInterface = {
items_key_id: 'test-key-id',
} as EncryptedPayloadInterface
const mockItemsKey: ItemsKeyInterface = {} as ItemsKeyInterface
itemsEncryptionService.itemsKeyForEncryptedPayload = jest.fn().mockReturnValue(mockItemsKey)
const result = itemsEncryptionService.keyToUseForDecryptionOfPayload(mockPayload)
expect(itemsEncryptionService.itemsKeyForEncryptedPayload).toHaveBeenCalledWith(mockPayload)
expect(result).toBe(mockItemsKey)
})
it('returns defaultKey when payload does not have items_key_id', () => {
const mockPayload: EncryptedPayloadInterface = {} as EncryptedPayloadInterface
const mockDefaultKey: KeySystemItemsKeyInterface = {} as KeySystemItemsKeyInterface
itemsEncryptionService.defaultItemsKeyForItemVersion = jest.fn().mockReturnValue(mockDefaultKey)
const result = itemsEncryptionService.keyToUseForDecryptionOfPayload(mockPayload)
expect(itemsEncryptionService.defaultItemsKeyForItemVersion).toHaveBeenCalledWith(mockPayload.version)
expect(result).toBe(mockDefaultKey)
})
})
describe('encryptPayloadWithKeyLookup', () => {
it('throws an error when keyToUseForItemEncryption returns an instance of StandardException', async () => {
const mockPayload: DecryptedPayloadInterface = {} as DecryptedPayloadInterface
const mockError: StandardException = new StandardException('test-error')
itemsEncryptionService.keyToUseForItemEncryption = jest.fn().mockReturnValue(mockError)
await expect(() => itemsEncryptionService.encryptPayloadWithKeyLookup(mockPayload)).rejects.toThrow('test-error')
})
it('encrypts the payload using the provided key', async () => {
const mockPayload: DecryptedPayloadInterface = {} as DecryptedPayloadInterface
const mockKey: ItemsKeyInterface = {} as ItemsKeyInterface
const encryptedOutputParameters: EncryptedOutputParameters = {
content: 'encrypted-content',
} as EncryptedOutputParameters
itemsEncryptionService.keyToUseForItemEncryption = jest.fn().mockReturnValue(mockKey)
itemsEncryptionService.encryptPayload = jest.fn().mockResolvedValue(encryptedOutputParameters)
const result = await itemsEncryptionService.encryptPayloadWithKeyLookup(mockPayload)
expect(itemsEncryptionService.encryptPayload).toHaveBeenCalledWith(mockPayload, mockKey, undefined)
expect(result).toBe(encryptedOutputParameters)
})
})
describe('encryptPayload', () => {
it('throws an error when the payload has no content', async () => {
const mockPayload: DecryptedPayloadInterface = { content: null } as unknown as DecryptedPayloadInterface
const mockKey: ItemsKeyInterface = {} as ItemsKeyInterface
await expect(() => itemsEncryptionService.encryptPayload(mockPayload, mockKey)).rejects.toThrow(
'Attempting to encrypt payload with no content.',
)
})
it('throws an error when the payload has no UUID', async () => {
const mockPayload: DecryptedPayloadInterface = { uuid: null, content: {} } as unknown as DecryptedPayloadInterface
const mockKey: ItemsKeyInterface = {} as ItemsKeyInterface
await expect(() => itemsEncryptionService.encryptPayload(mockPayload, mockKey)).rejects.toThrow(
'Attempting to encrypt payload with no UuidGenerator.',
)
})
it('returns encrypted output parameters', async () => {
const mockPayload: DecryptedPayloadInterface = {
uuid: 'test-uuid',
content: 'test-content',
} as unknown as DecryptedPayloadInterface
const mockKey: ItemsKeyInterface = {} as ItemsKeyInterface
const encryptedOutputParameters: EncryptedOutputParameters = {
content: 'encrypted-content',
} as EncryptedOutputParameters
jest.spyOn(itemsEncryptionService, 'encryptPayload').mockResolvedValue(encryptedOutputParameters)
const result = await itemsEncryptionService.encryptPayload(mockPayload, mockKey)
expect(result).toBe(encryptedOutputParameters)
})
})
it('repersistAllItems', async () => {
Object.defineProperty(mockItems, 'items', {
get: jest.fn().mockReturnValue([{ payload: { uuid: '123' } }]),
})
mockStorage.savePayloads = jest.fn().mockResolvedValue(undefined)
await itemsEncryptionService.repersistAllItems()
expect(mockStorage.savePayloads).toHaveBeenCalledWith([{ uuid: '123' }])
})
it('encryptPayloadWithKeyLookup', async () => {
const mockPayload: DecryptedPayloadInterface = {
key_system_identifier: 'test-identifier',
} as DecryptedPayloadInterface
const mockKeyPair: PkcKeyPair = { publicKey: 'publicKey', privateKey: 'privateKey' }
const mockKey = { uuid: 'key-id', keyVersion: '004' } as KeySystemItemsKey
mockKeys.getPrimaryKeySystemItemsKey = jest.fn().mockReturnValue(mockKey)
itemsEncryptionService.encryptPayload = jest
.fn()
.mockResolvedValue({ content: '004:...' } as EncryptedOutputParameters)
const result = await itemsEncryptionService.encryptPayloadWithKeyLookup(mockPayload, mockKeyPair)
expect(mockKeys.getPrimaryKeySystemItemsKey).toHaveBeenCalledWith(mockPayload.key_system_identifier)
expect(itemsEncryptionService.encryptPayload).toHaveBeenCalledWith(mockPayload, mockKey, mockKeyPair)
expect(result).toEqual({ content: '004:...' })
})
})
@@ -97,7 +97,7 @@ export class ItemsEncryptionService extends AbstractService {
return this._findDefaultItemsKey.execute(this.getItemsKeys()).getValue()
}
private keyToUseForItemEncryption(
keyToUseForItemEncryption(
payload: DecryptedPayloadInterface,
): ItemsKeyInterface | KeySystemItemsKeyInterface | KeySystemRootKeyInterface | StandardException {
if (payload.key_system_identifier) {
@@ -132,7 +132,7 @@ export class ItemsEncryptionService extends AbstractService {
return result
}
private keyToUseForDecryptionOfPayload(
keyToUseForDecryptionOfPayload(
payload: EncryptedPayloadInterface,
): ItemsKeyInterface | KeySystemItemsKeyInterface | undefined {
if (payload.items_key_id) {

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