mirror of
https://github.com/standardnotes/app
synced 2026-09-13 09:46:02 -04:00
Compare commits
78
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b567d63b09 | ||
|
|
74458ab762 | ||
|
|
6b59810c70 | ||
|
|
1b48fec3dc | ||
|
|
ce96cd2998 | ||
|
|
f82974633b | ||
|
|
cd1b488769 | ||
|
|
6bd8a9c4e0 | ||
|
|
5617e37cd4 | ||
|
|
b10eb5f2e8 | ||
|
|
11110547f8 | ||
|
|
1da4b5e8ce | ||
|
|
2484c2147a | ||
|
|
c5324c0dd2 | ||
|
|
99b155cbf1 | ||
|
|
4ca0e89fcd | ||
|
|
b731c73cb2 | ||
|
|
3b531ce8bb | ||
|
|
a9edf671b1 | ||
|
|
9f50ad28b0 | ||
|
|
bff2fb624d | ||
|
|
0f1c8ef030 | ||
|
|
653af36363 | ||
|
|
5b88deeddb | ||
|
|
022be7d792 | ||
|
|
695d37beaa | ||
|
|
b08cff4dc2 | ||
|
|
1585d6b8ca | ||
|
|
0a51034b80 | ||
|
|
e253da6333 | ||
|
|
8a029950ec | ||
|
|
f0b3d939c5 | ||
|
|
a87d3c71f3 | ||
|
|
e4258a3e12 | ||
|
|
e2215f9a1f | ||
|
|
ee473fe34d | ||
|
|
cedd8e1006 | ||
|
|
4b278c4193 | ||
|
|
52ef2a8a70 | ||
|
|
8655bdb5dd | ||
|
|
d59e1befff | ||
|
|
a295b4f2f7 | ||
|
|
e61e1ff86d | ||
|
|
5473829c7e | ||
|
|
d2f8a36f19 | ||
|
|
1d60af0243 | ||
|
|
8f3ed30c44 | ||
|
|
3ae2b78116 | ||
|
|
4b24b58f21 | ||
|
|
07c23d24f0 | ||
|
|
eb4a446274 | ||
|
|
d8d4052a52 | ||
|
|
b07da5b663 | ||
|
|
ec309d6fb5 | ||
|
|
83b83cd96d | ||
|
|
3a0f929261 | ||
|
|
cf73edc524 | ||
|
|
de778de951 | ||
|
|
89f91178f8 | ||
|
|
7c959e7305 | ||
|
|
7205cf9bd6 | ||
|
|
494436bdb6 | ||
|
|
a7f266bb68 | ||
|
|
c42a559955 | ||
|
|
afc32121ee | ||
|
|
1abacff890 | ||
|
|
fc500b08d2 | ||
|
|
0642b589ff | ||
|
|
f7a1c6ea65 | ||
|
|
e8c7c10358 | ||
|
|
b3eab998f9 | ||
|
|
c76ffc764b | ||
|
|
5602a4014e | ||
|
|
0a544e936c | ||
|
|
027dd41147 | ||
|
|
2036689dd6 | ||
|
|
25596e70a8 | ||
|
|
9961f83246 |
@@ -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",
|
||||
|
||||
@@ -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.46](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/api
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/api",
|
||||
"version": "1.26.38",
|
||||
"version": "1.26.46",
|
||||
"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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,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,3 +1,4 @@
|
||||
export * from './HttpService'
|
||||
export * from './FetchRequestHandler'
|
||||
export * from './HttpServiceInterface'
|
||||
export * from './XMLHttpRequestState'
|
||||
|
||||
@@ -3,6 +3,106 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.156](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.155](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.154](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [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,7 +1,7 @@
|
||||
{
|
||||
"name": "@standardnotes/clipper",
|
||||
"description": "Web clipper browser extension for Standard Notes",
|
||||
"version": "1.1.131",
|
||||
"version": "1.1.156",
|
||||
"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)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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
|
||||
>
|
||||
}
|
||||
|
||||
@@ -3,6 +3,110 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.108.88](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.87](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.86](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [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
|
||||
|
||||
@@ -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,7 +1,7 @@
|
||||
{
|
||||
"name": "@standardnotes/desktop",
|
||||
"main": "./app/dist/index.js",
|
||||
"version": "3.108.62",
|
||||
"version": "3.108.88",
|
||||
"license": "CC BY-NC-SA 4.0",
|
||||
"author": "Standard Notes.",
|
||||
"private": true,
|
||||
|
||||
@@ -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.68](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/encryption
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/encryption",
|
||||
"version": "1.21.61",
|
||||
"version": "1.21.68",
|
||||
"engines": {
|
||||
"node": ">=16.0.0 <17.0.0"
|
||||
},
|
||||
|
||||
@@ -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.78](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/filepicker
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/filepicker",
|
||||
"version": "1.28.71",
|
||||
"version": "1.28.78",
|
||||
"engines": {
|
||||
"node": ">=16.0.0 <17.0.0"
|
||||
},
|
||||
|
||||
@@ -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.24](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/files
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/files",
|
||||
"version": "1.16.17",
|
||||
"version": "1.16.24",
|
||||
"engines": {
|
||||
"node": ">=16.0.0 <17.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,108 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.56.67](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.66](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.65](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [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
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/mobile",
|
||||
"version": "3.56.42",
|
||||
"version": "3.56.67",
|
||||
"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,
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -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.5](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/models
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/models",
|
||||
"version": "1.46.20",
|
||||
"version": "1.47.5",
|
||||
"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,
|
||||
}
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
import { KeySystemRootKeyContentSpecialized } from '../../../Syncable/KeySystemRootKey/KeySystemRootKeyContent'
|
||||
import { ContactPublicKeySetJsonInterface } from '../../../Syncable/TrustedContact/PublicKeySet/ContactPublicKeySetJsonInterface'
|
||||
import { EmojiString, IconType } from '../../../Utilities/Icon/IconType'
|
||||
import { AsymmetricMessageDataCommon } from '../AsymmetricMessageDataCommon'
|
||||
import { AsymmetricMessagePayloadType } from '../AsymmetricMessagePayloadType'
|
||||
|
||||
@@ -17,6 +18,7 @@ export type AsymmetricMessageSharedVaultInvite = {
|
||||
metadata: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,6 +8,9 @@ import { VaultListingContent } from './VaultListingContent'
|
||||
import { KeySystemRootKeyStorageMode } from '../KeySystemRootKey/KeySystemRootKeyStorageMode'
|
||||
import { VaultListingSharingInfo } from './VaultListingSharingInfo'
|
||||
import { KeySystemIdentifier } from '../KeySystemRootKey/KeySystemIdentifier'
|
||||
import { EmojiString, IconType } from '../../Utilities/Icon/IconType'
|
||||
|
||||
export const DefaultVaultIconName: IconType = 'safe-square'
|
||||
|
||||
export class VaultListing extends DecryptedItem<VaultListingContent> implements VaultListingInterface {
|
||||
systemIdentifier: KeySystemIdentifier
|
||||
@@ -17,6 +20,7 @@ export class VaultListing extends DecryptedItem<VaultListingContent> implements
|
||||
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
|
||||
sharing?: VaultListingSharingInfo
|
||||
|
||||
@@ -30,6 +34,7 @@ export class VaultListing extends DecryptedItem<VaultListingContent> implements
|
||||
|
||||
this.name = payload.content.name
|
||||
this.description = payload.content.description
|
||||
this.iconString = payload.content.iconString || DefaultVaultIconName
|
||||
|
||||
this.sharing = payload.content.sharing
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { KeySystemIdentifier } from '../KeySystemRootKey/KeySystemIdentifier'
|
||||
import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface'
|
||||
import { KeySystemRootKeyStorageMode } from '../KeySystemRootKey/KeySystemRootKeyStorageMode'
|
||||
import { VaultListingSharingInfo } from './VaultListingSharingInfo'
|
||||
import { EmojiString, IconType } from '../../Utilities/Icon/IconType'
|
||||
|
||||
export interface VaultListingContentSpecialized extends SpecializedContent {
|
||||
systemIdentifier: KeySystemIdentifier
|
||||
@@ -12,6 +13,7 @@ export interface VaultListingContentSpecialized extends SpecializedContent {
|
||||
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
|
||||
sharing?: VaultListingSharingInfo
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { KeySystemRootKeyStorageMode } from '../KeySystemRootKey/KeySystemRootKe
|
||||
import { VaultListingSharingInfo } from './VaultListingSharingInfo'
|
||||
import { VaultListingContent } from './VaultListingContent'
|
||||
import { DecryptedItemInterface } from '../../Abstract/Item'
|
||||
import { EmojiString, IconType } from '../../Utilities/Icon/IconType'
|
||||
|
||||
export interface VaultListingInterface extends DecryptedItemInterface<VaultListingContent> {
|
||||
systemIdentifier: KeySystemIdentifier
|
||||
@@ -14,6 +15,7 @@ export interface VaultListingInterface extends DecryptedItemInterface<VaultListi
|
||||
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
|
||||
sharing?: VaultListingSharingInfo
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { DecryptedItemMutator } from '../../Abstract/Item'
|
||||
import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface'
|
||||
import { EmojiString, IconType } from '../../Utilities/Icon/IconType'
|
||||
import { KeySystemRootKeyStorageMode } from '../KeySystemRootKey/KeySystemRootKeyStorageMode'
|
||||
import { VaultListingContent } from './VaultListingContent'
|
||||
import { VaultListingSharingInfo } from './VaultListingSharingInfo'
|
||||
@@ -13,6 +14,10 @@ export class VaultListingMutator extends DecryptedItemMutator<VaultListingConten
|
||||
this.mutableContent.description = description
|
||||
}
|
||||
|
||||
set iconString(iconString: IconType | EmojiString) {
|
||||
this.mutableContent.iconString = iconString
|
||||
}
|
||||
|
||||
set sharing(sharing: VaultListingSharingInfo | undefined) {
|
||||
this.mutableContent.sharing = sharing
|
||||
}
|
||||
|
||||
@@ -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>>
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -3,6 +3,110 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.4.440](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.439](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.438](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/releases",
|
||||
"version": "1.4.414",
|
||||
"version": "1.4.440",
|
||||
"license": "CC BY-NC-SA 4.0",
|
||||
"main": "dist/releases.json",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -3,6 +3,50 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.63.31](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
## [1.63.30](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-08-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
## [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,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/services",
|
||||
"version": "1.63.20",
|
||||
"version": "1.63.31",
|
||||
"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'
|
||||
@@ -48,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()
|
||||
@@ -73,6 +75,7 @@ describe('AsymmetricMessageService', () => {
|
||||
getOutboundMessagesUseCase,
|
||||
getInboundMessagesUseCase,
|
||||
getUntrustedPayload,
|
||||
getKeyPairs,
|
||||
eventBus,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { GetKeyPairs } from './../Encryption/UseCase/GetKeyPairs'
|
||||
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
|
||||
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
|
||||
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
|
||||
@@ -54,6 +55,7 @@ export class AsymmetricMessageService
|
||||
private _getOutboundMessagesUseCase: GetOutboundMessages,
|
||||
private _getInboundMessagesUseCase: GetInboundMessages,
|
||||
private _getUntrustedPayload: GetUntrustedPayload,
|
||||
private _getKeyPairs: GetKeyPairs,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
@@ -196,8 +198,13 @@ export class AsymmetricMessageService
|
||||
}
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
@@ -214,8 +221,13 @@ export class AsymmetricMessageService
|
||||
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,
|
||||
|
||||
+7
-5
@@ -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' })
|
||||
}
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ describe('ProcessAcceptedVaultInvite', () => {
|
||||
} as jest.Mocked<KeySystemRootKeyContent>,
|
||||
metadata: {
|
||||
name: 'test-name',
|
||||
iconString: 'safe-square',
|
||||
},
|
||||
trustedContacts: [],
|
||||
},
|
||||
|
||||
+5
-4
@@ -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
|
||||
|
||||
@@ -32,9 +32,10 @@ export class ProcessAcceptedVaultInvite {
|
||||
keyStorageMode: KeySystemRootKeyStorageMode.Synced,
|
||||
name: metadata.name,
|
||||
description: metadata.description,
|
||||
iconString: metadata.iconString,
|
||||
sharing: {
|
||||
sharedVaultUuid: sharedVaultUuid,
|
||||
ownerUserUuid: senderUuid,
|
||||
ownerUserUuid: ownerUuid,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -47,7 +48,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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -8,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'
|
||||
@@ -26,7 +26,7 @@ export class ContactService extends AbstractService<ContactServiceEvent> impleme
|
||||
private mutator: MutatorClientInterface,
|
||||
private session: SessionsClientInterface,
|
||||
private crypto: PureCryptoInterface,
|
||||
private user: UserClientInterface,
|
||||
private user: UserServiceInterface,
|
||||
private selfContactManager: SelfContactManager,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private _deleteContact: DeleteContact,
|
||||
@@ -192,7 +192,7 @@ export class ContactService extends AbstractService<ContactServiceEvent> impleme
|
||||
}
|
||||
|
||||
findContactForInvite(invite: SharedVaultInviteServerHash): TrustedContactInterface | undefined {
|
||||
return this.findContact(invite.sender_uuid)
|
||||
return this.findContact(invite.user_uuid)
|
||||
}
|
||||
|
||||
getCollaborationIDForTrustedContact(contact: TrustedContactInterface): string {
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+1
-5
@@ -1,11 +1,7 @@
|
||||
export interface MfaProvider {
|
||||
export interface MfaServiceInterface {
|
||||
isMfaActivated(): Promise<boolean>
|
||||
|
||||
generateMfaSecret(): Promise<string>
|
||||
|
||||
getOtpToken(secret: string): Promise<string>
|
||||
|
||||
enableMfa(secret: string, otpToken: string): Promise<void>
|
||||
|
||||
disableMfa(): Promise<void>
|
||||
}
|
||||
@@ -6,9 +6,9 @@ export enum PreferencesServiceEvent {
|
||||
}
|
||||
|
||||
export interface PreferenceServiceInterface extends AbstractService<PreferencesServiceEvent> {
|
||||
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K] | undefined): PrefValue[K] | undefined
|
||||
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K]): PrefValue[K]
|
||||
getValue<K extends PrefKey>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] | undefined
|
||||
getValue<K extends PrefKey>(key: K, defaultValue: PrefValue[K] | undefined): PrefValue[K] | undefined
|
||||
|
||||
setValue<K extends PrefKey>(key: K, value: PrefValue[K]): Promise<void>
|
||||
/** Set value without triggering sync or event notifications */
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { ApplicationServiceInterface } from './../Service/ApplicationServiceInterface'
|
||||
import { DecryptedItem, DecryptedItemInterface, FileItem, SNNote } from '@standardnotes/models'
|
||||
import { ChallengeInterface, ChallengeReason } from '../Challenge'
|
||||
import { MobileUnlockTiming } from './MobileUnlockTiming'
|
||||
import { TimingDisplayOption } from './TimingDisplayOption'
|
||||
import { ProtectionEvent } from './ProtectionEvent'
|
||||
|
||||
export interface ProtectionsClientInterface extends ApplicationServiceInterface<ProtectionEvent, unknown> {
|
||||
isLocked(): Promise<boolean>
|
||||
softLockBiometrics(): void
|
||||
|
||||
export interface ProtectionsClientInterface {
|
||||
createLaunchChallenge(): ChallengeInterface | undefined
|
||||
authorizeProtectedActionForItems<T extends DecryptedItem>(files: T[], challengeReason: ChallengeReason): Promise<T[]>
|
||||
authorizeItemAccess(item: DecryptedItem): Promise<boolean>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum ProtectionEvent {
|
||||
UnprotectedSessionBegan = 'Protection:UnprotectedSessionBegan',
|
||||
UnprotectedSessionExpired = 'Protection:UnprotectedSessionExpired',
|
||||
BiometricsSoftLockEngaged = 'Protection:BiometricsSoftLockEngaged',
|
||||
BiometricsSoftLockDisengaged = 'Protection:BiometricsSoftLockDisengaged',
|
||||
}
|
||||
@@ -20,11 +20,13 @@ export interface SessionsClientInterface {
|
||||
|
||||
getUser(): User | undefined
|
||||
isSignedIn(): boolean
|
||||
isSignedOut(): boolean
|
||||
get userUuid(): string
|
||||
getSureUser(): User
|
||||
isSignedIntoFirstPartyServer(): boolean
|
||||
|
||||
getSessionsList(): Promise<HttpResponse<SessionListEntry[]>>
|
||||
refreshSessionIfExpiringSoon(): Promise<boolean>
|
||||
revokeSession(sessionId: string): Promise<HttpResponse<SessionListResponse>>
|
||||
revokeAllOtherSessions(): Promise<void>
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import { DiscardItemsLocally } from './../UseCase/DiscardItemsLocally'
|
||||
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
|
||||
import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults'
|
||||
import { IsVaultOwner } from './../VaultUser/UseCase/IsVaultOwner'
|
||||
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
|
||||
import { DeleteSharedVault } from './UseCase/DeleteSharedVault'
|
||||
import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault'
|
||||
import { ShareContactWithVault } from './UseCase/ShareContactWithVault'
|
||||
import { DeleteThirdPartyVault } from './UseCase/DeleteExternalSharedVault'
|
||||
import { FindContact } from './../Contacts/UseCase/FindContact'
|
||||
import { SendVaultDataChangedMessage } from './UseCase/SendVaultDataChangedMessage'
|
||||
import { NotifyVaultUsersOfKeyRotation } from './UseCase/NotifyVaultUsersOfKeyRotation'
|
||||
import { HandleKeyPairChange } from './../Contacts/UseCase/HandleKeyPairChange'
|
||||
import { CreateSharedVault } from './UseCase/CreateSharedVault'
|
||||
import { GetVault } from './../Vault/UseCase/GetVault'
|
||||
@@ -29,20 +25,16 @@ describe('SharedVaultService', () => {
|
||||
const items = {} as jest.Mocked<ItemManagerInterface>
|
||||
items.addObserver = jest.fn()
|
||||
|
||||
const encryption = {} as jest.Mocked<EncryptionProviderInterface>
|
||||
const session = {} as jest.Mocked<SessionsClientInterface>
|
||||
const getVault = {} as jest.Mocked<GetVault>
|
||||
const getOwnedVaults = {} as jest.Mocked<GetOwnedSharedVaults>
|
||||
const createSharedVaultUseCase = {} as jest.Mocked<CreateSharedVault>
|
||||
const handleKeyPairChange = {} as jest.Mocked<HandleKeyPairChange>
|
||||
const notifyVaultUsersOfKeyRotation = {} as jest.Mocked<NotifyVaultUsersOfKeyRotation>
|
||||
const sendVaultDataChangeMessage = {} as jest.Mocked<SendVaultDataChangedMessage>
|
||||
const findContact = {} as jest.Mocked<FindContact>
|
||||
const deleteThirdPartyVault = {} as jest.Mocked<DeleteThirdPartyVault>
|
||||
const shareContactWithVault = {} as jest.Mocked<ShareContactWithVault>
|
||||
const convertToSharedVault = {} as jest.Mocked<ConvertToSharedVault>
|
||||
const deleteSharedVaultUseCase = {} as jest.Mocked<DeleteSharedVault>
|
||||
const isVaultAdmin = {} as jest.Mocked<IsVaultOwner>
|
||||
const discardItemsLocally = {} as jest.Mocked<DiscardItemsLocally>
|
||||
|
||||
const eventBus = {} as jest.Mocked<InternalEventBusInterface>
|
||||
@@ -50,20 +42,16 @@ describe('SharedVaultService', () => {
|
||||
|
||||
service = new SharedVaultService(
|
||||
items,
|
||||
encryption,
|
||||
session,
|
||||
getVault,
|
||||
getOwnedVaults,
|
||||
createSharedVaultUseCase,
|
||||
handleKeyPairChange,
|
||||
notifyVaultUsersOfKeyRotation,
|
||||
sendVaultDataChangeMessage,
|
||||
findContact,
|
||||
deleteThirdPartyVault,
|
||||
shareContactWithVault,
|
||||
convertToSharedVault,
|
||||
deleteSharedVaultUseCase,
|
||||
isVaultAdmin,
|
||||
discardItemsLocally,
|
||||
eventBus,
|
||||
)
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
SharedVaultListingInterface,
|
||||
VaultListingInterface,
|
||||
KeySystemRootKeyStorageMode,
|
||||
EmojiString,
|
||||
IconType,
|
||||
} from '@standardnotes/models'
|
||||
import { SharedVaultServiceInterface } from './SharedVaultServiceInterface'
|
||||
import { SharedVaultServiceEvent, SharedVaultServiceEventPayload } from './SharedVaultServiceEvent'
|
||||
@@ -22,18 +24,13 @@ import { InternalEventInterface } from '../Internal/InternalEventInterface'
|
||||
import { NotificationServiceEvent, NotificationServiceEventPayload } from '../UserEvent/NotificationServiceEvent'
|
||||
import { DeleteThirdPartyVault } from './UseCase/DeleteExternalSharedVault'
|
||||
import { DeleteSharedVault } from './UseCase/DeleteSharedVault'
|
||||
import { VaultServiceEvent, VaultServiceEventPayload } from '../Vault/VaultServiceEvent'
|
||||
import { ShareContactWithVault } from './UseCase/ShareContactWithVault'
|
||||
import { NotifyVaultUsersOfKeyRotation } from './UseCase/NotifyVaultUsersOfKeyRotation'
|
||||
import { CreateSharedVault } from './UseCase/CreateSharedVault'
|
||||
import { SendVaultDataChangedMessage } from './UseCase/SendVaultDataChangedMessage'
|
||||
import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { ContentType, NotificationType, Uuid } from '@standardnotes/domain-core'
|
||||
import { HandleKeyPairChange } from '../Contacts/UseCase/HandleKeyPairChange'
|
||||
import { FindContact } from '../Contacts/UseCase/FindContact'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
import { IsVaultOwner } from '../VaultUser/UseCase/IsVaultOwner'
|
||||
import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults'
|
||||
|
||||
export class SharedVaultService
|
||||
@@ -42,20 +39,16 @@ export class SharedVaultService
|
||||
{
|
||||
constructor(
|
||||
private items: ItemManagerInterface,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private session: SessionsClientInterface,
|
||||
private _getVault: GetVault,
|
||||
private _getOwnedSharedVaults: GetOwnedSharedVaults,
|
||||
private _createSharedVault: CreateSharedVault,
|
||||
private _handleKeyPairChange: HandleKeyPairChange,
|
||||
private _notifyVaultUsersOfKeyRotation: NotifyVaultUsersOfKeyRotation,
|
||||
private _sendVaultDataChangeMessage: SendVaultDataChangedMessage,
|
||||
private _findContact: FindContact,
|
||||
private _deleteThirdPartyVault: DeleteThirdPartyVault,
|
||||
private _shareContactWithVault: ShareContactWithVault,
|
||||
private _convertToSharedVault: ConvertToSharedVault,
|
||||
private _deleteSharedVault: DeleteSharedVault,
|
||||
private _isVaultAdmin: IsVaultOwner,
|
||||
private _discardItemsLocally: DiscardItemsLocally,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
@@ -68,32 +61,20 @@ export class SharedVaultService
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
this.eventDisposers.push(
|
||||
items.addObserver<VaultListingInterface>(ContentType.TYPES.VaultListing, ({ changed, source }) => {
|
||||
if (source === PayloadEmitSource.LocalChanged && changed.length > 0) {
|
||||
void this.handleVaultListingsChange(changed)
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.items as unknown) = undefined
|
||||
;(this.encryption as unknown) = undefined
|
||||
;(this.session as unknown) = undefined
|
||||
;(this._getVault as unknown) = undefined
|
||||
;(this._createSharedVault as unknown) = undefined
|
||||
;(this._handleKeyPairChange as unknown) = undefined
|
||||
;(this._notifyVaultUsersOfKeyRotation as unknown) = undefined
|
||||
;(this._sendVaultDataChangeMessage as unknown) = undefined
|
||||
;(this._findContact as unknown) = undefined
|
||||
;(this._deleteThirdPartyVault as unknown) = undefined
|
||||
;(this._shareContactWithVault as unknown) = undefined
|
||||
;(this._convertToSharedVault as unknown) = undefined
|
||||
;(this._deleteSharedVault as unknown) = undefined
|
||||
;(this._isVaultAdmin as unknown) = undefined
|
||||
}
|
||||
|
||||
async handleEvent(event: InternalEventInterface): Promise<void> {
|
||||
@@ -109,11 +90,6 @@ export class SharedVaultService
|
||||
case NotificationServiceEvent.NotificationReceived:
|
||||
await this.handleUserEvent(event.payload as NotificationServiceEventPayload)
|
||||
break
|
||||
case VaultServiceEvent.VaultRootKeyRotated: {
|
||||
const payload = event.payload as VaultServiceEventPayload[VaultServiceEvent.VaultRootKeyRotated]
|
||||
await this.handleVaultRootKeyRotatedEvent(payload.vault)
|
||||
break
|
||||
}
|
||||
case SyncEvent.ReceivedRemoteSharedVaults:
|
||||
void this.notifyEventSync(SharedVaultServiceEvent.SharedVaultStatusChanged)
|
||||
break
|
||||
@@ -141,42 +117,17 @@ export class SharedVaultService
|
||||
}
|
||||
}
|
||||
|
||||
private isCurrentUserVaultOwner(sharedVault: SharedVaultListingInterface): boolean {
|
||||
if (!sharedVault.sharing.ownerUserUuid) {
|
||||
throw new Error(`Shared vault ${sharedVault.sharing.sharedVaultUuid} does not have an owner user uuid`)
|
||||
}
|
||||
|
||||
return sharedVault.sharing.ownerUserUuid === this.session.userUuid
|
||||
}
|
||||
|
||||
private async handleVaultRootKeyRotatedEvent(vault: VaultListingInterface): Promise<void> {
|
||||
if (!vault.isSharedVaultListing()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.isCurrentUserVaultOwner(vault)) {
|
||||
return
|
||||
}
|
||||
|
||||
await this._notifyVaultUsersOfKeyRotation.execute({
|
||||
sharedVault: vault,
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async createSharedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference?: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface | ClientDisplayableError> {
|
||||
return this._createSharedVault.execute({
|
||||
vaultName: dto.name,
|
||||
vaultDescription: dto.description,
|
||||
vaultIcon: dto.iconString,
|
||||
userInputtedPassword: dto.userInputtedPassword,
|
||||
storagePreference: dto.storagePreference ?? KeySystemRootKeyStorageMode.Synced,
|
||||
})
|
||||
@@ -198,23 +149,6 @@ export class SharedVaultService
|
||||
}
|
||||
}
|
||||
|
||||
private async handleVaultListingsChange(vaults: VaultListingInterface[]): Promise<void> {
|
||||
for (const vault of vaults) {
|
||||
if (!vault.isSharedVaultListing()) {
|
||||
continue
|
||||
}
|
||||
|
||||
await this._sendVaultDataChangeMessage.execute({
|
||||
vault,
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void> {
|
||||
return this._deleteSharedVault.execute({ sharedVault })
|
||||
}
|
||||
@@ -224,17 +158,12 @@ export class SharedVaultService
|
||||
throw new Error('Cannot share self contact')
|
||||
}
|
||||
|
||||
const ownedVaults = this._getOwnedSharedVaults.execute({ userUuid: this.session.userUuid }).getValue()
|
||||
const ownedVaults = this._getOwnedSharedVaults.execute().getValue()
|
||||
|
||||
for (const vault of ownedVaults) {
|
||||
await this._shareContactWithVault.execute({
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
},
|
||||
sharedVault: vault,
|
||||
contactToShare: contact,
|
||||
senderUserUuid: this.session.getSureUser().uuid,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { GetVaultItems } from './../../Vault/UseCase/GetVaultItems'
|
||||
import { SharedVaultListingInterface, VaultListingInterface, VaultListingMutator } from '@standardnotes/models'
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultServerInterface } from '@standardnotes/api'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { MoveItemsToVault } from '../../Vault/UseCase/MoveItemsToVault'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
|
||||
export class ConvertToSharedVault {
|
||||
constructor(
|
||||
private items: ItemManagerInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
private sharedVaultServer: SharedVaultServerInterface,
|
||||
private moveItemsToVault: MoveItemsToVault,
|
||||
private _moveItemsToVault: MoveItemsToVault,
|
||||
private _getVaultItems: GetVaultItems,
|
||||
) {}
|
||||
|
||||
async execute(dto: { vault: VaultListingInterface }): Promise<SharedVaultListingInterface | ClientDisplayableError> {
|
||||
@@ -35,9 +35,9 @@ export class ConvertToSharedVault {
|
||||
},
|
||||
)
|
||||
|
||||
const vaultItems = this.items.itemsBelongingToKeySystem(sharedVaultListing.systemIdentifier)
|
||||
const vaultItems = this._getVaultItems.execute(sharedVaultListing).getValue()
|
||||
|
||||
await this.moveItemsToVault.execute({ vault: sharedVaultListing, items: vaultItems })
|
||||
await this._moveItemsToVault.execute({ vault: sharedVaultListing, items: vaultItems })
|
||||
|
||||
return sharedVaultListing as SharedVaultListingInterface
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { GetVaultItems } from './../../Vault/UseCase/GetVaultItems'
|
||||
import {
|
||||
EmojiString,
|
||||
IconType,
|
||||
KeySystemRootKeyStorageMode,
|
||||
SharedVaultListingInterface,
|
||||
VaultListingInterface,
|
||||
@@ -6,36 +9,37 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultServerInterface } from '@standardnotes/api'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { CreateVault } from '../../Vault/UseCase/CreateVault'
|
||||
import { MoveItemsToVault } from '../../Vault/UseCase/MoveItemsToVault'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
|
||||
export class CreateSharedVault {
|
||||
constructor(
|
||||
private items: ItemManagerInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
private sharedVaultServer: SharedVaultServerInterface,
|
||||
private createVault: CreateVault,
|
||||
private moveItemsToVault: MoveItemsToVault,
|
||||
private _createVault: CreateVault,
|
||||
private _moveItemsToVault: MoveItemsToVault,
|
||||
private _getVaultItems: GetVaultItems,
|
||||
) {}
|
||||
|
||||
async execute(dto: {
|
||||
vaultName: string
|
||||
vaultDescription?: string
|
||||
vaultIcon: IconType | EmojiString
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<SharedVaultListingInterface | ClientDisplayableError> {
|
||||
const privateVault = await this.createVault.execute({
|
||||
const privateVault = await this._createVault.execute({
|
||||
vaultName: dto.vaultName,
|
||||
vaultDescription: dto.vaultDescription,
|
||||
vaultIcon: dto.vaultIcon,
|
||||
userInputtedPassword: dto.userInputtedPassword,
|
||||
storagePreference: dto.storagePreference,
|
||||
})
|
||||
|
||||
const serverResult = await this.sharedVaultServer.createSharedVault()
|
||||
if (isErrorResponse(serverResult)) {
|
||||
return ClientDisplayableError.FromString(`Failed to create shared vault ${JSON.stringify(serverResult)}`)
|
||||
return ClientDisplayableError.FromString(`Failed to create shared vault: ${serverResult.data.error?.message}`)
|
||||
}
|
||||
|
||||
const serverVaultHash = serverResult.data.sharedVault
|
||||
@@ -50,9 +54,9 @@ export class CreateSharedVault {
|
||||
},
|
||||
)
|
||||
|
||||
const vaultItems = this.items.itemsBelongingToKeySystem(sharedVaultListing.systemIdentifier)
|
||||
const vaultItems = this._getVaultItems.execute(sharedVaultListing).getValue()
|
||||
|
||||
await this.moveItemsToVault.execute({ vault: sharedVaultListing, items: vaultItems })
|
||||
await this._moveItemsToVault.execute({ vault: sharedVaultListing, items: vaultItems })
|
||||
|
||||
return sharedVaultListing as SharedVaultListingInterface
|
||||
}
|
||||
|
||||
@@ -5,20 +5,15 @@ import { GetSharedVaults } from './GetSharedVaults'
|
||||
|
||||
export class GetOwnedSharedVaults implements SyncUseCaseInterface<SharedVaultListingInterface[]> {
|
||||
constructor(
|
||||
private getSharedVaults: GetSharedVaults,
|
||||
private isVaultOwnwer: IsVaultOwner,
|
||||
private _getSharedVaults: GetSharedVaults,
|
||||
private _isVaultOwnwer: IsVaultOwner,
|
||||
) {}
|
||||
|
||||
execute(dto: { userUuid: string }): Result<SharedVaultListingInterface[]> {
|
||||
const sharedVaults = this.getSharedVaults.execute().getValue()
|
||||
execute(): Result<SharedVaultListingInterface[]> {
|
||||
const sharedVaults = this._getSharedVaults.execute().getValue()
|
||||
|
||||
const ownedVaults = sharedVaults.filter((vault) => {
|
||||
return this.isVaultOwnwer
|
||||
.execute({
|
||||
sharedVault: vault,
|
||||
userUuid: dto.userUuid,
|
||||
})
|
||||
.getValue()
|
||||
return this._isVaultOwnwer.execute(vault).getValue()
|
||||
})
|
||||
|
||||
return Result.ok(ownedVaults)
|
||||
|
||||
+21
-24
@@ -2,30 +2,26 @@ import { SharedVaultInvitesServerInterface } from '@standardnotes/api'
|
||||
import { AsymmetricMessageSharedVaultInvite, SharedVaultListingInterface } from '@standardnotes/models'
|
||||
import { SharedVaultInviteServerHash, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SendVaultKeyChangedMessage } from './SendVaultKeyChangedMessage'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { InviteToVault } from '../../VaultInvite/UseCase/InviteToVault'
|
||||
import { GetVaultContacts } from '../../VaultUser/UseCase/GetVaultContacts'
|
||||
import { DecryptOwnMessage } from '../../Encryption/UseCase/Asymmetric/DecryptOwnMessage'
|
||||
import { FindContact } from '../../Contacts/UseCase/FindContact'
|
||||
import { GetKeyPairs } from '../../Encryption/UseCase/GetKeyPairs'
|
||||
|
||||
type Params = {
|
||||
keys: {
|
||||
encryption: PkcKeyPair
|
||||
signing: PkcKeyPair
|
||||
}
|
||||
sharedVault: SharedVaultListingInterface
|
||||
senderUuid: string
|
||||
}
|
||||
|
||||
export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private findContact: FindContact,
|
||||
private sendKeyChangedMessage: SendVaultKeyChangedMessage,
|
||||
private inviteToVault: InviteToVault,
|
||||
private inviteServer: SharedVaultInvitesServerInterface,
|
||||
private getVaultContacts: GetVaultContacts,
|
||||
private decryptOwnMessage: DecryptOwnMessage<AsymmetricMessageSharedVaultInvite>,
|
||||
private _findContact: FindContact,
|
||||
private _sendKeyChangedMessage: SendVaultKeyChangedMessage,
|
||||
private _inviteToVault: InviteToVault,
|
||||
private _inviteServer: SharedVaultInvitesServerInterface,
|
||||
private _getVaultContacts: GetVaultContacts,
|
||||
private _decryptOwnMessage: DecryptOwnMessage<AsymmetricMessageSharedVaultInvite>,
|
||||
private _getKeyPairs: GetKeyPairs,
|
||||
) {}
|
||||
|
||||
async execute(params: Params): Promise<Result<void>> {
|
||||
@@ -44,20 +40,25 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
|
||||
await this.deleteAllInvites(params.sharedVault.sharing.sharedVaultUuid)
|
||||
|
||||
const contacts = await this.getVaultContacts.execute({
|
||||
const contacts = await this._getVaultContacts.execute({
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
|
||||
const keys = this._getKeyPairs.execute()
|
||||
if (keys.isFailed()) {
|
||||
return Result.fail('Cannot send metadata changed message; keys not found')
|
||||
}
|
||||
|
||||
for (const invite of existingInvites.getValue()) {
|
||||
const recipient = this.findContact.execute({ userUuid: invite.user_uuid })
|
||||
const recipient = this._findContact.execute({ userUuid: invite.user_uuid })
|
||||
if (recipient.isFailed()) {
|
||||
continue
|
||||
}
|
||||
|
||||
const decryptedPreviousInvite = this.decryptOwnMessage.execute({
|
||||
const decryptedPreviousInvite = this._decryptOwnMessage.execute({
|
||||
message: invite.encrypted_message,
|
||||
privateKey: params.keys.encryption.privateKey,
|
||||
privateKey: keys.getValue().encryption.privateKey,
|
||||
recipientPublicKey: recipient.getValue().publicKeySet.encryption,
|
||||
})
|
||||
|
||||
@@ -65,13 +66,11 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
return Result.fail(decryptedPreviousInvite.getError())
|
||||
}
|
||||
|
||||
await this.inviteToVault.execute({
|
||||
keys: params.keys,
|
||||
await this._inviteToVault.execute({
|
||||
sharedVault: params.sharedVault,
|
||||
sharedVaultContacts: !contacts.isFailed() ? contacts.getValue() : [],
|
||||
recipient: recipient.getValue(),
|
||||
permission: invite.permission,
|
||||
senderUuid: params.senderUuid,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,11 +78,9 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
}
|
||||
|
||||
private async performSendKeyChangeMessage(params: Params): Promise<Result<void>> {
|
||||
const result = await this.sendKeyChangedMessage.execute({
|
||||
const result = await this._sendKeyChangedMessage.execute({
|
||||
keySystemIdentifier: params.sharedVault.systemIdentifier,
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
senderUuid: params.senderUuid,
|
||||
keys: params.keys,
|
||||
})
|
||||
|
||||
if (result.isFailed()) {
|
||||
@@ -94,7 +91,7 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
}
|
||||
|
||||
private async deleteAllInvites(sharedVaultUuid: string): Promise<Result<void>> {
|
||||
const response = await this.inviteServer.deleteAllSharedVaultInvites({
|
||||
const response = await this._inviteServer.deleteAllSharedVaultInvites({
|
||||
sharedVaultUuid: sharedVaultUuid,
|
||||
})
|
||||
|
||||
@@ -106,7 +103,7 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
}
|
||||
|
||||
private async getExistingInvites(sharedVaultUuid: string): Promise<Result<SharedVaultInviteServerHash[]>> {
|
||||
const response = await this.inviteServer.getOutboundUserInvites()
|
||||
const response = await this._inviteServer.getOutboundUserInvites()
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return Result.fail(`Failed to get outbound user invites ${JSON.stringify(response)}`)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { UserServiceInterface } from './../../User/UserServiceInterface'
|
||||
import { IsVaultOwner } from './../../VaultUser/UseCase/IsVaultOwner'
|
||||
import {
|
||||
AsymmetricMessagePayloadType,
|
||||
AsymmetricMessageSharedVaultMetadataChanged,
|
||||
@@ -12,24 +14,26 @@ import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessa
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { GetReplaceabilityIdentifier } from '../../AsymmetricMessage/UseCase/GetReplaceabilityIdentifier'
|
||||
import { FindContact } from '../../Contacts/UseCase/FindContact'
|
||||
import { GetKeyPairs } from '../../Encryption/UseCase/GetKeyPairs'
|
||||
|
||||
export class SendVaultDataChangedMessage implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private encryptMessage: EncryptMessage,
|
||||
private findContact: FindContact,
|
||||
private getVaultUsers: GetVaultUsers,
|
||||
private sendMessage: SendMessage,
|
||||
private users: UserServiceInterface,
|
||||
private _encryptMessage: EncryptMessage,
|
||||
private _findContact: FindContact,
|
||||
private _getVaultUsers: GetVaultUsers,
|
||||
private _sendMessage: SendMessage,
|
||||
private _isVaultOwner: IsVaultOwner,
|
||||
private _getKeyPairs: GetKeyPairs,
|
||||
) {}
|
||||
|
||||
async execute(params: {
|
||||
vault: SharedVaultListingInterface
|
||||
senderUuid: string
|
||||
keys: {
|
||||
encryption: PkcKeyPair
|
||||
signing: PkcKeyPair
|
||||
async execute(params: { vault: SharedVaultListingInterface }): Promise<Result<void>> {
|
||||
const isOwner = this._isVaultOwner.execute(params.vault).getValue()
|
||||
if (!isOwner) {
|
||||
return Result.ok()
|
||||
}
|
||||
}): Promise<Result<void>> {
|
||||
const users = await this.getVaultUsers.execute({
|
||||
|
||||
const users = await this._getVaultUsers.execute({
|
||||
sharedVaultUuid: params.vault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
@@ -37,20 +41,25 @@ export class SendVaultDataChangedMessage implements UseCaseInterface<void> {
|
||||
return Result.fail('Cannot send metadata changed message; users not found')
|
||||
}
|
||||
|
||||
const keys = this._getKeyPairs.execute()
|
||||
if (keys.isFailed()) {
|
||||
return Result.fail('Cannot send metadata changed message; keys not found')
|
||||
}
|
||||
|
||||
const errors: string[] = []
|
||||
for (const user of users.getValue()) {
|
||||
if (user.user_uuid === params.senderUuid) {
|
||||
if (user.user_uuid === this.users.sureUser.uuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
const trustedContact = this.findContact.execute({ userUuid: user.user_uuid })
|
||||
const trustedContact = this._findContact.execute({ userUuid: user.user_uuid })
|
||||
if (trustedContact.isFailed()) {
|
||||
continue
|
||||
}
|
||||
|
||||
const sendMessageResult = await this.sendToContact({
|
||||
vault: params.vault,
|
||||
keys: params.keys,
|
||||
keys: keys.getValue(),
|
||||
contact: trustedContact.getValue(),
|
||||
})
|
||||
|
||||
@@ -84,7 +93,7 @@ export class SendVaultDataChangedMessage implements UseCaseInterface<void> {
|
||||
},
|
||||
}
|
||||
|
||||
const encryptedMessage = this.encryptMessage.execute({
|
||||
const encryptedMessage = this._encryptMessage.execute({
|
||||
message: message,
|
||||
keys: params.keys,
|
||||
recipientPublicKey: params.contact.publicKeySet.encryption,
|
||||
@@ -100,7 +109,7 @@ export class SendVaultDataChangedMessage implements UseCaseInterface<void> {
|
||||
params.vault.systemIdentifier,
|
||||
)
|
||||
|
||||
const sendMessageResult = await this.sendMessage.execute({
|
||||
const sendMessageResult = await this._sendMessage.execute({
|
||||
recipientUuid: params.contact.contactUuid,
|
||||
encryptedMessage: encryptedMessage.getValue(),
|
||||
replaceabilityIdentifier,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { UserServiceInterface } from './../../User/UserServiceInterface'
|
||||
import {
|
||||
AsymmetricMessagePayloadType,
|
||||
AsymmetricMessageSharedVaultRootKeyChanged,
|
||||
@@ -13,38 +14,38 @@ import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { GetReplaceabilityIdentifier } from '../../AsymmetricMessage/UseCase/GetReplaceabilityIdentifier'
|
||||
import { FindContact } from '../../Contacts/UseCase/FindContact'
|
||||
import { KeySystemKeyManagerInterface } from '../../KeySystem/KeySystemKeyManagerInterface'
|
||||
import { GetKeyPairs } from '../../Encryption/UseCase/GetKeyPairs'
|
||||
|
||||
export class SendVaultKeyChangedMessage implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private encryptMessage: EncryptMessage,
|
||||
private users: UserServiceInterface,
|
||||
private keyManager: KeySystemKeyManagerInterface,
|
||||
private findContact: FindContact,
|
||||
private sendMessage: SendMessage,
|
||||
private getVaultUsers: GetVaultUsers,
|
||||
private _encryptMessage: EncryptMessage,
|
||||
private _findContact: FindContact,
|
||||
private _sendMessage: SendMessage,
|
||||
private _getVaultUsers: GetVaultUsers,
|
||||
private _getKeyPairs: GetKeyPairs,
|
||||
) {}
|
||||
|
||||
async execute(params: {
|
||||
keySystemIdentifier: KeySystemIdentifier
|
||||
sharedVaultUuid: string
|
||||
senderUuid: string
|
||||
keys: {
|
||||
encryption: PkcKeyPair
|
||||
signing: PkcKeyPair
|
||||
}
|
||||
}): Promise<Result<void>> {
|
||||
const users = await this.getVaultUsers.execute({ sharedVaultUuid: params.sharedVaultUuid, readFromCache: false })
|
||||
async execute(params: { keySystemIdentifier: KeySystemIdentifier; sharedVaultUuid: string }): Promise<Result<void>> {
|
||||
const users = await this._getVaultUsers.execute({ sharedVaultUuid: params.sharedVaultUuid, readFromCache: false })
|
||||
if (users.isFailed()) {
|
||||
return Result.fail('Cannot send root key changed message; users not found')
|
||||
}
|
||||
|
||||
const keys = this._getKeyPairs.execute()
|
||||
if (keys.isFailed()) {
|
||||
return Result.fail('Cannot send root key changed message; keys not found')
|
||||
}
|
||||
|
||||
const errors: string[] = []
|
||||
|
||||
for (const user of users.getValue()) {
|
||||
if (user.user_uuid === params.senderUuid) {
|
||||
if (user.user_uuid === this.users.sureUser.uuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
const trustedContact = this.findContact.execute({ userUuid: user.user_uuid })
|
||||
const trustedContact = this._findContact.execute({ userUuid: user.user_uuid })
|
||||
if (trustedContact.isFailed()) {
|
||||
continue
|
||||
}
|
||||
@@ -52,7 +53,7 @@ export class SendVaultKeyChangedMessage implements UseCaseInterface<void> {
|
||||
const result = await this.sendToContact({
|
||||
keySystemIdentifier: params.keySystemIdentifier,
|
||||
sharedVaultUuid: params.sharedVaultUuid,
|
||||
keys: params.keys,
|
||||
keys: keys.getValue(),
|
||||
contact: trustedContact.getValue(),
|
||||
})
|
||||
|
||||
@@ -87,7 +88,7 @@ export class SendVaultKeyChangedMessage implements UseCaseInterface<void> {
|
||||
data: { recipientUuid: params.contact.contactUuid, rootKey: keySystemRootKey.content },
|
||||
}
|
||||
|
||||
const encryptedMessage = this.encryptMessage.execute({
|
||||
const encryptedMessage = this._encryptMessage.execute({
|
||||
message: message,
|
||||
keys: params.keys,
|
||||
recipientPublicKey: params.contact.publicKeySet.encryption,
|
||||
@@ -103,7 +104,7 @@ export class SendVaultKeyChangedMessage implements UseCaseInterface<void> {
|
||||
params.keySystemIdentifier,
|
||||
)
|
||||
|
||||
const sendMessageResult = await this.sendMessage.execute({
|
||||
const sendMessageResult = await this._sendMessage.execute({
|
||||
recipientUuid: params.contact.contactUuid,
|
||||
encryptedMessage: encryptedMessage.getValue(),
|
||||
replaceabilityIdentifier,
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
import { UserServiceInterface } from './../../User/UserServiceInterface'
|
||||
import {
|
||||
TrustedContactInterface,
|
||||
SharedVaultListingInterface,
|
||||
AsymmetricMessagePayloadType,
|
||||
} from '@standardnotes/models'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { SendMessage } from '../../AsymmetricMessage/UseCase/SendMessage'
|
||||
import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { FindContact } from '../../Contacts/UseCase/FindContact'
|
||||
import { GetVaultUsers } from '../../VaultUser/UseCase/GetVaultUsers'
|
||||
import { GetKeyPairs } from '../../Encryption/UseCase/GetKeyPairs'
|
||||
|
||||
export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private findContact: FindContact,
|
||||
private encryptMessage: EncryptMessage,
|
||||
private sendMessage: SendMessage,
|
||||
private getVaultUsers: GetVaultUsers,
|
||||
private users: UserServiceInterface,
|
||||
private _findContact: FindContact,
|
||||
private _encryptMessage: EncryptMessage,
|
||||
private _sendMessage: SendMessage,
|
||||
private _getVaultUsers: GetVaultUsers,
|
||||
private _getKeyPairs: GetKeyPairs,
|
||||
) {}
|
||||
|
||||
async execute(params: {
|
||||
keys: {
|
||||
encryption: PkcKeyPair
|
||||
signing: PkcKeyPair
|
||||
}
|
||||
senderUserUuid: string
|
||||
sharedVault: SharedVaultListingInterface
|
||||
contactToShare: TrustedContactInterface
|
||||
}): Promise<Result<void>> {
|
||||
if (params.sharedVault.sharing.ownerUserUuid !== params.senderUserUuid) {
|
||||
if (params.sharedVault.sharing.ownerUserUuid !== this.users.sureUser.uuid) {
|
||||
return Result.fail('Cannot share contact; user is not the owner of the shared vault')
|
||||
}
|
||||
|
||||
const users = await this.getVaultUsers.execute({
|
||||
const users = await this._getVaultUsers.execute({
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
@@ -44,8 +42,13 @@ export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
return Result.ok()
|
||||
}
|
||||
|
||||
const keys = this._getKeyPairs.execute()
|
||||
if (keys.isFailed()) {
|
||||
return Result.fail('Cannot share contact; keys not found')
|
||||
}
|
||||
|
||||
for (const vaultUser of users.getValue()) {
|
||||
if (vaultUser.user_uuid === params.senderUserUuid) {
|
||||
if (vaultUser.user_uuid === this.users.sureUser.uuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -53,12 +56,12 @@ export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
continue
|
||||
}
|
||||
|
||||
const vaultUserAsContact = this.findContact.execute({ userUuid: vaultUser.user_uuid })
|
||||
const vaultUserAsContact = this._findContact.execute({ userUuid: vaultUser.user_uuid })
|
||||
if (vaultUserAsContact.isFailed()) {
|
||||
continue
|
||||
}
|
||||
|
||||
const encryptedMessage = this.encryptMessage.execute({
|
||||
const encryptedMessage = this._encryptMessage.execute({
|
||||
message: {
|
||||
type: AsymmetricMessagePayloadType.ContactShare,
|
||||
data: {
|
||||
@@ -66,7 +69,7 @@ export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
trustedContact: params.contactToShare.content,
|
||||
},
|
||||
},
|
||||
keys: params.keys,
|
||||
keys: keys.getValue(),
|
||||
recipientPublicKey: vaultUserAsContact.getValue().publicKeySet.encryption,
|
||||
})
|
||||
|
||||
@@ -74,7 +77,7 @@ export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
continue
|
||||
}
|
||||
|
||||
await this.sendMessage.execute({
|
||||
await this._sendMessage.execute({
|
||||
recipientUuid: vaultUserAsContact.getValue().contactUuid,
|
||||
encryptedMessage: encryptedMessage.getValue(),
|
||||
replaceabilityIdentifier: undefined,
|
||||
|
||||
@@ -37,10 +37,6 @@ export class SubscriptionManager
|
||||
protected override internalEventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(internalEventBus)
|
||||
|
||||
internalEventBus.addEventHandler(this, ApplicationEvent.UserRolesChanged)
|
||||
internalEventBus.addEventHandler(this, ApplicationEvent.Launched)
|
||||
internalEventBus.addEventHandler(this, ApplicationEvent.SignedIn)
|
||||
}
|
||||
|
||||
async handleEvent(event: InternalEventInterface): Promise<void> {
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
import { FullyFormedPayloadInterface } from '@standardnotes/models'
|
||||
import { DecryptedItemInterface, DeletedItemInterface, FullyFormedPayloadInterface } from '@standardnotes/models'
|
||||
import { SyncOptions } from './SyncOptions'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SyncEvent } from '../Event/SyncEvent'
|
||||
import { SyncOpStatus } from './SyncOpStatus'
|
||||
import { HttpRequest } from '@standardnotes/responses'
|
||||
|
||||
export interface SyncServiceInterface extends AbstractService<SyncEvent> {
|
||||
sync(options?: Partial<SyncOptions>): Promise<unknown>
|
||||
getRawSyncRequestForExternalUse(
|
||||
items: (DecryptedItemInterface | DeletedItemInterface)[],
|
||||
): Promise<HttpRequest | undefined>
|
||||
|
||||
isDatabaseLoaded(): boolean
|
||||
onNewDatabaseCreated(): Promise<void>
|
||||
loadDatabasePayloads(): Promise<void>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { SyncOptions } from './../Sync/SyncOptions'
|
||||
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
|
||||
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
|
||||
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||
import { DecryptedItemInterface, DecryptedItemMutator, MutationType, PayloadEmitSource } from '@standardnotes/models'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class ChangeAndSaveItem implements UseCaseInterface<DecryptedItemInterface | undefined> {
|
||||
constructor(
|
||||
private readonly items: ItemManagerInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
private sync: SyncServiceInterface,
|
||||
) {}
|
||||
|
||||
async execute<M extends DecryptedItemMutator = DecryptedItemMutator>(
|
||||
itemToLookupUuidFor: DecryptedItemInterface,
|
||||
mutate: (mutator: M) => void,
|
||||
updateTimestamps = true,
|
||||
emitSource?: PayloadEmitSource,
|
||||
syncOptions?: SyncOptions,
|
||||
): Promise<Result<DecryptedItemInterface | undefined>> {
|
||||
await this.mutator.changeItems(
|
||||
[itemToLookupUuidFor],
|
||||
mutate,
|
||||
updateTimestamps ? MutationType.UpdateUserTimestamps : MutationType.NoUpdateUserTimestamps,
|
||||
emitSource,
|
||||
)
|
||||
|
||||
await this.sync.sync(syncOptions)
|
||||
|
||||
return Result.ok(this.items.findItem(itemToLookupUuidFor.uuid))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
|
||||
export class GenerateUuid implements SyncUseCaseInterface<string> {
|
||||
constructor(private crypto: PureCryptoInterface) {}
|
||||
|
||||
execute(): Result<string> {
|
||||
const uuid = this.crypto.generateUUID()
|
||||
|
||||
return Result.ok(uuid)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { LegacyApiServiceInterface } from './../Api/LegacyApiServiceInterface'
|
||||
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class GetHost implements SyncUseCaseInterface<string> {
|
||||
constructor(private legacyApi: LegacyApiServiceInterface) {}
|
||||
|
||||
execute(): Result<string> {
|
||||
return Result.ok(this.legacyApi.getHost())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { HttpServiceInterface } from '@standardnotes/api'
|
||||
import { LegacyApiServiceInterface } from '../Api/LegacyApiServiceInterface'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class SetHost implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private http: HttpServiceInterface,
|
||||
private legacyApi: LegacyApiServiceInterface,
|
||||
) {}
|
||||
|
||||
async execute(host: string): Promise<Result<string>> {
|
||||
this.http.setHost(host)
|
||||
|
||||
await this.legacyApi.setHost(host)
|
||||
|
||||
return Result.ok()
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecryptErroredPayloads } from './../Encryption/UseCase/DecryptErroredPayloads'
|
||||
import { ReencryptTypeAItems } from './../Encryption/UseCase/TypeA/ReencryptTypeAItems'
|
||||
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
|
||||
import { UserApiServiceInterface } from '@standardnotes/api'
|
||||
@@ -27,6 +28,7 @@ describe('UserService', () => {
|
||||
let protectionService: ProtectionsClientInterface
|
||||
let userApiService: UserApiServiceInterface
|
||||
let reencryptTypeAItems: ReencryptTypeAItems
|
||||
let decryptErroredPayloads: DecryptErroredPayloads
|
||||
let internalEventBus: InternalEventBusInterface
|
||||
|
||||
const createService = () =>
|
||||
@@ -41,6 +43,7 @@ describe('UserService', () => {
|
||||
protectionService,
|
||||
userApiService,
|
||||
reencryptTypeAItems,
|
||||
decryptErroredPayloads,
|
||||
internalEventBus,
|
||||
)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user