mirror of
https://github.com/standardnotes/app
synced 2026-09-13 09:46:02 -04:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ad5d028af | ||
|
|
596e041c42 | ||
|
|
80436cd0b9 | ||
|
|
40c0a08e74 | ||
|
|
560e91bce9 | ||
|
|
2a3db43df5 | ||
|
|
2e59aa5a07 | ||
|
|
98c0228139 | ||
|
|
d6bcc808d5 | ||
|
|
e18978d4ba | ||
|
|
ac4231d8eb | ||
|
|
3281ac9d37 | ||
|
|
f2d089ab24 | ||
|
|
a91ab4abbf | ||
|
|
0af41cbcad | ||
|
|
1adb21a06e | ||
|
|
412b192b85 | ||
|
|
8ad9b8ae2a | ||
|
|
c52d8e7309 | ||
|
|
406abb4929 | ||
|
|
814a156e1b |
@@ -6,6 +6,3 @@ DEFAULT_SYNC_SERVER=https://api.standardnotes.com
|
||||
DASHBOARD_URL=http://standardnotes.com/dashboard
|
||||
PLANS_URL=https://standardnotes.com/plans
|
||||
PURCHASE_URL=https://standardnotes.com/purchase
|
||||
|
||||
# Used by Rails internals and not Standard Notes related
|
||||
SECRET_KEY_BASE=<enter a secret string here>
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -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.1.113](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.112](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.111](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.110](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.109](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.108](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.107](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/clipper
|
||||
|
||||
## [1.1.106](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**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.106",
|
||||
"version": "1.1.113",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build-mv2": "yarn clean && webpack --config ./webpack.config.prod.js",
|
||||
|
||||
@@ -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.
|
||||
|
||||
## [3.108.44](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.43](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.42](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.41](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.40](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.39](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.38](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
## [3.108.37](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/desktop
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@standardnotes/desktop",
|
||||
"main": "./app/dist/index.js",
|
||||
"version": "3.108.37",
|
||||
"version": "3.108.44",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": "Standard Notes.",
|
||||
"private": true,
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [3.56.24](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.23](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.22](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.21](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.20](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.19](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.18](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.17](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
## [3.56.16](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/mobile
|
||||
|
||||
@@ -118,7 +118,24 @@ class ReceiveSharingIntent: NSObject {
|
||||
|
||||
@objc
|
||||
func clearFileNames(){
|
||||
print("clearFileNames");
|
||||
let appDomain = Bundle.main.bundleIdentifier!
|
||||
let groupName = "group.\(appDomain)"
|
||||
let userDefaults = UserDefaults(suiteName: groupName)
|
||||
userDefaults?.set(nil, forKey: "ShareKey.media")
|
||||
userDefaults?.set(nil, forKey: "ShareKey.text")
|
||||
userDefaults?.set(nil, forKey: "ShareKey.url")
|
||||
let containerURL = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: groupName)!
|
||||
let shareTempDirPath = containerURL.appendingPathComponent("ShareTemp", isDirectory: true)
|
||||
do {
|
||||
let fileNames = try FileManager.default.contentsOfDirectory(atPath: shareTempDirPath.relativePath)
|
||||
for fileName in fileNames {
|
||||
let filePath = shareTempDirPath.appendingPathComponent(fileName)
|
||||
try FileManager.default.removeItem(at: filePath)
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -95,16 +95,11 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
attachment.loadItem(forTypeIdentifier: imageContentType, options: nil) { [weak self] data, error in
|
||||
|
||||
if error == nil, let url = data as? URL, let this = self {
|
||||
// this.redirectToHostApp(type: .media)
|
||||
// Always copy
|
||||
let fileExtension = this.getExtension(from: url, type: .video)
|
||||
let newName = UUID().uuidString
|
||||
let newPath = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
|
||||
.appendingPathComponent("\(newName).\(fileExtension)")
|
||||
let copied = this.copyFile(at: url, to: newPath)
|
||||
if(copied) {
|
||||
this.sharedMedia.append(SharedMediaFile(path: newPath.absoluteString, thumbnail: nil, duration: nil, type: .image))
|
||||
if let copiedPath = this.copyToTemporaryPath(url: url, name: "\(newName).\(fileExtension)") {
|
||||
this.sharedMedia.append(SharedMediaFile(path: copiedPath, thumbnail: nil, duration: nil, type: .image))
|
||||
}
|
||||
|
||||
if index == (content.attachments?.count)! - 1 {
|
||||
@@ -125,15 +120,8 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
// Always copy
|
||||
let fileExtension = this.getExtension(from: url, type: .video)
|
||||
let newName = UUID().uuidString
|
||||
let newPath = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
|
||||
.appendingPathComponent("\(newName).\(fileExtension)")
|
||||
let copied = this.copyFile(at: url, to: newPath)
|
||||
if(copied) {
|
||||
guard let sharedFile = this.getSharedMediaFile(forVideo: newPath) else {
|
||||
return
|
||||
}
|
||||
this.sharedMedia.append(sharedFile)
|
||||
if let copiedPath = this.copyToTemporaryPath(url: url, name: "\(newName).\(fileExtension)") {
|
||||
this.sharedMedia.append(SharedMediaFile(path: copiedPath, thumbnail: nil, duration: nil, type: .video))
|
||||
}
|
||||
|
||||
if index == (content.attachments?.count)! - 1 {
|
||||
@@ -151,14 +139,9 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
|
||||
if error == nil, let url = data as? URL, let this = self {
|
||||
|
||||
// Always copy
|
||||
let newName = this.getFileName(from :url)
|
||||
let newPath = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
|
||||
.appendingPathComponent("\(newName)")
|
||||
let copied = this.copyFile(at: url, to: newPath)
|
||||
if (copied) {
|
||||
this.sharedMedia.append(SharedMediaFile(path: newPath.absoluteString, thumbnail: nil, duration: nil, type: .file))
|
||||
if let copiedPath = this.copyToTemporaryPath(url: url, name: newName) {
|
||||
this.sharedMedia.append(SharedMediaFile(path: copiedPath, thumbnail: nil, duration: nil, type: .file))
|
||||
}
|
||||
|
||||
if index == (content.attachments?.count)! - 1 {
|
||||
@@ -171,6 +154,32 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func directoryExistsAtPath(_ path: String) -> Bool {
|
||||
var isDirectory = ObjCBool(true)
|
||||
let exists = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
|
||||
return exists && isDirectory.boolValue
|
||||
}
|
||||
|
||||
private func copyToTemporaryPath(url: URL, name: String) -> String? {
|
||||
let containerURL = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
|
||||
let shareTempDirPath = containerURL.appendingPathComponent("ShareTemp", isDirectory: true)
|
||||
if !directoryExistsAtPath(shareTempDirPath.absoluteString) {
|
||||
do {
|
||||
try FileManager.default.createDirectory(atPath: shareTempDirPath.relativePath, withIntermediateDirectories: true, attributes: nil)
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
let newPath = shareTempDirPath
|
||||
.appendingPathComponent("\(name)")
|
||||
let copied = self.copyFile(at: url, to: newPath)
|
||||
if (copied) {
|
||||
return newPath.absoluteString
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private func redirectToHostApp() {
|
||||
let userDefaults = UserDefaults(suiteName: "group.\(hostAppBundleIdentifier)")
|
||||
userDefaults?.set(self.toData(data: self.sharedMedia), forKey: "\(self.sharedKey).media")
|
||||
@@ -263,40 +272,6 @@ class ShareViewController: SLComposeServiceViewController {
|
||||
return true
|
||||
}
|
||||
|
||||
private func getSharedMediaFile(forVideo: URL) -> SharedMediaFile? {
|
||||
let asset = AVAsset(url: forVideo)
|
||||
let duration = (CMTimeGetSeconds(asset.duration) * 1000).rounded()
|
||||
let thumbnailPath = getThumbnailPath(for: forVideo)
|
||||
|
||||
if FileManager.default.fileExists(atPath: thumbnailPath.path) {
|
||||
return SharedMediaFile(path: forVideo.absoluteString, thumbnail: thumbnailPath.absoluteString, duration: duration, type: .video)
|
||||
}
|
||||
|
||||
var saved = false
|
||||
let assetImgGenerate = AVAssetImageGenerator(asset: asset)
|
||||
assetImgGenerate.appliesPreferredTrackTransform = true
|
||||
// let scale = UIScreen.main.scale
|
||||
assetImgGenerate.maximumSize = CGSize(width: 360, height: 360)
|
||||
do {
|
||||
let img = try assetImgGenerate.copyCGImage(at: CMTimeMakeWithSeconds(600, preferredTimescale: Int32(1.0)), actualTime: nil)
|
||||
try UIImage.pngData(UIImage(cgImage: img))()?.write(to: thumbnailPath)
|
||||
saved = true
|
||||
} catch {
|
||||
saved = false
|
||||
}
|
||||
|
||||
return saved ? SharedMediaFile(path: forVideo.absoluteString, thumbnail: thumbnailPath.absoluteString, duration: duration, type: .video) : nil
|
||||
|
||||
}
|
||||
|
||||
private func getThumbnailPath(for url: URL) -> URL {
|
||||
let fileName = Data(url.lastPathComponent.utf8).base64EncodedString().replacingOccurrences(of: "==", with: "")
|
||||
let path = FileManager.default
|
||||
.containerURL(forSecurityApplicationGroupIdentifier: "group.\(hostAppBundleIdentifier)")!
|
||||
.appendingPathComponent("\(fileName).jpg")
|
||||
return path
|
||||
}
|
||||
|
||||
class SharedMediaFile: Codable {
|
||||
var path: String; // can be image, video or url path. It can also be text content
|
||||
var thumbnail: String?; // video thumbnail
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/mobile",
|
||||
"version": "3.56.16",
|
||||
"version": "3.56.24",
|
||||
"author": "Standard Notes.",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
||||
@@ -71,6 +71,7 @@ export class ReceivedSharedItemsHandler {
|
||||
}
|
||||
|
||||
deinit() {
|
||||
ReceiveSharingIntent.clearFileNames()
|
||||
this.receivedItemsQueue = []
|
||||
this.eventSub?.remove()
|
||||
}
|
||||
@@ -100,17 +101,13 @@ export class ReceivedSharedItemsHandler {
|
||||
}
|
||||
|
||||
handleItemsQueue = async () => {
|
||||
if (!this.receivedItemsQueue.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const item = this.receivedItemsQueue.shift()
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isReceivedAndroidFile(item) || isReceivedIosFile(item)) {
|
||||
this.sendFileToWebView(item).catch(console.error)
|
||||
await this.sendFileToWebView(item).catch(console.error)
|
||||
} else if (isReceivedWeblink(item)) {
|
||||
this.webViewRef.current?.postMessage(
|
||||
JSON.stringify({
|
||||
@@ -134,12 +131,20 @@ export class ReceivedSharedItemsHandler {
|
||||
)
|
||||
}
|
||||
|
||||
if (!this.receivedItemsQueue.length) {
|
||||
if (Platform.OS === 'ios') {
|
||||
ReceiveSharingIntent.clearFileNames()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.handleItemsQueue().catch(console.error)
|
||||
}
|
||||
|
||||
sendFileToWebView = async (item: ReceivedAndroidFile | ReceivedIosFile) => {
|
||||
const path = isReceivedAndroidFile(item) ? item.contentUri : item.path
|
||||
const data = await readFile(path, 'base64')
|
||||
const data = await readFile(decodeURIComponent(path), 'base64')
|
||||
const file = {
|
||||
name: item.fileName || item.path,
|
||||
data,
|
||||
@@ -157,7 +162,12 @@ export class ReceivedSharedItemsHandler {
|
||||
private addSharedItemsToQueue = async (url?: string) => {
|
||||
const received =
|
||||
Platform.OS === 'ios' ? await ReceiveSharingIntent.getFileNames(url) : await ReceiveSharingIntent.getFileNames()
|
||||
ReceiveSharingIntent.clearFileNames()
|
||||
|
||||
// On iOS, we need to wait for the whole queue
|
||||
// to finish before clearing
|
||||
if (Platform.OS === 'android') {
|
||||
ReceiveSharingIntent.clearFileNames()
|
||||
}
|
||||
|
||||
if (!received) {
|
||||
return
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.4.396](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.395](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.394](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.393](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.392](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.391](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.390](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.389](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
## [1.4.388](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/releases
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/releases",
|
||||
"version": "1.4.388",
|
||||
"version": "1.4.396",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"main": "dist/releases.json",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.63.9](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
## [1.63.8](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
## [1.63.7](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
## [1.63.6](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/services
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/services",
|
||||
"version": "1.63.6",
|
||||
"version": "1.63.9",
|
||||
"engines": {
|
||||
"node": ">=16.0.0 <17.0.0"
|
||||
},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { VaultUserServiceInterface, VaultInviteServiceInterface } from '@standardnotes/services'
|
||||
import { VaultLockServiceInterface } from './../VaultLock/VaultLockServiceInterface'
|
||||
import { HistoryServiceInterface } from './../History/HistoryServiceInterface'
|
||||
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
|
||||
import { PreferenceServiceInterface } from './../Preferences/PreferenceServiceInterface'
|
||||
@@ -5,7 +7,7 @@ import { AsymmetricMessageServiceInterface } from './../AsymmetricMessage/Asymme
|
||||
import { SyncOptions } from './../Sync/SyncOptions'
|
||||
import { ImportDataReturnType } from './../Mutator/ImportDataUseCase'
|
||||
import { ChallengeServiceInterface } from './../Challenge/ChallengeServiceInterface'
|
||||
import { VaultServiceInterface } from './../Vaults/VaultServiceInterface'
|
||||
import { VaultServiceInterface } from '../Vault/VaultServiceInterface'
|
||||
import { ApplicationIdentifier } from '@standardnotes/common'
|
||||
import {
|
||||
BackupFile,
|
||||
@@ -95,24 +97,27 @@ export interface ApplicationInterface {
|
||||
syncOptions?: SyncOptions,
|
||||
): Promise<void>
|
||||
|
||||
get features(): FeaturesClientInterface
|
||||
get componentManager(): ComponentManagerInterface
|
||||
get items(): ItemManagerInterface
|
||||
get mutator(): MutatorClientInterface
|
||||
get user(): UserClientInterface
|
||||
get files(): FilesClientInterface
|
||||
get subscriptions(): SubscriptionManagerInterface
|
||||
get fileBackups(): BackupServiceInterface | undefined
|
||||
get sessions(): SessionsClientInterface
|
||||
get homeServer(): HomeServerServiceInterface | undefined
|
||||
get vaults(): VaultServiceInterface
|
||||
get challenges(): ChallengeServiceInterface
|
||||
get alerts(): AlertService
|
||||
get asymmetric(): AsymmetricMessageServiceInterface
|
||||
get preferences(): PreferenceServiceInterface
|
||||
get events(): InternalEventBusInterface
|
||||
get history(): HistoryServiceInterface
|
||||
get challenges(): ChallengeServiceInterface
|
||||
get componentManager(): ComponentManagerInterface
|
||||
get encryption(): EncryptionProviderInterface
|
||||
get events(): InternalEventBusInterface
|
||||
get features(): FeaturesClientInterface
|
||||
get fileBackups(): BackupServiceInterface | undefined
|
||||
get files(): FilesClientInterface
|
||||
get history(): HistoryServiceInterface
|
||||
get homeServer(): HomeServerServiceInterface | undefined
|
||||
get items(): ItemManagerInterface
|
||||
get mutator(): MutatorClientInterface
|
||||
get preferences(): PreferenceServiceInterface
|
||||
get sessions(): SessionsClientInterface
|
||||
get subscriptions(): SubscriptionManagerInterface
|
||||
get user(): UserClientInterface
|
||||
get vaults(): VaultServiceInterface
|
||||
get vaultLocks(): VaultLockServiceInterface
|
||||
get vaultUsers(): VaultUserServiceInterface
|
||||
get vaultInvites(): VaultInviteServiceInterface
|
||||
|
||||
readonly identifier: ApplicationIdentifier
|
||||
readonly platform: Platform
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { GetVault } from './../Vault/UseCase/GetVault'
|
||||
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
|
||||
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
|
||||
import { GetUntrustedPayload } from './UseCase/GetUntrustedPayload'
|
||||
import { GetInboundMessages } from './UseCase/GetInboundMessages'
|
||||
import { GetOutboundMessages } from './UseCase/GetOutboundMessages'
|
||||
import { SendOwnContactChangeMessage } from './UseCase/SendOwnContactChangeMessage'
|
||||
import { HandleRootKeyChangedMessage } from './UseCase/HandleRootKeyChangedMessage'
|
||||
import { GetVault } from './../Vaults/UseCase/GetVault'
|
||||
import { GetTrustedPayload } from './UseCase/GetTrustedPayload'
|
||||
import { ReplaceContactData } from './../Contacts/UseCase/ReplaceContactData'
|
||||
import { GetAllContacts } from './../Contacts/UseCase/GetAllContacts'
|
||||
@@ -31,6 +32,7 @@ describe('AsymmetricMessageService', () => {
|
||||
let sync: jest.Mocked<SyncServiceInterface>
|
||||
let mutator: jest.Mocked<MutatorClientInterface>
|
||||
let encryption: jest.Mocked<EncryptionProviderInterface>
|
||||
let sessions: jest.Mocked<SessionsClientInterface>
|
||||
let service: AsymmetricMessageService
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -60,9 +62,10 @@ describe('AsymmetricMessageService', () => {
|
||||
eventBus.addEventHandler = jest.fn()
|
||||
|
||||
service = new AsymmetricMessageService(
|
||||
messageServer,
|
||||
encryption,
|
||||
mutator,
|
||||
sessions,
|
||||
messageServer,
|
||||
createOrEditContact,
|
||||
findContact,
|
||||
getAllContacts,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
|
||||
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
|
||||
import { AsymmetricMessageServerHash, ClientDisplayableError, isClientDisplayableError } from '@standardnotes/responses'
|
||||
import { SyncEvent, SyncEventReceivedAsymmetricMessagesData } from '../Event/SyncEvent'
|
||||
@@ -25,7 +26,7 @@ import { UserKeyPairChangedEventData } from '../Session/UserKeyPairChangedEventD
|
||||
import { SendOwnContactChangeMessage } from './UseCase/SendOwnContactChangeMessage'
|
||||
import { GetOutboundMessages } from './UseCase/GetOutboundMessages'
|
||||
import { GetInboundMessages } from './UseCase/GetInboundMessages'
|
||||
import { GetVault } from '../Vaults/UseCase/GetVault'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { AsymmetricMessageServiceInterface } from './AsymmetricMessageServiceInterface'
|
||||
import { GetUntrustedPayload } from './UseCase/GetUntrustedPayload'
|
||||
import { FindContact } from '../Contacts/UseCase/FindContact'
|
||||
@@ -39,9 +40,10 @@ export class AsymmetricMessageService
|
||||
implements AsymmetricMessageServiceInterface, InternalEventHandlerInterface
|
||||
{
|
||||
constructor(
|
||||
private messageServer: AsymmetricMessageServer,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
private sessions: SessionsClientInterface,
|
||||
private messageServer: AsymmetricMessageServer,
|
||||
private _createOrEditContact: CreateOrEditContact,
|
||||
private _findContact: FindContact,
|
||||
private _getAllContacts: GetAllContacts,
|
||||
@@ -184,10 +186,6 @@ export class AsymmetricMessageService
|
||||
message: AsymmetricMessageServerHash,
|
||||
payload: AsymmetricMessagePayload,
|
||||
): Promise<void> {
|
||||
if (payload.data.recipientUuid !== message.user_uuid) {
|
||||
return
|
||||
}
|
||||
|
||||
if (payload.type === AsymmetricMessagePayloadType.ContactShare) {
|
||||
await this.handleTrustedContactShareMessage(message, payload)
|
||||
} else if (payload.type === AsymmetricMessagePayloadType.SenderKeypairChanged) {
|
||||
@@ -225,6 +223,7 @@ export class AsymmetricMessageService
|
||||
const result = this._getTrustedPayload.execute({
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
sender: contact.getValue(),
|
||||
ownUserUuid: this.sessions.userUuid,
|
||||
message,
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
|
||||
import { AsymmetricMessagePayload, TrustedContactInterface } from '@standardnotes/models'
|
||||
import { DecryptMessage } from '../../Encryption/UseCase/Asymmetric/DecryptMessage'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
import { GetTrustedPayload } from './GetTrustedPayload'
|
||||
|
||||
describe('GetTrustedPayload', () => {
|
||||
let decryptMessage: jest.Mocked<DecryptMessage>
|
||||
let getTrustedPayload: GetTrustedPayload
|
||||
|
||||
beforeEach(() => {
|
||||
decryptMessage = {} as jest.Mocked<DecryptMessage>
|
||||
decryptMessage.execute = jest.fn()
|
||||
|
||||
getTrustedPayload = new GetTrustedPayload(decryptMessage)
|
||||
})
|
||||
|
||||
describe('execute', () => {
|
||||
const mockDto = {
|
||||
privateKey: 'test-private-key',
|
||||
message: {} as AsymmetricMessageServerHash,
|
||||
sender: {} as TrustedContactInterface,
|
||||
ownUserUuid: 'test-user-uuid',
|
||||
}
|
||||
|
||||
it('should return failure when decryption fails', () => {
|
||||
decryptMessage.execute = jest.fn().mockReturnValue(Result.fail('Decryption failed'))
|
||||
|
||||
const result = getTrustedPayload.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toBe('Decryption failed')
|
||||
})
|
||||
|
||||
it('should return failure when recipientUuid is not equal to ownUserUuid', () => {
|
||||
const mockPayload: AsymmetricMessagePayload = {
|
||||
data: {
|
||||
recipientUuid: 'another-user-uuid',
|
||||
},
|
||||
} as AsymmetricMessagePayload
|
||||
decryptMessage.execute = jest.fn().mockReturnValue(Result.ok(mockPayload))
|
||||
|
||||
const result = getTrustedPayload.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toBe('Message is not for this user')
|
||||
})
|
||||
|
||||
it('should return success when recipientUuid is equal to ownUserUuid', () => {
|
||||
const mockPayload: AsymmetricMessagePayload = {
|
||||
data: {
|
||||
recipientUuid: 'test-user-uuid',
|
||||
},
|
||||
} as AsymmetricMessagePayload
|
||||
decryptMessage.execute = jest.fn().mockReturnValue(Result.ok(mockPayload))
|
||||
|
||||
const result = getTrustedPayload.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(false)
|
||||
expect(result.getValue()).toBe(mockPayload)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -10,6 +10,7 @@ export class GetTrustedPayload implements SyncUseCaseInterface<AsymmetricMessage
|
||||
privateKey: string
|
||||
message: AsymmetricMessageServerHash
|
||||
sender: TrustedContactInterface
|
||||
ownUserUuid: string
|
||||
}): Result<M> {
|
||||
const result = this.decryptMessage.execute<M>({
|
||||
message: dto.message.encrypted_message,
|
||||
@@ -17,6 +18,16 @@ export class GetTrustedPayload implements SyncUseCaseInterface<AsymmetricMessage
|
||||
privateKey: dto.privateKey,
|
||||
})
|
||||
|
||||
if (result.isFailed()) {
|
||||
return result
|
||||
}
|
||||
|
||||
const recipientUuid = result.getValue().data.recipientUuid
|
||||
|
||||
if (recipientUuid !== dto.ownUserUuid) {
|
||||
return Result.fail('Message is not for this user')
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { GetVault } from '../../Vaults/UseCase/GetVault'
|
||||
import { GetVault } from '../../Vault/UseCase/GetVault'
|
||||
import { EncryptionProviderInterface } from '../../Encryption/EncryptionProviderInterface'
|
||||
|
||||
export class HandleRootKeyChangedMessage {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DeleteContact } from './UseCase/DeleteContact'
|
||||
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
|
||||
import { UserKeyPairChangedEventData } from './../Session/UserKeyPairChangedEventData'
|
||||
import { SessionEvent } from './../Session/SessionEvent'
|
||||
@@ -21,6 +22,7 @@ import { CreateOrEditContact } from './UseCase/CreateOrEditContact'
|
||||
import { EditContact } from './UseCase/EditContact'
|
||||
import { GetAllContacts } from './UseCase/GetAllContacts'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export class ContactService
|
||||
extends AbstractService<ContactServiceEvent>
|
||||
@@ -34,6 +36,7 @@ export class ContactService
|
||||
private user: UserClientInterface,
|
||||
private selfContactManager: SelfContactManager,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private _deleteContact: DeleteContact,
|
||||
private _findContact: FindContact,
|
||||
private _getAllContacts: GetAllContacts,
|
||||
private _createOrEditContact: CreateOrEditContact,
|
||||
@@ -167,20 +170,15 @@ export class ContactService
|
||||
return contact
|
||||
}
|
||||
|
||||
async deleteContact(contact: TrustedContactInterface): Promise<void> {
|
||||
if (contact.isMe) {
|
||||
throw new Error('Cannot delete self')
|
||||
}
|
||||
|
||||
await this.mutator.setItemToBeDeleted(contact)
|
||||
await this.sync.sync()
|
||||
async deleteContact(contact: TrustedContactInterface): Promise<Result<void>> {
|
||||
return this._deleteContact.execute({ contact, ownUserUuid: this.session.userUuid })
|
||||
}
|
||||
|
||||
getAllContacts(): TrustedContactInterface[] {
|
||||
return this._getAllContacts.execute().getValue()
|
||||
}
|
||||
|
||||
findTrustedContact(userUuid: string): TrustedContactInterface | undefined {
|
||||
findContact(userUuid: string): TrustedContactInterface | undefined {
|
||||
const result = this._findContact.execute({ userUuid })
|
||||
if (result.isFailed()) {
|
||||
return undefined
|
||||
@@ -188,12 +186,12 @@ export class ContactService
|
||||
return result.getValue()
|
||||
}
|
||||
|
||||
findTrustedContactForServerUser(user: SharedVaultUserServerHash): TrustedContactInterface | undefined {
|
||||
return this.findTrustedContact(user.user_uuid)
|
||||
findContactForServerUser(user: SharedVaultUserServerHash): TrustedContactInterface | undefined {
|
||||
return this.findContact(user.user_uuid)
|
||||
}
|
||||
|
||||
findTrustedContactForInvite(invite: SharedVaultInviteServerHash): TrustedContactInterface | undefined {
|
||||
return this.findTrustedContact(invite.sender_uuid)
|
||||
findContactForInvite(invite: SharedVaultInviteServerHash): TrustedContactInterface | undefined {
|
||||
return this.findContact(invite.sender_uuid)
|
||||
}
|
||||
|
||||
getCollaborationIDForTrustedContact(contact: TrustedContactInterface): string {
|
||||
@@ -205,7 +203,7 @@ export class ContactService
|
||||
})
|
||||
}
|
||||
|
||||
isItemAuthenticallySigned(item: DecryptedItemInterface): ItemSignatureValidationResult {
|
||||
getItemSignatureStatus(item: DecryptedItemInterface): ItemSignatureValidationResult {
|
||||
return this._validateItemSigner.execute(item)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { DecryptedItemInterface, TrustedContactInterface } from '@standardnotes/
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SharedVaultInviteServerHash, SharedVaultUserServerHash } from '@standardnotes/responses'
|
||||
import { ItemSignatureValidationResult } from './UseCase/Types/ItemSignatureValidationResult'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export enum ContactServiceEvent {}
|
||||
|
||||
@@ -26,13 +27,13 @@ export interface ContactServiceInterface extends AbstractService<ContactServiceE
|
||||
contact: TrustedContactInterface,
|
||||
params: { name: string; collaborationID: string },
|
||||
): Promise<TrustedContactInterface>
|
||||
deleteContact(contact: TrustedContactInterface): Promise<void>
|
||||
deleteContact(contact: TrustedContactInterface): Promise<Result<void>>
|
||||
|
||||
getAllContacts(): TrustedContactInterface[]
|
||||
getSelfContact(): TrustedContactInterface | undefined
|
||||
findTrustedContact(userUuid: string): TrustedContactInterface | undefined
|
||||
findTrustedContactForServerUser(user: SharedVaultUserServerHash): TrustedContactInterface | undefined
|
||||
findTrustedContactForInvite(invite: SharedVaultInviteServerHash): TrustedContactInterface | undefined
|
||||
findContact(userUuid: string): TrustedContactInterface | undefined
|
||||
findContactForServerUser(user: SharedVaultUserServerHash): TrustedContactInterface | undefined
|
||||
findContactForInvite(invite: SharedVaultInviteServerHash): TrustedContactInterface | undefined
|
||||
|
||||
isItemAuthenticallySigned(item: DecryptedItemInterface): ItemSignatureValidationResult
|
||||
getItemSignatureStatus(item: DecryptedItemInterface): ItemSignatureValidationResult
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import { ContactBelongsToVault } from './../../SharedVaults/UseCase/ContactBelongsToVault'
|
||||
import { GetOwnedSharedVaults } from './../../SharedVaults/UseCase/GetOwnedSharedVaults'
|
||||
import { SyncServiceInterface } from './../../Sync/SyncServiceInterface'
|
||||
import { MutatorClientInterface } from './../../Mutator/MutatorClientInterface'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
import { TrustedContactInterface } from '@standardnotes/models'
|
||||
import { DeleteContact } from './DeleteContact'
|
||||
|
||||
describe('DeleteContact', () => {
|
||||
let mutator: jest.Mocked<MutatorClientInterface>
|
||||
let sync: jest.Mocked<SyncServiceInterface>
|
||||
let getOwnedVaults: jest.Mocked<GetOwnedSharedVaults>
|
||||
let contactBelongsToVault: jest.Mocked<ContactBelongsToVault>
|
||||
let deleteContact: DeleteContact
|
||||
let mockDto: {
|
||||
contact: TrustedContactInterface
|
||||
ownUserUuid: string
|
||||
}
|
||||
let mockVaults: { id: string }[]
|
||||
|
||||
beforeEach(() => {
|
||||
mutator = {} as jest.Mocked<MutatorClientInterface>
|
||||
sync = {} as jest.Mocked<SyncServiceInterface>
|
||||
|
||||
getOwnedVaults = {} as jest.Mocked<GetOwnedSharedVaults>
|
||||
getOwnedVaults.execute = jest.fn()
|
||||
|
||||
contactBelongsToVault = {} as jest.Mocked<ContactBelongsToVault>
|
||||
contactBelongsToVault.execute = jest.fn()
|
||||
|
||||
deleteContact = new DeleteContact(mutator, sync, getOwnedVaults, contactBelongsToVault)
|
||||
|
||||
mockDto = {
|
||||
contact: { isMe: false } as TrustedContactInterface,
|
||||
ownUserUuid: 'test-user-uuid',
|
||||
}
|
||||
|
||||
mockVaults = [{ id: 'vault1' }, { id: 'vault2' }]
|
||||
})
|
||||
|
||||
describe('execute', () => {
|
||||
it('should throw error when deleting self', async () => {
|
||||
mockDto.contact.isMe = true
|
||||
await expect(deleteContact.execute(mockDto)).rejects.toThrow('Cannot delete self')
|
||||
})
|
||||
|
||||
it('should return failure when getting owned vaults fails', async () => {
|
||||
getOwnedVaults.execute = jest.fn().mockReturnValue(Result.fail('Failed to get owned vaults'))
|
||||
|
||||
const result = await deleteContact.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toBe('Failed to get owned vaults')
|
||||
})
|
||||
|
||||
it('should return failure when checking contact membership fails', async () => {
|
||||
getOwnedVaults.execute = jest.fn().mockReturnValue(Result.ok(mockVaults))
|
||||
contactBelongsToVault.execute = jest.fn().mockResolvedValue(Result.fail('Failed to check contact membership'))
|
||||
|
||||
const result = await deleteContact.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toBe('Failed to check contact membership')
|
||||
})
|
||||
|
||||
it('should return failure when contact belongs to an owned vault', async () => {
|
||||
getOwnedVaults.execute = jest.fn().mockReturnValue(Result.ok(mockVaults))
|
||||
contactBelongsToVault.execute = jest.fn().mockResolvedValue(Result.ok(true))
|
||||
|
||||
const result = await deleteContact.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(true)
|
||||
expect(result.getError()).toBe('Cannot delete contact that belongs to an owned vault')
|
||||
})
|
||||
|
||||
it('should return success when contact is successfully deleted', async () => {
|
||||
getOwnedVaults.execute = jest.fn().mockReturnValue(Result.ok(mockVaults))
|
||||
contactBelongsToVault.execute = jest.fn().mockResolvedValue(Result.ok(false))
|
||||
mutator.setItemToBeDeleted = jest.fn().mockResolvedValue(undefined)
|
||||
sync.sync = jest.fn().mockResolvedValue(undefined)
|
||||
|
||||
const result = await deleteContact.execute(mockDto)
|
||||
|
||||
expect(result.isFailed()).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,45 @@
|
||||
import { ContactBelongsToVault } from './../../SharedVaults/UseCase/ContactBelongsToVault'
|
||||
import { GetOwnedSharedVaults } from './../../SharedVaults/UseCase/GetOwnedSharedVaults'
|
||||
import { SyncServiceInterface } from './../../Sync/SyncServiceInterface'
|
||||
import { MutatorClientInterface } from './../../Mutator/MutatorClientInterface'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { TrustedContactInterface } from '@standardnotes/models'
|
||||
|
||||
export class DeleteContact implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private mutator: MutatorClientInterface,
|
||||
private sync: SyncServiceInterface,
|
||||
private getOwnedVaults: GetOwnedSharedVaults,
|
||||
private contactBelongsToVault: ContactBelongsToVault,
|
||||
) {}
|
||||
|
||||
async execute(dto: { contact: TrustedContactInterface; ownUserUuid: string }): Promise<Result<void>> {
|
||||
if (dto.contact.isMe) {
|
||||
throw new Error('Cannot delete self')
|
||||
}
|
||||
|
||||
const vaults = this.getOwnedVaults.execute({ userUuid: dto.ownUserUuid })
|
||||
if (vaults.isFailed()) {
|
||||
return Result.fail('Failed to get owned vaults')
|
||||
}
|
||||
|
||||
for (const vault of vaults.getValue()) {
|
||||
const contactBelongsToVault = await this.contactBelongsToVault.execute({
|
||||
contact: dto.contact,
|
||||
vault: vault,
|
||||
})
|
||||
if (contactBelongsToVault.isFailed()) {
|
||||
return Result.fail('Failed to check contact membership')
|
||||
}
|
||||
|
||||
if (contactBelongsToVault.getValue()) {
|
||||
return Result.fail('Cannot delete contact that belongs to an owned vault')
|
||||
}
|
||||
}
|
||||
|
||||
await this.mutator.setItemToBeDeleted(dto.contact)
|
||||
await this.sync.sync()
|
||||
|
||||
return Result.ok()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { ReuploadAllInvites } from '../../SharedVaults/UseCase/ReuploadAllInvites'
|
||||
import { ReuploadAllInvites } from '../../VaultInvite/UseCase/ReuploadAllInvites'
|
||||
import { ResendAllMessages } from '../../AsymmetricMessage/UseCase/ResendAllMessages'
|
||||
|
||||
export class HandleKeyPairChange implements UseCaseInterface<void> {
|
||||
|
||||
@@ -1,30 +1,21 @@
|
||||
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
|
||||
import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults'
|
||||
import { IsVaultOwner } from './../VaultUser/UseCase/IsVaultOwner'
|
||||
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
|
||||
import { GetVaultUsers } from './UseCase/GetVaultUsers'
|
||||
import { RemoveVaultMember } from './UseCase/RemoveSharedVaultMember'
|
||||
import { DeleteSharedVault } from './UseCase/DeleteSharedVault'
|
||||
import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault'
|
||||
import { ShareContactWithVault } from './UseCase/ShareContactWithVault'
|
||||
import { DeleteThirdPartyVault } from './UseCase/DeleteExternalSharedVault'
|
||||
import { LeaveVault } from './UseCase/LeaveSharedVault'
|
||||
import { InviteToVault } from './UseCase/InviteToVault'
|
||||
import { AcceptVaultInvite } from './UseCase/AcceptVaultInvite'
|
||||
import { GetVaultContacts } from './UseCase/GetVaultContacts'
|
||||
import { GetAllContacts } from './../Contacts/UseCase/GetAllContacts'
|
||||
import { FindContact } from './../Contacts/UseCase/FindContact'
|
||||
import { GetUntrustedPayload } from './../AsymmetricMessage/UseCase/GetUntrustedPayload'
|
||||
import { GetTrustedPayload } from './../AsymmetricMessage/UseCase/GetTrustedPayload'
|
||||
import { SendVaultDataChangedMessage } from './UseCase/SendVaultDataChangedMessage'
|
||||
import { NotifyVaultUsersOfKeyRotation } from './UseCase/NotifyVaultUsersOfKeyRotation'
|
||||
import { HandleKeyPairChange } from './../Contacts/UseCase/HandleKeyPairChange'
|
||||
import { CreateSharedVault } from './UseCase/CreateSharedVault'
|
||||
import { GetVault } from './../Vaults/UseCase/GetVault'
|
||||
import { SharedVaultInvitesServer } from '@standardnotes/api'
|
||||
import { GetVault } from './../Vault/UseCase/GetVault'
|
||||
import { SharedVaultService } from './SharedVaultService'
|
||||
import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
|
||||
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||
import { SessionsClientInterface } from '../Session/SessionsClientInterface'
|
||||
import { VaultServiceInterface } from '../Vaults/VaultServiceInterface'
|
||||
import { InternalEventBusInterface } from '../..'
|
||||
import { ContactPublicKeySetInterface, TrustedContactInterface } from '@standardnotes/models'
|
||||
|
||||
describe('SharedVaultService', () => {
|
||||
@@ -39,57 +30,38 @@ describe('SharedVaultService', () => {
|
||||
|
||||
const encryption = {} as jest.Mocked<EncryptionProviderInterface>
|
||||
const session = {} as jest.Mocked<SessionsClientInterface>
|
||||
const vaults = {} as jest.Mocked<VaultServiceInterface>
|
||||
const invitesServer = {} as jest.Mocked<SharedVaultInvitesServer>
|
||||
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 getTrustedPayload = {} as jest.Mocked<GetTrustedPayload>
|
||||
const getUntrustedPayload = {} as jest.Mocked<GetUntrustedPayload>
|
||||
const findContact = {} as jest.Mocked<FindContact>
|
||||
const getAllContacts = {} as jest.Mocked<GetAllContacts>
|
||||
const getVaultContacts = {} as jest.Mocked<GetVaultContacts>
|
||||
const acceptVaultInvite = {} as jest.Mocked<AcceptVaultInvite>
|
||||
const inviteToVault = {} as jest.Mocked<InviteToVault>
|
||||
const leaveVault = {} as jest.Mocked<LeaveVault>
|
||||
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 removeVaultMember = {} as jest.Mocked<RemoveVaultMember>
|
||||
const getSharedVaultUsersUseCase = {} as jest.Mocked<GetVaultUsers>
|
||||
const isVaultAdmin = {} as jest.Mocked<IsVaultOwner>
|
||||
|
||||
const eventBus = {} as jest.Mocked<InternalEventBusInterface>
|
||||
eventBus.addEventHandler = jest.fn()
|
||||
|
||||
service = new SharedVaultService(
|
||||
sync,
|
||||
items,
|
||||
encryption,
|
||||
session,
|
||||
vaults,
|
||||
invitesServer,
|
||||
getVault,
|
||||
getOwnedVaults,
|
||||
createSharedVaultUseCase,
|
||||
handleKeyPairChange,
|
||||
notifyVaultUsersOfKeyRotation,
|
||||
sendVaultDataChangeMessage,
|
||||
getTrustedPayload,
|
||||
getUntrustedPayload,
|
||||
findContact,
|
||||
getAllContacts,
|
||||
getVaultContacts,
|
||||
acceptVaultInvite,
|
||||
inviteToVault,
|
||||
leaveVault,
|
||||
deleteThirdPartyVault,
|
||||
shareContactWithVault,
|
||||
convertToSharedVault,
|
||||
deleteSharedVaultUseCase,
|
||||
removeVaultMember,
|
||||
getSharedVaultUsersUseCase,
|
||||
isVaultAdmin,
|
||||
eventBus,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,114 +1,70 @@
|
||||
import { UserKeyPairChangedEventData } from './../Session/UserKeyPairChangedEventData'
|
||||
import { InviteToVault } from './UseCase/InviteToVault'
|
||||
import {
|
||||
ClientDisplayableError,
|
||||
SharedVaultInviteServerHash,
|
||||
isErrorResponse,
|
||||
SharedVaultUserServerHash,
|
||||
isClientDisplayableError,
|
||||
SharedVaultPermission,
|
||||
UserEventType,
|
||||
} from '@standardnotes/responses'
|
||||
import { SharedVaultInvitesServer } from '@standardnotes/api'
|
||||
import { ClientDisplayableError, UserEventType } from '@standardnotes/responses'
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
PayloadEmitSource,
|
||||
TrustedContactInterface,
|
||||
SharedVaultListingInterface,
|
||||
VaultListingInterface,
|
||||
AsymmetricMessageSharedVaultInvite,
|
||||
KeySystemRootKeyStorageMode,
|
||||
} from '@standardnotes/models'
|
||||
import { SharedVaultServiceInterface } from './SharedVaultServiceInterface'
|
||||
import { SharedVaultServiceEvent, SharedVaultServiceEventPayload } from './SharedVaultServiceEvent'
|
||||
import { GetVaultUsers } from './UseCase/GetVaultUsers'
|
||||
import { RemoveVaultMember } from './UseCase/RemoveSharedVaultMember'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { InternalEventHandlerInterface } from '../Internal/InternalEventHandlerInterface'
|
||||
import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
|
||||
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||
import { SessionsClientInterface } from '../Session/SessionsClientInterface'
|
||||
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
|
||||
import { SyncEvent, SyncEventReceivedSharedVaultInvitesData } from '../Event/SyncEvent'
|
||||
import { SyncEvent } from '../Event/SyncEvent'
|
||||
import { SessionEvent } from '../Session/SessionEvent'
|
||||
import { InternalEventInterface } from '../Internal/InternalEventInterface'
|
||||
import { LeaveVault } from './UseCase/LeaveSharedVault'
|
||||
import { VaultServiceInterface } from '../Vaults/VaultServiceInterface'
|
||||
import { UserEventServiceEvent, UserEventServiceEventPayload } from '../UserEvent/UserEventServiceEvent'
|
||||
import { DeleteThirdPartyVault } from './UseCase/DeleteExternalSharedVault'
|
||||
import { DeleteSharedVault } from './UseCase/DeleteSharedVault'
|
||||
import { VaultServiceEvent, VaultServiceEventPayload } from '../Vaults/VaultServiceEvent'
|
||||
import { AcceptVaultInvite } from './UseCase/AcceptVaultInvite'
|
||||
import { GetTrustedPayload } from '../AsymmetricMessage/UseCase/GetTrustedPayload'
|
||||
import { PendingSharedVaultInviteRecord } from './PendingSharedVaultInviteRecord'
|
||||
import { GetUntrustedPayload } from '../AsymmetricMessage/UseCase/GetUntrustedPayload'
|
||||
import { VaultServiceEvent, VaultServiceEventPayload } from '../Vault/VaultServiceEvent'
|
||||
import { ShareContactWithVault } from './UseCase/ShareContactWithVault'
|
||||
import { GetVaultContacts } from './UseCase/GetVaultContacts'
|
||||
import { NotifyVaultUsersOfKeyRotation } from './UseCase/NotifyVaultUsersOfKeyRotation'
|
||||
import { CreateSharedVault } from './UseCase/CreateSharedVault'
|
||||
import { SendVaultDataChangedMessage } from './UseCase/SendVaultDataChangedMessage'
|
||||
import { ConvertToSharedVault } from './UseCase/ConvertToSharedVault'
|
||||
import { GetVault } from '../Vaults/UseCase/GetVault'
|
||||
import { ContentType, Result } from '@standardnotes/domain-core'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { HandleKeyPairChange } from '../Contacts/UseCase/HandleKeyPairChange'
|
||||
import { FindContact } from '../Contacts/UseCase/FindContact'
|
||||
import { GetAllContacts } from '../Contacts/UseCase/GetAllContacts'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
import { IsVaultOwner } from '../VaultUser/UseCase/IsVaultOwner'
|
||||
import { GetOwnedSharedVaults } from './UseCase/GetOwnedSharedVaults'
|
||||
|
||||
export class SharedVaultService
|
||||
extends AbstractService<SharedVaultServiceEvent, SharedVaultServiceEventPayload>
|
||||
implements SharedVaultServiceInterface, InternalEventHandlerInterface
|
||||
{
|
||||
private pendingInvites: Record<string, PendingSharedVaultInviteRecord> = {}
|
||||
|
||||
constructor(
|
||||
private sync: SyncServiceInterface,
|
||||
private items: ItemManagerInterface,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private session: SessionsClientInterface,
|
||||
private vaults: VaultServiceInterface,
|
||||
private invitesServer: SharedVaultInvitesServer,
|
||||
private getVault: GetVault,
|
||||
private createSharedVaultUseCase: CreateSharedVault,
|
||||
private handleKeyPairChange: HandleKeyPairChange,
|
||||
private notifyVaultUsersOfKeyRotation: NotifyVaultUsersOfKeyRotation,
|
||||
private sendVaultDataChangeMessage: SendVaultDataChangedMessage,
|
||||
private getTrustedPayload: GetTrustedPayload,
|
||||
private getUntrustedPayload: GetUntrustedPayload,
|
||||
private findContact: FindContact,
|
||||
private getAllContacts: GetAllContacts,
|
||||
private getVaultContacts: GetVaultContacts,
|
||||
private acceptVaultInvite: AcceptVaultInvite,
|
||||
private inviteToVault: InviteToVault,
|
||||
private leaveVault: LeaveVault,
|
||||
private deleteThirdPartyVault: DeleteThirdPartyVault,
|
||||
private shareContactWithVault: ShareContactWithVault,
|
||||
private convertToSharedVault: ConvertToSharedVault,
|
||||
private deleteSharedVaultUseCase: DeleteSharedVault,
|
||||
private removeVaultMember: RemoveVaultMember,
|
||||
private getSharedVaultUsersUseCase: GetVaultUsers,
|
||||
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,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
|
||||
eventBus.addEventHandler(this, SessionEvent.UserKeyPairChanged)
|
||||
eventBus.addEventHandler(this, UserEventServiceEvent.UserEventReceived)
|
||||
eventBus.addEventHandler(this, VaultServiceEvent.VaultRootKeyRotated)
|
||||
|
||||
this.eventDisposers.push(
|
||||
items.addObserver<TrustedContactInterface>(
|
||||
ContentType.TYPES.TrustedContact,
|
||||
async ({ changed, inserted, source }) => {
|
||||
await this.reprocessCachedInvitesTrustStatusAfterTrustedContactsChange()
|
||||
|
||||
if (source === PayloadEmitSource.LocalChanged && inserted.length > 0) {
|
||||
void this.handleCreationOfNewTrustedContacts(inserted)
|
||||
}
|
||||
if (source === PayloadEmitSource.LocalChanged && changed.length > 0) {
|
||||
void this.handleTrustedContactsChange(changed)
|
||||
}
|
||||
},
|
||||
),
|
||||
items.addObserver<TrustedContactInterface>(ContentType.TYPES.TrustedContact, async ({ changed, source }) => {
|
||||
if (source === PayloadEmitSource.LocalChanged && changed.length > 0) {
|
||||
void this.handleTrustedContactsChange(changed)
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
this.eventDisposers.push(
|
||||
@@ -120,54 +76,87 @@ export class SharedVaultService
|
||||
)
|
||||
}
|
||||
|
||||
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> {
|
||||
if (event.type === SessionEvent.UserKeyPairChanged) {
|
||||
void this.invitesServer.deleteAllInboundInvites()
|
||||
|
||||
const eventData = event.payload as UserKeyPairChangedEventData
|
||||
|
||||
void this.handleKeyPairChange.execute({
|
||||
newKeys: eventData.current,
|
||||
previousKeys: eventData.previous,
|
||||
})
|
||||
} else if (event.type === UserEventServiceEvent.UserEventReceived) {
|
||||
await this.handleUserEvent(event.payload as UserEventServiceEventPayload)
|
||||
} else if (event.type === VaultServiceEvent.VaultRootKeyRotated) {
|
||||
const payload = event.payload as VaultServiceEventPayload[VaultServiceEvent.VaultRootKeyRotated]
|
||||
await this.handleVaultRootKeyRotatedEvent(payload.vault)
|
||||
} else if (event.type === SyncEvent.ReceivedSharedVaultInvites) {
|
||||
await this.processInboundInvites(event.payload as SyncEventReceivedSharedVaultInvitesData)
|
||||
} else if (event.type === SyncEvent.ReceivedRemoteSharedVaults) {
|
||||
void this.notifyCollaborationStatusChanged()
|
||||
switch (event.type) {
|
||||
case SessionEvent.UserKeyPairChanged: {
|
||||
const eventData = event.payload as UserKeyPairChangedEventData
|
||||
void this._handleKeyPairChange.execute({
|
||||
newKeys: eventData.current,
|
||||
previousKeys: eventData.previous,
|
||||
})
|
||||
break
|
||||
}
|
||||
case UserEventServiceEvent.UserEventReceived:
|
||||
await this.handleUserEvent(event.payload as UserEventServiceEventPayload)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
private async handleUserEvent(event: UserEventServiceEventPayload): Promise<void> {
|
||||
if (event.eventPayload.eventType === UserEventType.RemovedFromSharedVault) {
|
||||
const vault = this.getVault.execute<SharedVaultListingInterface>({
|
||||
sharedVaultUuid: event.eventPayload.sharedVaultUuid,
|
||||
})
|
||||
if (!vault.isFailed()) {
|
||||
await this.deleteThirdPartyVault.execute(vault.getValue())
|
||||
switch (event.eventPayload.eventType) {
|
||||
case UserEventType.RemovedFromSharedVault: {
|
||||
const vault = this._getVault.execute<SharedVaultListingInterface>({
|
||||
sharedVaultUuid: event.eventPayload.sharedVaultUuid,
|
||||
})
|
||||
if (!vault.isFailed()) {
|
||||
await this._deleteThirdPartyVault.execute(vault.getValue())
|
||||
}
|
||||
break
|
||||
}
|
||||
} else if (event.eventPayload.eventType === UserEventType.SharedVaultItemRemoved) {
|
||||
const item = this.items.findItem(event.eventPayload.itemUuid)
|
||||
if (item) {
|
||||
this.items.removeItemsLocally([item])
|
||||
case UserEventType.SharedVaultItemRemoved: {
|
||||
const item = this.items.findItem(event.eventPayload.itemUuid)
|
||||
if (item) {
|
||||
this.items.removeItemsLocally([item])
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.isCurrentUserSharedVaultOwner(vault)) {
|
||||
if (!this.isCurrentUserVaultOwner(vault)) {
|
||||
return
|
||||
}
|
||||
|
||||
await this.notifyVaultUsersOfKeyRotation.execute({
|
||||
await this._notifyVaultUsersOfKeyRotation.execute({
|
||||
sharedVault: vault,
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
keys: {
|
||||
@@ -183,7 +172,7 @@ export class SharedVaultService
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference?: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface | ClientDisplayableError> {
|
||||
return this.createSharedVaultUseCase.execute({
|
||||
return this._createSharedVault.execute({
|
||||
vaultName: dto.name,
|
||||
vaultDescription: dto.description,
|
||||
userInputtedPassword: dto.userInputtedPassword,
|
||||
@@ -194,48 +183,7 @@ export class SharedVaultService
|
||||
async convertVaultToSharedVault(
|
||||
vault: VaultListingInterface,
|
||||
): Promise<SharedVaultListingInterface | ClientDisplayableError> {
|
||||
return this.convertToSharedVault.execute({ vault })
|
||||
}
|
||||
|
||||
public getCachedPendingInviteRecords(): PendingSharedVaultInviteRecord[] {
|
||||
return Object.values(this.pendingInvites)
|
||||
}
|
||||
|
||||
private getAllSharedVaults(): SharedVaultListingInterface[] {
|
||||
const vaults = this.vaults.getVaults().filter((vault) => vault.isSharedVaultListing())
|
||||
return vaults as SharedVaultListingInterface[]
|
||||
}
|
||||
|
||||
private findSharedVault(sharedVaultUuid: string): SharedVaultListingInterface | undefined {
|
||||
const result = this.getVault.execute<SharedVaultListingInterface>({ sharedVaultUuid })
|
||||
if (result.isFailed()) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.getValue()
|
||||
}
|
||||
|
||||
public isCurrentUserSharedVaultAdmin(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
|
||||
}
|
||||
|
||||
public isCurrentUserSharedVaultOwner(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
|
||||
}
|
||||
|
||||
public isSharedVaultUserSharedVaultOwner(user: SharedVaultUserServerHash): boolean {
|
||||
const vault = this.findSharedVault(user.shared_vault_uuid)
|
||||
return vault != undefined && vault.sharing.ownerUserUuid === user.user_uuid
|
||||
}
|
||||
|
||||
private async handleCreationOfNewTrustedContacts(_contacts: TrustedContactInterface[]): Promise<void> {
|
||||
await this.downloadInboundInvites()
|
||||
return this._convertToSharedVault.execute({ vault })
|
||||
}
|
||||
|
||||
private async handleTrustedContactsChange(contacts: TrustedContactInterface[]): Promise<void> {
|
||||
@@ -254,7 +202,7 @@ export class SharedVaultService
|
||||
continue
|
||||
}
|
||||
|
||||
await this.sendVaultDataChangeMessage.execute({
|
||||
await this._sendVaultDataChangeMessage.execute({
|
||||
vault,
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
keys: {
|
||||
@@ -265,220 +213,8 @@ export class SharedVaultService
|
||||
}
|
||||
}
|
||||
|
||||
public async downloadInboundInvites(): Promise<ClientDisplayableError | SharedVaultInviteServerHash[]> {
|
||||
const response = await this.invitesServer.getInboundUserInvites()
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to get inbound user invites ${response}`)
|
||||
}
|
||||
|
||||
this.pendingInvites = {}
|
||||
|
||||
await this.processInboundInvites(response.data.invites)
|
||||
|
||||
return response.data.invites
|
||||
}
|
||||
|
||||
public async getOutboundInvites(
|
||||
sharedVault?: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultInviteServerHash[] | ClientDisplayableError> {
|
||||
const response = await this.invitesServer.getOutboundUserInvites()
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to get outbound user invites ${response}`)
|
||||
}
|
||||
|
||||
if (sharedVault) {
|
||||
return response.data.invites.filter((invite) => invite.shared_vault_uuid === sharedVault.sharing.sharedVaultUuid)
|
||||
}
|
||||
|
||||
return response.data.invites
|
||||
}
|
||||
|
||||
public async deleteInvite(invite: SharedVaultInviteServerHash): Promise<ClientDisplayableError | void> {
|
||||
const response = await this.invitesServer.deleteInvite({
|
||||
sharedVaultUuid: invite.shared_vault_uuid,
|
||||
inviteUuid: invite.uuid,
|
||||
})
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to delete invite ${response}`)
|
||||
}
|
||||
|
||||
delete this.pendingInvites[invite.uuid]
|
||||
}
|
||||
|
||||
public async deleteSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void> {
|
||||
return this.deleteSharedVaultUseCase.execute({ sharedVault })
|
||||
}
|
||||
|
||||
private async reprocessCachedInvitesTrustStatusAfterTrustedContactsChange(): Promise<void> {
|
||||
const cachedInvites = this.getCachedPendingInviteRecords().map((record) => record.invite)
|
||||
|
||||
await this.processInboundInvites(cachedInvites)
|
||||
}
|
||||
|
||||
private async processInboundInvites(invites: SharedVaultInviteServerHash[]): Promise<void> {
|
||||
if (invites.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
for (const invite of invites) {
|
||||
const sender = this.findContact.execute({ userUuid: invite.sender_uuid })
|
||||
if (!sender.isFailed()) {
|
||||
const trustedMessage = this.getTrustedPayload.execute<AsymmetricMessageSharedVaultInvite>({
|
||||
message: invite,
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
sender: sender.getValue(),
|
||||
})
|
||||
|
||||
if (!trustedMessage.isFailed()) {
|
||||
this.pendingInvites[invite.uuid] = {
|
||||
invite,
|
||||
message: trustedMessage.getValue(),
|
||||
trusted: true,
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const untrustedMessage = this.getUntrustedPayload.execute<AsymmetricMessageSharedVaultInvite>({
|
||||
message: invite,
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
})
|
||||
|
||||
if (!untrustedMessage.isFailed()) {
|
||||
this.pendingInvites[invite.uuid] = {
|
||||
invite,
|
||||
message: untrustedMessage.getValue(),
|
||||
trusted: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await this.notifyCollaborationStatusChanged()
|
||||
}
|
||||
|
||||
private async notifyCollaborationStatusChanged(): Promise<void> {
|
||||
await this.notifyEventSync(SharedVaultServiceEvent.SharedVaultStatusChanged)
|
||||
}
|
||||
|
||||
async acceptPendingSharedVaultInvite(pendingInvite: PendingSharedVaultInviteRecord): Promise<void> {
|
||||
if (!pendingInvite.trusted) {
|
||||
throw new Error('Cannot accept untrusted invite')
|
||||
}
|
||||
|
||||
await this.acceptVaultInvite.execute({ invite: pendingInvite.invite, message: pendingInvite.message })
|
||||
|
||||
delete this.pendingInvites[pendingInvite.invite.uuid]
|
||||
|
||||
void this.sync.sync()
|
||||
|
||||
await this.decryptErroredItemsAfterInviteAccept()
|
||||
|
||||
await this.sync.syncSharedVaultsFromScratch([pendingInvite.invite.shared_vault_uuid])
|
||||
}
|
||||
|
||||
private async decryptErroredItemsAfterInviteAccept(): Promise<void> {
|
||||
await this.encryption.decryptErroredPayloads()
|
||||
}
|
||||
|
||||
public async getInvitableContactsForSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
): Promise<TrustedContactInterface[]> {
|
||||
const users = await this.getSharedVaultUsers(sharedVault)
|
||||
if (!users) {
|
||||
return []
|
||||
}
|
||||
|
||||
const contacts = this.getAllContacts.execute()
|
||||
if (contacts.isFailed()) {
|
||||
return []
|
||||
}
|
||||
return contacts.getValue().filter((contact) => {
|
||||
const isContactAlreadyInVault = users.some((user) => user.user_uuid === contact.contactUuid)
|
||||
return !isContactAlreadyInVault
|
||||
})
|
||||
}
|
||||
|
||||
private async getSharedVaultContacts(sharedVault: SharedVaultListingInterface): Promise<TrustedContactInterface[]> {
|
||||
const contacts = await this.getVaultContacts.execute(sharedVault.sharing.sharedVaultUuid)
|
||||
if (contacts.isFailed()) {
|
||||
return []
|
||||
}
|
||||
|
||||
return contacts.getValue()
|
||||
}
|
||||
|
||||
async inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const sharedVaultContacts = await this.getSharedVaultContacts(sharedVault)
|
||||
|
||||
const result = await this.inviteToVault.execute({
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
},
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
sharedVault,
|
||||
recipient: contact,
|
||||
sharedVaultContacts,
|
||||
permissions,
|
||||
})
|
||||
|
||||
void this.notifyCollaborationStatusChanged()
|
||||
|
||||
await this.sync.sync()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async removeUserFromSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
userUuid: string,
|
||||
): Promise<ClientDisplayableError | void> {
|
||||
if (!this.isCurrentUserSharedVaultAdmin(sharedVault)) {
|
||||
throw new Error('Only vault admins can remove users')
|
||||
}
|
||||
|
||||
if (this.vaults.isVaultLocked(sharedVault)) {
|
||||
throw new Error('Cannot remove user from locked vault')
|
||||
}
|
||||
|
||||
const result = await this.removeVaultMember.execute({
|
||||
sharedVaultUuid: sharedVault.sharing.sharedVaultUuid,
|
||||
userUuid,
|
||||
})
|
||||
if (isClientDisplayableError(result)) {
|
||||
return result
|
||||
}
|
||||
|
||||
void this.notifyCollaborationStatusChanged()
|
||||
|
||||
await this.vaults.rotateVaultRootKey(sharedVault)
|
||||
}
|
||||
|
||||
async leaveSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void> {
|
||||
const result = await this.leaveVault.execute({
|
||||
sharedVault: sharedVault,
|
||||
userUuid: this.session.getSureUser().uuid,
|
||||
})
|
||||
|
||||
if (isClientDisplayableError(result)) {
|
||||
return result
|
||||
}
|
||||
|
||||
void this.notifyCollaborationStatusChanged()
|
||||
}
|
||||
|
||||
async getSharedVaultUsers(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultUserServerHash[] | undefined> {
|
||||
return this.getSharedVaultUsersUseCase.execute({ sharedVaultUuid: sharedVault.sharing.sharedVaultUuid })
|
||||
return this._deleteSharedVault.execute({ sharedVault })
|
||||
}
|
||||
|
||||
async shareContactWithVaults(contact: TrustedContactInterface): Promise<void> {
|
||||
@@ -486,10 +222,10 @@ export class SharedVaultService
|
||||
throw new Error('Cannot share self contact')
|
||||
}
|
||||
|
||||
const ownedVaults = this.getAllSharedVaults().filter(this.isCurrentUserSharedVaultAdmin.bind(this))
|
||||
const ownedVaults = this._getOwnedSharedVaults.execute({ userUuid: this.session.userUuid }).getValue()
|
||||
|
||||
for (const vault of ownedVaults) {
|
||||
await this.shareContactWithVault.execute({
|
||||
await this._shareContactWithVault.execute({
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
@@ -506,7 +242,7 @@ export class SharedVaultService
|
||||
return undefined
|
||||
}
|
||||
|
||||
const contact = this.findContact.execute({ userUuid: item.last_edited_by_uuid })
|
||||
const contact = this._findContact.execute({ userUuid: item.last_edited_by_uuid })
|
||||
|
||||
return contact.isFailed() ? undefined : contact.getValue()
|
||||
}
|
||||
@@ -516,37 +252,8 @@ export class SharedVaultService
|
||||
return undefined
|
||||
}
|
||||
|
||||
const contact = this.findContact.execute({ userUuid: item.user_uuid })
|
||||
const contact = this._findContact.execute({ userUuid: item.user_uuid })
|
||||
|
||||
return contact.isFailed() ? undefined : contact.getValue()
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.sync as unknown) = undefined
|
||||
;(this.items as unknown) = undefined
|
||||
;(this.encryption as unknown) = undefined
|
||||
;(this.session as unknown) = undefined
|
||||
;(this.vaults as unknown) = undefined
|
||||
;(this.invitesServer as unknown) = undefined
|
||||
;(this.getVault as unknown) = undefined
|
||||
;(this.createSharedVaultUseCase as unknown) = undefined
|
||||
;(this.handleKeyPairChange as unknown) = undefined
|
||||
;(this.notifyVaultUsersOfKeyRotation as unknown) = undefined
|
||||
;(this.sendVaultDataChangeMessage as unknown) = undefined
|
||||
;(this.getTrustedPayload as unknown) = undefined
|
||||
;(this.getUntrustedPayload as unknown) = undefined
|
||||
;(this.findContact as unknown) = undefined
|
||||
;(this.getAllContacts as unknown) = undefined
|
||||
;(this.getVaultContacts as unknown) = undefined
|
||||
;(this.acceptVaultInvite as unknown) = undefined
|
||||
;(this.inviteToVault as unknown) = undefined
|
||||
;(this.leaveVault as unknown) = undefined
|
||||
;(this.deleteThirdPartyVault as unknown) = undefined
|
||||
;(this.shareContactWithVault as unknown) = undefined
|
||||
;(this.convertToSharedVault as unknown) = undefined
|
||||
;(this.deleteSharedVaultUseCase as unknown) = undefined
|
||||
;(this.removeVaultMember as unknown) = undefined
|
||||
;(this.getSharedVaultUsersUseCase as unknown) = undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
ClientDisplayableError,
|
||||
SharedVaultInviteServerHash,
|
||||
SharedVaultUserServerHash,
|
||||
SharedVaultPermission,
|
||||
} from '@standardnotes/responses'
|
||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
TrustedContactInterface,
|
||||
@@ -13,8 +8,6 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SharedVaultServiceEvent, SharedVaultServiceEventPayload } from './SharedVaultServiceEvent'
|
||||
import { PendingSharedVaultInviteRecord } from './PendingSharedVaultInviteRecord'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface SharedVaultServiceInterface
|
||||
extends AbstractService<SharedVaultServiceEvent, SharedVaultServiceEventPayload> {
|
||||
@@ -25,32 +18,8 @@ export interface SharedVaultServiceInterface
|
||||
storagePreference?: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface | ClientDisplayableError>
|
||||
deleteSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void>
|
||||
|
||||
convertVaultToSharedVault(vault: VaultListingInterface): Promise<SharedVaultListingInterface | ClientDisplayableError>
|
||||
|
||||
inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
): Promise<Result<SharedVaultInviteServerHash>>
|
||||
removeUserFromSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
userUuid: string,
|
||||
): Promise<ClientDisplayableError | void>
|
||||
leaveSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void>
|
||||
getSharedVaultUsers(sharedVault: SharedVaultListingInterface): Promise<SharedVaultUserServerHash[] | undefined>
|
||||
isSharedVaultUserSharedVaultOwner(user: SharedVaultUserServerHash): boolean
|
||||
isCurrentUserSharedVaultAdmin(sharedVault: SharedVaultListingInterface): boolean
|
||||
|
||||
getItemLastEditedBy(item: DecryptedItemInterface): TrustedContactInterface | undefined
|
||||
getItemSharedBy(item: DecryptedItemInterface): TrustedContactInterface | undefined
|
||||
|
||||
downloadInboundInvites(): Promise<ClientDisplayableError | SharedVaultInviteServerHash[]>
|
||||
getOutboundInvites(
|
||||
sharedVault?: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultInviteServerHash[] | ClientDisplayableError>
|
||||
acceptPendingSharedVaultInvite(pendingInvite: PendingSharedVaultInviteRecord): Promise<void>
|
||||
getCachedPendingInviteRecords(): PendingSharedVaultInviteRecord[]
|
||||
getInvitableContactsForSharedVault(sharedVault: SharedVaultListingInterface): Promise<TrustedContactInterface[]>
|
||||
deleteInvite(invite: SharedVaultInviteServerHash): Promise<ClientDisplayableError | void>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { GetVaultUsers } from './../../VaultUser/UseCase/GetVaultUsers'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { SharedVaultListingInterface, TrustedContactInterface } from '@standardnotes/models'
|
||||
|
||||
export class ContactBelongsToVault implements UseCaseInterface<boolean> {
|
||||
constructor(private getVaultUsers: GetVaultUsers) {}
|
||||
|
||||
async execute(dto: {
|
||||
contact: TrustedContactInterface
|
||||
vault: SharedVaultListingInterface
|
||||
}): Promise<Result<boolean>> {
|
||||
const users = await this.getVaultUsers.execute({
|
||||
sharedVaultUuid: dto.vault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
|
||||
if (users.isFailed()) {
|
||||
return Result.fail('Failed to get vault users')
|
||||
}
|
||||
|
||||
return Result.ok(users.getValue().some((u) => u.user_uuid === dto.contact.contactUuid))
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { SharedVaultListingInterface, VaultListingInterface, VaultListingMutator
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultServerInterface } from '@standardnotes/api'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { MoveItemsToVault } from '../../Vaults/UseCase/MoveItemsToVault'
|
||||
import { MoveItemsToVault } from '../../Vault/UseCase/MoveItemsToVault'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
|
||||
export class ConvertToSharedVault {
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultServerInterface } from '@standardnotes/api'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { CreateVault } from '../../Vaults/UseCase/CreateVault'
|
||||
import { MoveItemsToVault } from '../../Vaults/UseCase/MoveItemsToVault'
|
||||
import { CreateVault } from '../../Vault/UseCase/CreateVault'
|
||||
import { MoveItemsToVault } from '../../Vault/UseCase/MoveItemsToVault'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
|
||||
export class CreateSharedVault {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ClientDisplayableError, isErrorResponse } from '@standardnotes/response
|
||||
import { SharedVaultServerInterface } from '@standardnotes/api'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
import { SyncServiceInterface } from '../../Sync/SyncServiceInterface'
|
||||
import { DeleteVault } from '../../Vaults/UseCase/DeleteVault'
|
||||
import { DeleteVault } from '../../Vault/UseCase/DeleteVault'
|
||||
|
||||
export class DeleteSharedVault {
|
||||
constructor(
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { IsVaultOwner } from './../../VaultUser/UseCase/IsVaultOwner'
|
||||
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
import { GetSharedVaults } from './GetSharedVaults'
|
||||
|
||||
export class GetOwnedSharedVaults implements SyncUseCaseInterface<SharedVaultListingInterface[]> {
|
||||
constructor(private getSharedVaults: GetSharedVaults, private isVaultOwnwer: IsVaultOwner) {}
|
||||
|
||||
execute(dto: { userUuid: string }): Result<SharedVaultListingInterface[]> {
|
||||
const sharedVaults = this.getSharedVaults.execute().getValue()
|
||||
|
||||
const ownedVaults = sharedVaults.filter((vault) => {
|
||||
return this.isVaultOwnwer
|
||||
.execute({
|
||||
sharedVault: vault,
|
||||
userUuid: dto.userUuid,
|
||||
})
|
||||
.getValue()
|
||||
})
|
||||
|
||||
return Result.ok(ownedVaults)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { GetVaults } from '../../Vault/UseCase/GetVaults'
|
||||
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
export class GetSharedVaults implements SyncUseCaseInterface<SharedVaultListingInterface[]> {
|
||||
constructor(private getVaults: GetVaults) {}
|
||||
|
||||
execute(): Result<SharedVaultListingInterface[]> {
|
||||
const vaults = this.getVaults
|
||||
.execute()
|
||||
.getValue()
|
||||
.filter((vault) => vault.isSharedVaultListing())
|
||||
|
||||
return Result.ok(vaults as SharedVaultListingInterface[])
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { SharedVaultUserServerHash, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultUsersServerInterface } from '@standardnotes/api'
|
||||
|
||||
export class GetVaultUsers {
|
||||
constructor(private vaultUsersServer: SharedVaultUsersServerInterface) {}
|
||||
|
||||
async execute(params: { sharedVaultUuid: string }): Promise<SharedVaultUserServerHash[] | undefined> {
|
||||
const response = await this.vaultUsersServer.getSharedVaultUsers({ sharedVaultUuid: params.sharedVaultUuid })
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return response.data.users
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import { SharedVaultInviteServerHash, isErrorResponse } from '@standardnotes/res
|
||||
import { SendVaultKeyChangedMessage } from './SendVaultKeyChangedMessage'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { InviteToVault } from './InviteToVault'
|
||||
import { GetVaultContacts } from './GetVaultContacts'
|
||||
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'
|
||||
|
||||
@@ -44,7 +44,10 @@ export class NotifyVaultUsersOfKeyRotation implements UseCaseInterface<void> {
|
||||
|
||||
await this.deleteAllInvites(params.sharedVault.sharing.sharedVaultUuid)
|
||||
|
||||
const contacts = await this.getVaultContacts.execute(params.sharedVault.sharing.sharedVaultUuid)
|
||||
const contacts = await this.getVaultContacts.execute({
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
|
||||
for (const invite of existingInvites.getValue()) {
|
||||
const recipient = this.findContact.execute({ userUuid: invite.user_uuid })
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
TrustedContactInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
|
||||
import { GetVaultUsers } from './GetVaultUsers'
|
||||
import { GetVaultUsers } from '../../VaultUser/UseCase/GetVaultUsers'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { SendMessage } from '../../AsymmetricMessage/UseCase/SendMessage'
|
||||
import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
@@ -29,13 +29,16 @@ export class SendVaultDataChangedMessage implements UseCaseInterface<void> {
|
||||
signing: PkcKeyPair
|
||||
}
|
||||
}): Promise<Result<void>> {
|
||||
const users = await this.getVaultUsers.execute({ sharedVaultUuid: params.vault.sharing.sharedVaultUuid })
|
||||
if (!users) {
|
||||
const users = await this.getVaultUsers.execute({
|
||||
sharedVaultUuid: params.vault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
if (users.isFailed()) {
|
||||
return Result.fail('Cannot send metadata changed message; users not found')
|
||||
}
|
||||
|
||||
const errors: string[] = []
|
||||
for (const user of users) {
|
||||
for (const user of users.getValue()) {
|
||||
if (user.user_uuid === params.senderUuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
TrustedContactInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { AsymmetricMessageServerHash } from '@standardnotes/responses'
|
||||
import { GetVaultUsers } from './GetVaultUsers'
|
||||
import { GetVaultUsers } from '../../VaultUser/UseCase/GetVaultUsers'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { SendMessage } from '../../AsymmetricMessage/UseCase/SendMessage'
|
||||
import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
@@ -32,14 +32,14 @@ export class SendVaultKeyChangedMessage implements UseCaseInterface<void> {
|
||||
signing: PkcKeyPair
|
||||
}
|
||||
}): Promise<Result<void>> {
|
||||
const users = await this.getVaultUsers.execute({ sharedVaultUuid: params.sharedVaultUuid })
|
||||
if (!users) {
|
||||
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 errors: string[] = []
|
||||
|
||||
for (const user of users) {
|
||||
for (const user of users.getValue()) {
|
||||
if (user.user_uuid === params.senderUuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ 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 './GetVaultUsers'
|
||||
import { GetVaultUsers } from '../../VaultUser/UseCase/GetVaultUsers'
|
||||
|
||||
export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
@@ -33,17 +33,18 @@ export class ShareContactWithVault implements UseCaseInterface<void> {
|
||||
|
||||
const users = await this.getVaultUsers.execute({
|
||||
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
|
||||
if (!users) {
|
||||
if (users.isFailed()) {
|
||||
return Result.fail('Cannot share contact; shared vault users not found')
|
||||
}
|
||||
|
||||
if (users.length === 0) {
|
||||
if (users.getValue().length === 0) {
|
||||
return Result.ok()
|
||||
}
|
||||
|
||||
for (const vaultUser of users) {
|
||||
for (const vaultUser of users.getValue()) {
|
||||
if (vaultUser.user_uuid === params.senderUserUuid) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import {
|
||||
ClientDisplayableError,
|
||||
SharedVaultInviteServerHash,
|
||||
isErrorResponse,
|
||||
SharedVaultPermission,
|
||||
} from '@standardnotes/responses'
|
||||
import { SharedVaultInvitesServerInterface } from '@standardnotes/api'
|
||||
|
||||
export class UpdateSharedVaultInviteUseCase {
|
||||
constructor(private vaultInvitesServer: SharedVaultInvitesServerInterface) {}
|
||||
|
||||
async execute(params: {
|
||||
sharedVaultUuid: string
|
||||
inviteUuid: string
|
||||
encryptedMessage: string
|
||||
permissions: SharedVaultPermission
|
||||
}): Promise<SharedVaultInviteServerHash | ClientDisplayableError> {
|
||||
const response = await this.vaultInvitesServer.updateInvite({
|
||||
sharedVaultUuid: params.sharedVaultUuid,
|
||||
inviteUuid: params.inviteUuid,
|
||||
encryptedMessage: params.encryptedMessage,
|
||||
permissions: params.permissions,
|
||||
})
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromNetworkError(response)
|
||||
}
|
||||
|
||||
return response.data.invite
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,7 +5,7 @@ import {
|
||||
VaultListingInterface,
|
||||
VaultListingMutator,
|
||||
} from '@standardnotes/models'
|
||||
import { ChangeVaultOptionsDTO } from '../ChangeVaultOptionsDTO'
|
||||
import { ChangeVaultKeyOptionsDTO } from './ChangeVaultKeyOptionsDTO'
|
||||
import { GetVault } from './GetVault'
|
||||
import { EncryptionProviderInterface } from '../../Encryption/EncryptionProviderInterface'
|
||||
import { KeySystemKeyManagerInterface } from '../../KeySystem/KeySystemKeyManagerInterface'
|
||||
@@ -19,7 +19,7 @@ export class ChangeVaultKeyOptions {
|
||||
private getVault: GetVault,
|
||||
) {}
|
||||
|
||||
async execute(dto: ChangeVaultOptionsDTO): Promise<void> {
|
||||
async execute(dto: ChangeVaultKeyOptionsDTO): Promise<void> {
|
||||
const useStorageMode = dto.newKeyStorageMode ?? dto.vault.keyStorageMode
|
||||
|
||||
if (dto.newPasswordType) {
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { KeySystemRootKeyPasswordType, KeySystemRootKeyStorageMode, VaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
export type ChangeVaultOptionsDTO = {
|
||||
export type ChangeVaultKeyOptionsDTO = {
|
||||
vault: VaultListingInterface
|
||||
newPasswordType:
|
||||
| { passwordType: KeySystemRootKeyPasswordType.Randomized }
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { SyncServiceInterface } from './../../Sync/SyncServiceInterface'
|
||||
import { SyncServiceInterface } from '../../Sync/SyncServiceInterface'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
import {
|
||||
KeySystemRootKeyParamsInterface,
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { VaultListingInterface } from '@standardnotes/models'
|
||||
import { ItemManagerInterface } from './../../Item/ItemManagerInterface'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { ContentType, Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class GetVault implements SyncUseCaseInterface<VaultListingInterface> {
|
||||
@@ -20,7 +20,7 @@ export class GetVault implements SyncUseCaseInterface<VaultListingInterface> {
|
||||
} else {
|
||||
const result = vaults.find((listing) => listing.sharing?.sharedVaultUuid === query.sharedVaultUuid) as T
|
||||
if (!result) {
|
||||
return Result.fail('Vault not found')
|
||||
return Result.fail('Shared vault not found')
|
||||
}
|
||||
|
||||
return Result.ok(result)
|
||||
@@ -0,0 +1,15 @@
|
||||
import { ContentType, Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { VaultListingInterface } from '@standardnotes/models'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
|
||||
export class GetVaults implements SyncUseCaseInterface<VaultListingInterface[]> {
|
||||
constructor(private items: ItemManagerInterface) {}
|
||||
|
||||
execute(): Result<VaultListingInterface[]> {
|
||||
const vaults = this.items.getItems<VaultListingInterface>(ContentType.TYPES.VaultListing).sort((a, b) => {
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
|
||||
return Result.ok(vaults)
|
||||
}
|
||||
}
|
||||
+33
-132
@@ -3,14 +3,13 @@ import {
|
||||
DecryptedItemInterface,
|
||||
FileItem,
|
||||
KeySystemIdentifier,
|
||||
KeySystemRootKeyPasswordType,
|
||||
KeySystemRootKeyStorageMode,
|
||||
VaultListingInterface,
|
||||
VaultListingMutator,
|
||||
isNote,
|
||||
} from '@standardnotes/models'
|
||||
import { VaultServiceInterface } from './VaultServiceInterface'
|
||||
import { ChangeVaultOptionsDTO } from './ChangeVaultOptionsDTO'
|
||||
import { ChangeVaultKeyOptionsDTO } from './UseCase/ChangeVaultKeyOptionsDTO'
|
||||
import { VaultServiceEvent, VaultServiceEventPayload } from './VaultServiceEvent'
|
||||
import { CreateVault } from './UseCase/CreateVault'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
@@ -25,51 +24,51 @@ import { GetVault } from './UseCase/GetVault'
|
||||
import { ChangeVaultKeyOptions } from './UseCase/ChangeVaultKeyOptions'
|
||||
import { MutatorClientInterface } from '../Mutator/MutatorClientInterface'
|
||||
import { AlertService } from '../Alert/AlertService'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
import { KeySystemKeyManagerInterface } from '../KeySystem/KeySystemKeyManagerInterface'
|
||||
import { GetVaults } from './UseCase/GetVaults'
|
||||
import { VaultLockServiceInterface } from '../VaultLock/VaultLockServiceInterface'
|
||||
|
||||
export class VaultService
|
||||
extends AbstractService<VaultServiceEvent, VaultServiceEventPayload[VaultServiceEvent]>
|
||||
implements VaultServiceInterface
|
||||
{
|
||||
private lockMap = new Map<VaultListingInterface['uuid'], boolean>()
|
||||
|
||||
constructor(
|
||||
private sync: SyncServiceInterface,
|
||||
private items: ItemManagerInterface,
|
||||
private mutator: MutatorClientInterface,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private keys: KeySystemKeyManagerInterface,
|
||||
private vaultLocks: VaultLockServiceInterface,
|
||||
private alerts: AlertService,
|
||||
private _getVault: GetVault,
|
||||
private _getVaults: GetVaults,
|
||||
private _changeVaultKeyOptions: ChangeVaultKeyOptions,
|
||||
private _moveItemsToVault: MoveItemsToVault,
|
||||
private _createVault: CreateVault,
|
||||
private _removeItemFromVaultUseCase: RemoveItemFromVault,
|
||||
private _deleteVaultUseCase: DeleteVault,
|
||||
private _removeItemFromVault: RemoveItemFromVault,
|
||||
private _deleteVault: DeleteVault,
|
||||
private _rotateVaultKey: RotateVaultKey,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
}
|
||||
|
||||
items.addObserver(
|
||||
[ContentType.TYPES.KeySystemItemsKey, ContentType.TYPES.KeySystemRootKey, ContentType.TYPES.VaultListing],
|
||||
() => {
|
||||
void this.recomputeAllVaultsLockingState()
|
||||
},
|
||||
)
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.sync as unknown) = undefined
|
||||
;(this.items as unknown) = undefined
|
||||
;(this.mutator as unknown) = undefined
|
||||
;(this.vaultLocks as unknown) = undefined
|
||||
;(this.alerts as unknown) = undefined
|
||||
;(this._getVault as unknown) = undefined
|
||||
;(this._getVaults as unknown) = undefined
|
||||
;(this._changeVaultKeyOptions as unknown) = undefined
|
||||
;(this._moveItemsToVault as unknown) = undefined
|
||||
;(this._createVault as unknown) = undefined
|
||||
;(this._removeItemFromVault as unknown) = undefined
|
||||
;(this._deleteVault as unknown) = undefined
|
||||
;(this._rotateVaultKey as unknown) = undefined
|
||||
}
|
||||
|
||||
getVaults(): VaultListingInterface[] {
|
||||
return this.items.getItems<VaultListingInterface>(ContentType.TYPES.VaultListing).sort((a, b) => {
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
}
|
||||
|
||||
getLockedvaults(): VaultListingInterface[] {
|
||||
const vaults = this.getVaults()
|
||||
return vaults.filter((vault) => this.isVaultLocked(vault))
|
||||
return this._getVaults.execute().getValue()
|
||||
}
|
||||
|
||||
public getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined {
|
||||
@@ -90,16 +89,12 @@ export class VaultService
|
||||
return vault
|
||||
}
|
||||
|
||||
async createRandomizedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface> {
|
||||
async createRandomizedVault(dto: { name: string; description?: string }): Promise<VaultListingInterface> {
|
||||
return this.createVaultWithParameters({
|
||||
name: dto.name,
|
||||
description: dto.description,
|
||||
userInputtedPassword: undefined,
|
||||
storagePreference: dto.storagePreference,
|
||||
storagePreference: KeySystemRootKeyStorageMode.Synced,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -132,7 +127,7 @@ export class VaultService
|
||||
vault: VaultListingInterface,
|
||||
item: DecryptedItemInterface,
|
||||
): Promise<DecryptedItemInterface | undefined> {
|
||||
if (this.isVaultLocked(vault)) {
|
||||
if (this.vaultLocks.isVaultLocked(vault)) {
|
||||
throw new Error('Attempting to add item to locked vault')
|
||||
}
|
||||
|
||||
@@ -162,11 +157,11 @@ export class VaultService
|
||||
throw new Error('Cannot find vault to remove item from')
|
||||
}
|
||||
|
||||
if (this.isVaultLocked(vault)) {
|
||||
if (this.vaultLocks.isVaultLocked(vault)) {
|
||||
throw new Error('Attempting to remove item from locked vault')
|
||||
}
|
||||
|
||||
await this._removeItemFromVaultUseCase.execute({ item })
|
||||
await this._removeItemFromVault.execute({ item })
|
||||
return this.items.findSureItem(item.uuid)
|
||||
}
|
||||
|
||||
@@ -175,7 +170,7 @@ export class VaultService
|
||||
throw new Error('Shared vault must be deleted through SharedVaultService')
|
||||
}
|
||||
|
||||
const error = await this._deleteVaultUseCase.execute(vault)
|
||||
const error = await this._deleteVault.execute(vault)
|
||||
|
||||
if (isClientDisplayableError(error)) {
|
||||
return false
|
||||
@@ -200,7 +195,7 @@ export class VaultService
|
||||
}
|
||||
|
||||
async rotateVaultRootKey(vault: VaultListingInterface): Promise<void> {
|
||||
if (this.computeVaultLockState(vault) === 'locked') {
|
||||
if (this.vaultLocks.isVaultLocked(vault)) {
|
||||
throw new Error('Cannot rotate root key of locked vault')
|
||||
}
|
||||
|
||||
@@ -232,8 +227,8 @@ export class VaultService
|
||||
return this.getVault({ keySystemIdentifier: latestItem.key_system_identifier })
|
||||
}
|
||||
|
||||
async changeVaultOptions(dto: ChangeVaultOptionsDTO): Promise<void> {
|
||||
if (this.isVaultLocked(dto.vault)) {
|
||||
async changeVaultOptions(dto: ChangeVaultKeyOptionsDTO): Promise<void> {
|
||||
if (this.vaultLocks.isVaultLocked(dto.vault)) {
|
||||
throw new Error('Attempting to change vault options on a locked vault')
|
||||
}
|
||||
|
||||
@@ -243,98 +238,4 @@ export class VaultService
|
||||
await this.notifyEventSync(VaultServiceEvent.VaultRootKeyRotated, { vault: dto.vault })
|
||||
}
|
||||
}
|
||||
|
||||
public isVaultLocked(vault: VaultListingInterface): boolean {
|
||||
return this.lockMap.get(vault.uuid) === true
|
||||
}
|
||||
|
||||
public async lockNonPersistentVault(vault: VaultListingInterface): Promise<void> {
|
||||
if (vault.keyStorageMode === KeySystemRootKeyStorageMode.Synced) {
|
||||
throw new Error('Vault uses synced root key and cannot be locked')
|
||||
}
|
||||
|
||||
this.keys.clearMemoryOfKeysRelatedToVault(vault)
|
||||
|
||||
this.lockMap.set(vault.uuid, true)
|
||||
void this.notifyEventSync(VaultServiceEvent.VaultLocked, { vault })
|
||||
}
|
||||
|
||||
public async unlockNonPersistentVault(vault: VaultListingInterface, password: string): Promise<boolean> {
|
||||
if (vault.keyPasswordType !== KeySystemRootKeyPasswordType.UserInputted) {
|
||||
throw new Error('Vault uses randomized password and cannot be unlocked with user inputted password')
|
||||
}
|
||||
|
||||
if (vault.keyStorageMode === KeySystemRootKeyStorageMode.Synced) {
|
||||
throw new Error('Vault uses synced root key and cannot be unlocked with user inputted password')
|
||||
}
|
||||
|
||||
const derivedRootKey = this.encryption.deriveUserInputtedKeySystemRootKey({
|
||||
keyParams: vault.rootKeyParams,
|
||||
userInputtedPassword: password,
|
||||
})
|
||||
|
||||
this.keys.intakeNonPersistentKeySystemRootKey(derivedRootKey, vault.keyStorageMode)
|
||||
|
||||
await this.encryption.decryptErroredPayloads()
|
||||
|
||||
if (this.computeVaultLockState(vault) === 'locked') {
|
||||
this.keys.undoIntakeNonPersistentKeySystemRootKey(vault.systemIdentifier)
|
||||
return false
|
||||
}
|
||||
|
||||
this.lockMap.set(vault.uuid, false)
|
||||
void this.notifyEventSync(VaultServiceEvent.VaultUnlocked, { vault })
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private recomputeAllVaultsLockingState = async (): Promise<void> => {
|
||||
const vaults = this.getVaults()
|
||||
|
||||
for (const vault of vaults) {
|
||||
const locked = this.computeVaultLockState(vault) === 'locked'
|
||||
|
||||
if (this.lockMap.get(vault.uuid) !== locked) {
|
||||
this.lockMap.set(vault.uuid, locked)
|
||||
|
||||
if (locked) {
|
||||
void this.notifyEvent(VaultServiceEvent.VaultLocked, { vault })
|
||||
} else {
|
||||
void this.notifyEvent(VaultServiceEvent.VaultUnlocked, { vault })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private computeVaultLockState(vault: VaultListingInterface): 'locked' | 'unlocked' {
|
||||
const rootKey = this.keys.getPrimaryKeySystemRootKey(vault.systemIdentifier)
|
||||
if (!rootKey) {
|
||||
return 'locked'
|
||||
}
|
||||
|
||||
const itemsKey = this.keys.getPrimaryKeySystemItemsKey(vault.systemIdentifier)
|
||||
if (!itemsKey) {
|
||||
return 'locked'
|
||||
}
|
||||
|
||||
return 'unlocked'
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.sync as unknown) = undefined
|
||||
;(this.items as unknown) = undefined
|
||||
;(this.mutator as unknown) = undefined
|
||||
;(this.encryption as unknown) = undefined
|
||||
;(this.alerts as unknown) = undefined
|
||||
;(this._getVault as unknown) = undefined
|
||||
;(this._changeVaultKeyOptions as unknown) = undefined
|
||||
;(this._moveItemsToVault as unknown) = undefined
|
||||
;(this._createVault as unknown) = undefined
|
||||
;(this._removeItemFromVaultUseCase as unknown) = undefined
|
||||
;(this._deleteVaultUseCase as unknown) = undefined
|
||||
;(this._rotateVaultKey as unknown) = undefined
|
||||
|
||||
this.lockMap.clear()
|
||||
}
|
||||
}
|
||||
-8
@@ -2,18 +2,10 @@ import { VaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
export enum VaultServiceEvent {
|
||||
VaultRootKeyRotated = 'VaultRootKeyRotated',
|
||||
VaultUnlocked = 'VaultUnlocked',
|
||||
VaultLocked = 'VaultLocked',
|
||||
}
|
||||
|
||||
export type VaultServiceEventPayload = {
|
||||
[VaultServiceEvent.VaultRootKeyRotated]: {
|
||||
vault: VaultListingInterface
|
||||
}
|
||||
[VaultServiceEvent.VaultUnlocked]: {
|
||||
vault: VaultListingInterface
|
||||
}
|
||||
[VaultServiceEvent.VaultLocked]: {
|
||||
vault: VaultListingInterface
|
||||
}
|
||||
}
|
||||
+3
-11
@@ -6,15 +6,11 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { VaultServiceEvent, VaultServiceEventPayload } from './VaultServiceEvent'
|
||||
import { ChangeVaultOptionsDTO } from './ChangeVaultOptionsDTO'
|
||||
import { ChangeVaultKeyOptionsDTO } from './UseCase/ChangeVaultKeyOptionsDTO'
|
||||
|
||||
export interface VaultServiceInterface
|
||||
extends AbstractService<VaultServiceEvent, VaultServiceEventPayload[VaultServiceEvent]> {
|
||||
createRandomizedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface>
|
||||
createRandomizedVault(dto: { name: string; description?: string }): Promise<VaultListingInterface>
|
||||
createUserInputtedPasswordVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
@@ -24,7 +20,6 @@ export interface VaultServiceInterface
|
||||
|
||||
getVaults(): VaultListingInterface[]
|
||||
getVault(dto: { keySystemIdentifier: KeySystemIdentifier }): VaultListingInterface | undefined
|
||||
getLockedvaults(): VaultListingInterface[]
|
||||
deleteVault(vault: VaultListingInterface): Promise<boolean>
|
||||
|
||||
moveItemToVault(
|
||||
@@ -40,8 +35,5 @@ export interface VaultServiceInterface
|
||||
params: { name: string; description: string },
|
||||
): Promise<VaultListingInterface>
|
||||
rotateVaultRootKey(vault: VaultListingInterface): Promise<void>
|
||||
changeVaultOptions(dto: ChangeVaultOptionsDTO): Promise<void>
|
||||
|
||||
isVaultLocked(vault: VaultListingInterface): boolean
|
||||
unlockNonPersistentVault(vault: VaultListingInterface, password: string): Promise<boolean>
|
||||
changeVaultOptions(dto: ChangeVaultKeyOptionsDTO): Promise<void>
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { AsymmetricMessageSharedVaultInvite } from '@standardnotes/models'
|
||||
import { SharedVaultInviteServerHash } from '@standardnotes/responses'
|
||||
|
||||
export type PendingSharedVaultInviteRecord = {
|
||||
export type InviteRecord = {
|
||||
invite: SharedVaultInviteServerHash
|
||||
message: AsymmetricMessageSharedVaultInvite
|
||||
trusted: boolean
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { SendVaultInvite } from './SendVaultInvite'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
import { EncryptMessage } from '../../Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { ShareContactWithVault } from './ShareContactWithVault'
|
||||
import { ShareContactWithVault } from '../../SharedVaults/UseCase/ShareContactWithVault'
|
||||
import { KeySystemKeyManagerInterface } from '../../KeySystem/KeySystemKeyManagerInterface'
|
||||
|
||||
export class InviteToVault implements UseCaseInterface<SharedVaultInviteServerHash> {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DecryptOwnMessage } from './../../Encryption/UseCase/Asymmetric/DecryptOwnMessage'
|
||||
import { DecryptOwnMessage } from '../../Encryption/UseCase/Asymmetric/DecryptOwnMessage'
|
||||
import { AsymmetricMessageSharedVaultInvite, TrustedContactInterface } from '@standardnotes/models'
|
||||
import { SharedVaultInviteServerHash } from '@standardnotes/responses'
|
||||
import { PkcKeyPair } from '@standardnotes/sncrypto-common'
|
||||
@@ -0,0 +1,278 @@
|
||||
import { AcceptVaultInvite } from './UseCase/AcceptVaultInvite'
|
||||
import { SyncEvent, SyncEventReceivedSharedVaultInvitesData } from './../Event/SyncEvent'
|
||||
import { SessionEvent } from './../Session/SessionEvent'
|
||||
import { InternalEventInterface } from './../Internal/InternalEventInterface'
|
||||
import { InternalEventHandlerInterface } from './../Internal/InternalEventHandlerInterface'
|
||||
import { ItemManagerInterface } from './../Item/ItemManagerInterface'
|
||||
import { FindContact } from './../Contacts/UseCase/FindContact'
|
||||
import { GetUntrustedPayload } from './../AsymmetricMessage/UseCase/GetUntrustedPayload'
|
||||
import { GetTrustedPayload } from './../AsymmetricMessage/UseCase/GetTrustedPayload'
|
||||
import { InviteRecord } from './InviteRecord'
|
||||
import { VaultUserServiceInterface } from './../VaultUser/VaultUserServiceInterface'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { InviteToVault } from './UseCase/InviteToVault'
|
||||
import { GetVaultContacts } from '../VaultUser/UseCase/GetVaultContacts'
|
||||
import { SyncServiceInterface } from './../Sync/SyncServiceInterface'
|
||||
import { EncryptionProviderInterface } from './../Encryption/EncryptionProviderInterface'
|
||||
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
|
||||
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
|
||||
import { GetAllContacts } from './../Contacts/UseCase/GetAllContacts'
|
||||
import {
|
||||
AsymmetricMessageSharedVaultInvite,
|
||||
PayloadEmitSource,
|
||||
SharedVaultListingInterface,
|
||||
TrustedContactInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { VaultInviteServiceInterface } from './VaultInviteServiceInterface'
|
||||
import {
|
||||
ClientDisplayableError,
|
||||
SharedVaultInviteServerHash,
|
||||
SharedVaultPermission,
|
||||
SharedVaultUserServerHash,
|
||||
isErrorResponse,
|
||||
} from '@standardnotes/responses'
|
||||
import { AbstractService } from './../Service/AbstractService'
|
||||
import { VaultInviteServiceEvent } from './VaultInviteServiceEvent'
|
||||
import { ContentType, Result } from '@standardnotes/domain-core'
|
||||
import { SharedVaultInvitesServer } from '@standardnotes/api'
|
||||
|
||||
export class VaultInviteService
|
||||
extends AbstractService<VaultInviteServiceEvent>
|
||||
implements VaultInviteServiceInterface, InternalEventHandlerInterface
|
||||
{
|
||||
private pendingInvites: Record<string, InviteRecord> = {}
|
||||
|
||||
constructor(
|
||||
items: ItemManagerInterface,
|
||||
private session: SessionsClientInterface,
|
||||
private vaultUsers: VaultUserServiceInterface,
|
||||
private sync: SyncServiceInterface,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private invitesServer: SharedVaultInvitesServer,
|
||||
private _getAllContacts: GetAllContacts,
|
||||
private _getVault: GetVault,
|
||||
private _getVaultContacts: GetVaultContacts,
|
||||
private _inviteToVault: InviteToVault,
|
||||
private _getTrustedPayload: GetTrustedPayload,
|
||||
private _getUntrustedPayload: GetUntrustedPayload,
|
||||
private _findContact: FindContact,
|
||||
private _acceptVaultInvite: AcceptVaultInvite,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
|
||||
this.eventDisposers.push(
|
||||
items.addObserver<TrustedContactInterface>(ContentType.TYPES.TrustedContact, async ({ inserted, source }) => {
|
||||
if (source === PayloadEmitSource.LocalChanged && inserted.length > 0) {
|
||||
void this.downloadInboundInvites()
|
||||
}
|
||||
|
||||
await this.reprocessCachedInvitesTrustStatusAfterTrustedContactsChange()
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.session as unknown) = undefined
|
||||
;(this.vaultUsers as unknown) = undefined
|
||||
;(this.sync as unknown) = undefined
|
||||
;(this.encryption as unknown) = undefined
|
||||
;(this.invitesServer as unknown) = undefined
|
||||
;(this._getAllContacts as unknown) = undefined
|
||||
;(this._getVault as unknown) = undefined
|
||||
;(this._getVaultContacts as unknown) = undefined
|
||||
;(this._inviteToVault as unknown) = undefined
|
||||
;(this._getTrustedPayload as unknown) = undefined
|
||||
;(this._getUntrustedPayload as unknown) = undefined
|
||||
;(this._findContact as unknown) = undefined
|
||||
;(this._acceptVaultInvite as unknown) = undefined
|
||||
|
||||
this.pendingInvites = {}
|
||||
}
|
||||
|
||||
async handleEvent(event: InternalEventInterface): Promise<void> {
|
||||
switch (event.type) {
|
||||
case SessionEvent.UserKeyPairChanged:
|
||||
void this.invitesServer.deleteAllInboundInvites()
|
||||
break
|
||||
case SyncEvent.ReceivedSharedVaultInvites:
|
||||
await this.processInboundInvites(event.payload as SyncEventReceivedSharedVaultInvitesData)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public getCachedPendingInviteRecords(): InviteRecord[] {
|
||||
return Object.values(this.pendingInvites)
|
||||
}
|
||||
|
||||
public async downloadInboundInvites(): Promise<ClientDisplayableError | SharedVaultInviteServerHash[]> {
|
||||
const response = await this.invitesServer.getInboundUserInvites()
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to get inbound user invites ${response}`)
|
||||
}
|
||||
|
||||
this.pendingInvites = {}
|
||||
|
||||
await this.processInboundInvites(response.data.invites)
|
||||
|
||||
return response.data.invites
|
||||
}
|
||||
|
||||
public async getOutboundInvites(
|
||||
sharedVault?: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultInviteServerHash[] | ClientDisplayableError> {
|
||||
const response = await this.invitesServer.getOutboundUserInvites()
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to get outbound user invites ${response}`)
|
||||
}
|
||||
|
||||
if (sharedVault) {
|
||||
return response.data.invites.filter((invite) => invite.shared_vault_uuid === sharedVault.sharing.sharedVaultUuid)
|
||||
}
|
||||
|
||||
return response.data.invites
|
||||
}
|
||||
|
||||
public async acceptInvite(pendingInvite: InviteRecord): Promise<void> {
|
||||
if (!pendingInvite.trusted) {
|
||||
throw new Error('Cannot accept untrusted invite')
|
||||
}
|
||||
|
||||
await this._acceptVaultInvite.execute({ invite: pendingInvite.invite, message: pendingInvite.message })
|
||||
|
||||
delete this.pendingInvites[pendingInvite.invite.uuid]
|
||||
|
||||
void this.sync.sync()
|
||||
|
||||
await this.encryption.decryptErroredPayloads()
|
||||
|
||||
await this.sync.syncSharedVaultsFromScratch([pendingInvite.invite.shared_vault_uuid])
|
||||
}
|
||||
|
||||
public async getInvitableContactsForSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
): Promise<TrustedContactInterface[]> {
|
||||
const users = await this.vaultUsers.getSharedVaultUsers(sharedVault)
|
||||
if (!users) {
|
||||
return []
|
||||
}
|
||||
|
||||
const contacts = this._getAllContacts.execute()
|
||||
if (contacts.isFailed()) {
|
||||
return []
|
||||
}
|
||||
return contacts.getValue().filter((contact) => {
|
||||
const isContactAlreadyInVault = users.some((user) => user.user_uuid === contact.contactUuid)
|
||||
return !isContactAlreadyInVault
|
||||
})
|
||||
}
|
||||
|
||||
public async inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
): Promise<Result<SharedVaultInviteServerHash>> {
|
||||
const contactsResult = await this._getVaultContacts.execute({
|
||||
sharedVaultUuid: sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
if (contactsResult.isFailed()) {
|
||||
return Result.fail(contactsResult.getError())
|
||||
}
|
||||
|
||||
const contacts = contactsResult.getValue()
|
||||
|
||||
const result = await this._inviteToVault.execute({
|
||||
keys: {
|
||||
encryption: this.encryption.getKeyPair(),
|
||||
signing: this.encryption.getSigningKeyPair(),
|
||||
},
|
||||
senderUuid: this.session.getSureUser().uuid,
|
||||
sharedVault,
|
||||
recipient: contact,
|
||||
sharedVaultContacts: contacts,
|
||||
permissions,
|
||||
})
|
||||
|
||||
void this.notifyEvent(VaultInviteServiceEvent.InviteSent)
|
||||
|
||||
await this.sync.sync()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
public isVaultUserOwner(user: SharedVaultUserServerHash): boolean {
|
||||
const result = this._getVault.execute<SharedVaultListingInterface>({ sharedVaultUuid: user.shared_vault_uuid })
|
||||
if (result.isFailed()) {
|
||||
return false
|
||||
}
|
||||
|
||||
const vault = result.getValue()
|
||||
return vault != undefined && vault.sharing.ownerUserUuid === user.user_uuid
|
||||
}
|
||||
|
||||
public async deleteInvite(invite: SharedVaultInviteServerHash): Promise<ClientDisplayableError | void> {
|
||||
const response = await this.invitesServer.deleteInvite({
|
||||
sharedVaultUuid: invite.shared_vault_uuid,
|
||||
inviteUuid: invite.uuid,
|
||||
})
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromString(`Failed to delete invite ${response}`)
|
||||
}
|
||||
|
||||
delete this.pendingInvites[invite.uuid]
|
||||
}
|
||||
|
||||
private async reprocessCachedInvitesTrustStatusAfterTrustedContactsChange(): Promise<void> {
|
||||
const cachedInvites = this.getCachedPendingInviteRecords().map((record) => record.invite)
|
||||
|
||||
await this.processInboundInvites(cachedInvites)
|
||||
}
|
||||
|
||||
private async processInboundInvites(invites: SharedVaultInviteServerHash[]): Promise<void> {
|
||||
if (invites.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
for (const invite of invites) {
|
||||
const sender = this._findContact.execute({ userUuid: invite.sender_uuid })
|
||||
if (!sender.isFailed()) {
|
||||
const trustedMessage = this._getTrustedPayload.execute<AsymmetricMessageSharedVaultInvite>({
|
||||
message: invite,
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
ownUserUuid: this.session.userUuid,
|
||||
sender: sender.getValue(),
|
||||
})
|
||||
|
||||
if (!trustedMessage.isFailed()) {
|
||||
this.pendingInvites[invite.uuid] = {
|
||||
invite,
|
||||
message: trustedMessage.getValue(),
|
||||
trusted: true,
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const untrustedMessage = this._getUntrustedPayload.execute<AsymmetricMessageSharedVaultInvite>({
|
||||
message: invite,
|
||||
privateKey: this.encryption.getKeyPair().privateKey,
|
||||
})
|
||||
|
||||
if (!untrustedMessage.isFailed()) {
|
||||
this.pendingInvites[invite.uuid] = {
|
||||
invite,
|
||||
message: untrustedMessage.getValue(),
|
||||
trusted: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void this.notifyEvent(VaultInviteServiceEvent.InvitesReloaded)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum VaultInviteServiceEvent {
|
||||
InviteSent = 'VaultInviteServiceEvent.InviteSent',
|
||||
InvitesReloaded = 'VaultInviteServiceEvent.InvitesReloaded',
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { InviteRecord } from './InviteRecord'
|
||||
import { ApplicationServiceInterface } from '../Service/ApplicationServiceInterface'
|
||||
import { SharedVaultListingInterface, TrustedContactInterface } from '@standardnotes/models'
|
||||
import { ClientDisplayableError, SharedVaultInviteServerHash, SharedVaultPermission } from '@standardnotes/responses'
|
||||
import { VaultInviteServiceEvent } from './VaultInviteServiceEvent'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface VaultInviteServiceInterface extends ApplicationServiceInterface<VaultInviteServiceEvent, unknown> {
|
||||
getInvitableContactsForSharedVault(sharedVault: SharedVaultListingInterface): Promise<TrustedContactInterface[]>
|
||||
inviteContactToSharedVault(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
contact: TrustedContactInterface,
|
||||
permissions: SharedVaultPermission,
|
||||
): Promise<Result<SharedVaultInviteServerHash>>
|
||||
getCachedPendingInviteRecords(): InviteRecord[]
|
||||
deleteInvite(invite: SharedVaultInviteServerHash): Promise<ClientDisplayableError | void>
|
||||
downloadInboundInvites(): Promise<ClientDisplayableError | SharedVaultInviteServerHash[]>
|
||||
getOutboundInvites(
|
||||
sharedVault?: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultInviteServerHash[] | ClientDisplayableError>
|
||||
acceptInvite(pendingInvite: InviteRecord): Promise<void>
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
import { GetVaults } from '../Vault/UseCase/GetVaults'
|
||||
import { KeySystemRootKeyPasswordType, KeySystemRootKeyStorageMode, VaultListingInterface } from '@standardnotes/models'
|
||||
import { VaultLockServiceInterface } from './VaultLockServiceInterface'
|
||||
import { VaultLockServiceEvent, VaultLockServiceEventPayload } from './VaultLockServiceEvent'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { ItemManagerInterface } from '../Item/ItemManagerInterface'
|
||||
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { EncryptionProviderInterface } from '../Encryption/EncryptionProviderInterface'
|
||||
import { KeySystemKeyManagerInterface } from '../KeySystem/KeySystemKeyManagerInterface'
|
||||
|
||||
export class VaultLockService
|
||||
extends AbstractService<VaultLockServiceEvent, VaultLockServiceEventPayload[VaultLockServiceEvent]>
|
||||
implements VaultLockServiceInterface
|
||||
{
|
||||
private lockMap = new Map<VaultListingInterface['uuid'], boolean>()
|
||||
|
||||
constructor(
|
||||
items: ItemManagerInterface,
|
||||
private encryption: EncryptionProviderInterface,
|
||||
private keys: KeySystemKeyManagerInterface,
|
||||
private _getVaults: GetVaults,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
|
||||
items.addObserver(
|
||||
[ContentType.TYPES.KeySystemItemsKey, ContentType.TYPES.KeySystemRootKey, ContentType.TYPES.VaultListing],
|
||||
() => {
|
||||
void this.recomputeAllVaultsLockingState()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.encryption as unknown) = undefined
|
||||
;(this.keys as unknown) = undefined
|
||||
;(this._getVaults as unknown) = undefined
|
||||
|
||||
this.lockMap.clear()
|
||||
}
|
||||
|
||||
public getLockedvaults(): VaultListingInterface[] {
|
||||
const vaults = this._getVaults.execute().getValue()
|
||||
return vaults.filter((vault) => this.isVaultLocked(vault))
|
||||
}
|
||||
|
||||
public isVaultLocked(vault: VaultListingInterface): boolean {
|
||||
return this.lockMap.get(vault.uuid) === true
|
||||
}
|
||||
|
||||
public isVaultLockable(vault: VaultListingInterface): boolean {
|
||||
return vault.keyPasswordType === KeySystemRootKeyPasswordType.UserInputted
|
||||
}
|
||||
|
||||
public lockNonPersistentVault(vault: VaultListingInterface): void {
|
||||
if (vault.keyStorageMode === KeySystemRootKeyStorageMode.Synced) {
|
||||
throw new Error('Vault uses synced key storage and cannot be locked')
|
||||
}
|
||||
|
||||
if (vault.keyPasswordType !== KeySystemRootKeyPasswordType.UserInputted) {
|
||||
throw new Error('Vault uses randomized password and cannot be locked')
|
||||
}
|
||||
|
||||
this.keys.clearMemoryOfKeysRelatedToVault(vault)
|
||||
|
||||
this.lockMap.set(vault.uuid, true)
|
||||
|
||||
void this.notifyEventSync(VaultLockServiceEvent.VaultLocked, { vault })
|
||||
}
|
||||
|
||||
public async unlockNonPersistentVault(vault: VaultListingInterface, password: string): Promise<boolean> {
|
||||
if (vault.keyPasswordType !== KeySystemRootKeyPasswordType.UserInputted) {
|
||||
throw new Error('Vault uses randomized password and cannot be unlocked with user inputted password')
|
||||
}
|
||||
|
||||
if (vault.keyStorageMode === KeySystemRootKeyStorageMode.Synced) {
|
||||
throw new Error('Vault uses synced root key and cannot be unlocked with user inputted password')
|
||||
}
|
||||
|
||||
const derivedRootKey = this.encryption.deriveUserInputtedKeySystemRootKey({
|
||||
keyParams: vault.rootKeyParams,
|
||||
userInputtedPassword: password,
|
||||
})
|
||||
|
||||
this.keys.intakeNonPersistentKeySystemRootKey(derivedRootKey, vault.keyStorageMode)
|
||||
|
||||
await this.encryption.decryptErroredPayloads()
|
||||
|
||||
if (this.computeVaultLockState(vault) === 'locked') {
|
||||
this.keys.undoIntakeNonPersistentKeySystemRootKey(vault.systemIdentifier)
|
||||
return false
|
||||
}
|
||||
|
||||
this.lockMap.set(vault.uuid, false)
|
||||
void this.notifyEventSync(VaultLockServiceEvent.VaultUnlocked, { vault })
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private recomputeAllVaultsLockingState = async (): Promise<void> => {
|
||||
const vaults = this._getVaults.execute().getValue()
|
||||
|
||||
for (const vault of vaults) {
|
||||
const locked = this.computeVaultLockState(vault) === 'locked'
|
||||
|
||||
if (this.lockMap.get(vault.uuid) !== locked) {
|
||||
this.lockMap.set(vault.uuid, locked)
|
||||
|
||||
if (locked) {
|
||||
void this.notifyEvent(VaultLockServiceEvent.VaultLocked, { vault })
|
||||
} else {
|
||||
void this.notifyEvent(VaultLockServiceEvent.VaultUnlocked, { vault })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private computeVaultLockState(vault: VaultListingInterface): 'locked' | 'unlocked' {
|
||||
const rootKey = this.keys.getPrimaryKeySystemRootKey(vault.systemIdentifier)
|
||||
if (!rootKey) {
|
||||
return 'locked'
|
||||
}
|
||||
|
||||
const itemsKey = this.keys.getPrimaryKeySystemItemsKey(vault.systemIdentifier)
|
||||
if (!itemsKey) {
|
||||
return 'locked'
|
||||
}
|
||||
|
||||
return 'unlocked'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { VaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
export enum VaultLockServiceEvent {
|
||||
VaultUnlocked = 'VaultUnlocked',
|
||||
VaultLocked = 'VaultLocked',
|
||||
}
|
||||
|
||||
export type VaultLockServiceEventPayload = {
|
||||
[VaultLockServiceEvent.VaultUnlocked]: {
|
||||
vault: VaultListingInterface
|
||||
}
|
||||
[VaultLockServiceEvent.VaultLocked]: {
|
||||
vault: VaultListingInterface
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { VaultListingInterface } from '@standardnotes/models'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { VaultLockServiceEvent, VaultLockServiceEventPayload } from './VaultLockServiceEvent'
|
||||
|
||||
export interface VaultLockServiceInterface
|
||||
extends AbstractService<VaultLockServiceEvent, VaultLockServiceEventPayload[VaultLockServiceEvent]> {
|
||||
getLockedvaults(): VaultListingInterface[]
|
||||
isVaultLocked(vault: VaultListingInterface): boolean
|
||||
isVaultLockable(vault: VaultListingInterface): boolean
|
||||
lockNonPersistentVault(vault: VaultListingInterface): void
|
||||
unlockNonPersistentVault(vault: VaultListingInterface, password: string): Promise<boolean>
|
||||
}
|
||||
+7
-3
@@ -7,13 +7,17 @@ import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
export class GetVaultContacts implements UseCaseInterface<TrustedContactInterface[]> {
|
||||
constructor(private findContact: FindContact, private getVaultUsers: GetVaultUsers) {}
|
||||
|
||||
async execute(sharedVaultUuid: string): Promise<Result<TrustedContactInterface[]>> {
|
||||
const users = await this.getVaultUsers.execute({ sharedVaultUuid })
|
||||
if (!users) {
|
||||
async execute(dto: { sharedVaultUuid: string; readFromCache: boolean }): Promise<Result<TrustedContactInterface[]>> {
|
||||
const users = await this.getVaultUsers.execute({
|
||||
sharedVaultUuid: dto.sharedVaultUuid,
|
||||
readFromCache: dto.readFromCache,
|
||||
})
|
||||
if (users.isFailed()) {
|
||||
return Result.fail('Failed to get vault users')
|
||||
}
|
||||
|
||||
const contacts = users
|
||||
.getValue()
|
||||
.map((user) => this.findContact.execute({ userUuid: user.user_uuid }))
|
||||
.map((result) => (result.isFailed() ? undefined : result.getValue()))
|
||||
.filter(isNotUndefined)
|
||||
@@ -0,0 +1,31 @@
|
||||
import { VaultUserCache } from './../VaultUserCache'
|
||||
import { SharedVaultUserServerHash, getErrorFromErrorResponse, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultUsersServerInterface } from '@standardnotes/api'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class GetVaultUsers implements UseCaseInterface<SharedVaultUserServerHash[]> {
|
||||
constructor(private vaultUsersServer: SharedVaultUsersServerInterface, private cache: VaultUserCache) {}
|
||||
|
||||
async execute(params: {
|
||||
sharedVaultUuid: string
|
||||
readFromCache: boolean
|
||||
}): Promise<Result<SharedVaultUserServerHash[]>> {
|
||||
if (params.readFromCache) {
|
||||
const cachedUsers = this.cache.get(params.sharedVaultUuid)
|
||||
|
||||
if (cachedUsers) {
|
||||
return Result.ok(cachedUsers)
|
||||
}
|
||||
}
|
||||
|
||||
const response = await this.vaultUsersServer.getSharedVaultUsers({ sharedVaultUuid: params.sharedVaultUuid })
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return Result.fail(getErrorFromErrorResponse(response).message)
|
||||
}
|
||||
|
||||
this.cache.set(params.sharedVaultUuid, response.data.users)
|
||||
|
||||
return Result.ok(response.data.users)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Result, SyncUseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
export class IsVaultOwner implements SyncUseCaseInterface<boolean> {
|
||||
execute(dto: { sharedVault: SharedVaultListingInterface; userUuid: string }): Result<boolean> {
|
||||
if (!dto.sharedVault.sharing.ownerUserUuid) {
|
||||
throw new Error(`Shared vault ${dto.sharedVault.sharing.sharedVaultUuid} does not have an owner user uuid`)
|
||||
}
|
||||
|
||||
return Result.ok(dto.sharedVault.sharing.ownerUserUuid === dto.userUuid)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultUsersServerInterface } from '@standardnotes/api'
|
||||
import { DeleteThirdPartyVault } from './DeleteExternalSharedVault'
|
||||
import { DeleteThirdPartyVault } from '../../SharedVaults/UseCase/DeleteExternalSharedVault'
|
||||
import { ItemManagerInterface } from '../../Item/ItemManagerInterface'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
|
||||
+7
-4
@@ -1,17 +1,20 @@
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { getErrorFromErrorResponse, isErrorResponse } from '@standardnotes/responses'
|
||||
import { SharedVaultUsersServerInterface } from '@standardnotes/api'
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
|
||||
export class RemoveVaultMember {
|
||||
export class RemoveVaultMember implements UseCaseInterface<void> {
|
||||
constructor(private vaultUserServer: SharedVaultUsersServerInterface) {}
|
||||
|
||||
async execute(params: { sharedVaultUuid: string; userUuid: string }): Promise<ClientDisplayableError | void> {
|
||||
async execute(params: { sharedVaultUuid: string; userUuid: string }): Promise<Result<void>> {
|
||||
const response = await this.vaultUserServer.deleteSharedVaultUser({
|
||||
sharedVaultUuid: params.sharedVaultUuid,
|
||||
userUuid: params.userUuid,
|
||||
})
|
||||
|
||||
if (isErrorResponse(response)) {
|
||||
return ClientDisplayableError.FromNetworkError(response)
|
||||
return Result.fail(getErrorFromErrorResponse(response).message)
|
||||
}
|
||||
|
||||
return Result.ok()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { SharedVaultUserServerHash } from '@standardnotes/responses'
|
||||
|
||||
type SharedVaultUuid = string
|
||||
|
||||
export class VaultUserCache {
|
||||
private cache = new Map<SharedVaultUuid, SharedVaultUserServerHash[]>()
|
||||
|
||||
public get(sharedVaultUuid: SharedVaultUuid): SharedVaultUserServerHash[] | undefined {
|
||||
return this.cache.get(sharedVaultUuid)
|
||||
}
|
||||
|
||||
public set(sharedVaultUuid: SharedVaultUuid, users: SharedVaultUserServerHash[]): void {
|
||||
this.cache.set(sharedVaultUuid, users)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { VaultLockServiceInterface } from './../VaultLock/VaultLockServiceInterface'
|
||||
import { LeaveVault } from './UseCase/LeaveSharedVault'
|
||||
import { GetVault } from '../Vault/UseCase/GetVault'
|
||||
import { InternalEventBusInterface } from './../Internal/InternalEventBusInterface'
|
||||
import { RemoveVaultMember } from './UseCase/RemoveSharedVaultMember'
|
||||
import { VaultServiceInterface } from '../Vault/VaultServiceInterface'
|
||||
import { SessionsClientInterface } from './../Session/SessionsClientInterface'
|
||||
import { GetVaultUsers } from './UseCase/GetVaultUsers'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
import { VaultUserServiceInterface } from './VaultUserServiceInterface'
|
||||
import { ClientDisplayableError, SharedVaultUserServerHash, isClientDisplayableError } from '@standardnotes/responses'
|
||||
import { AbstractService } from './../Service/AbstractService'
|
||||
import { VaultUserServiceEvent } from './VaultUserServiceEvent'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
import { IsVaultOwner } from './UseCase/IsVaultOwner'
|
||||
|
||||
export class VaultUserService extends AbstractService<VaultUserServiceEvent> implements VaultUserServiceInterface {
|
||||
constructor(
|
||||
private session: SessionsClientInterface,
|
||||
private vaults: VaultServiceInterface,
|
||||
private vaultLocks: VaultLockServiceInterface,
|
||||
private _getVaultUsers: GetVaultUsers,
|
||||
private _removeVaultMember: RemoveVaultMember,
|
||||
private _isVaultOwner: IsVaultOwner,
|
||||
private _getVault: GetVault,
|
||||
private _leaveVault: LeaveVault,
|
||||
eventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(eventBus)
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
super.deinit()
|
||||
;(this.session as unknown) = undefined
|
||||
;(this.vaults as unknown) = undefined
|
||||
;(this._getVaultUsers as unknown) = undefined
|
||||
;(this._removeVaultMember as unknown) = undefined
|
||||
;(this._isVaultOwner as unknown) = undefined
|
||||
;(this._getVault as unknown) = undefined
|
||||
;(this._leaveVault as unknown) = undefined
|
||||
}
|
||||
|
||||
public async getSharedVaultUsers(
|
||||
sharedVault: SharedVaultListingInterface,
|
||||
): Promise<SharedVaultUserServerHash[] | undefined> {
|
||||
const result = await this._getVaultUsers.execute({
|
||||
sharedVaultUuid: sharedVault.sharing.sharedVaultUuid,
|
||||
readFromCache: false,
|
||||
})
|
||||
if (result.isFailed()) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return result.getValue()
|
||||
}
|
||||
|
||||
public isCurrentUserSharedVaultAdmin(sharedVault: SharedVaultListingInterface): boolean {
|
||||
return this._isVaultOwner
|
||||
.execute({
|
||||
sharedVault,
|
||||
userUuid: this.session.userUuid,
|
||||
})
|
||||
.getValue()
|
||||
}
|
||||
|
||||
async removeUserFromSharedVault(sharedVault: SharedVaultListingInterface, userUuid: string): Promise<Result<void>> {
|
||||
if (!this.isCurrentUserSharedVaultAdmin(sharedVault)) {
|
||||
throw new Error('Only vault admins can remove users')
|
||||
}
|
||||
|
||||
if (this.vaultLocks.isVaultLocked(sharedVault)) {
|
||||
throw new Error('Cannot remove user from locked vault')
|
||||
}
|
||||
|
||||
const result = await this._removeVaultMember.execute({
|
||||
sharedVaultUuid: sharedVault.sharing.sharedVaultUuid,
|
||||
userUuid,
|
||||
})
|
||||
|
||||
if (result.isFailed()) {
|
||||
return result
|
||||
}
|
||||
|
||||
void this.notifyEvent(VaultUserServiceEvent.UsersChanged)
|
||||
|
||||
await this.vaults.rotateVaultRootKey(sharedVault)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
public isVaultUserOwner(user: SharedVaultUserServerHash): boolean {
|
||||
const result = this._getVault.execute<SharedVaultListingInterface>({ sharedVaultUuid: user.shared_vault_uuid })
|
||||
if (result.isFailed()) {
|
||||
return false
|
||||
}
|
||||
|
||||
const vault = result.getValue()
|
||||
return vault != undefined && vault.sharing.ownerUserUuid === user.user_uuid
|
||||
}
|
||||
|
||||
async leaveSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void> {
|
||||
const result = await this._leaveVault.execute({
|
||||
sharedVault: sharedVault,
|
||||
userUuid: this.session.getSureUser().uuid,
|
||||
})
|
||||
|
||||
if (isClientDisplayableError(result)) {
|
||||
return result
|
||||
}
|
||||
|
||||
void this.notifyEvent(VaultUserServiceEvent.UsersChanged)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export enum VaultUserServiceEvent {
|
||||
UsersChanged = 'VaultUserServiceEvent.UsersChanged',
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { ApplicationServiceInterface } from './../Service/ApplicationServiceInterface'
|
||||
import { SharedVaultListingInterface } from '@standardnotes/models'
|
||||
import { ClientDisplayableError, SharedVaultUserServerHash } from '@standardnotes/responses'
|
||||
import { VaultUserServiceEvent } from './VaultUserServiceEvent'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface VaultUserServiceInterface extends ApplicationServiceInterface<VaultUserServiceEvent, unknown> {
|
||||
getSharedVaultUsers(sharedVault: SharedVaultListingInterface): Promise<SharedVaultUserServerHash[] | undefined>
|
||||
isCurrentUserSharedVaultAdmin(sharedVault: SharedVaultListingInterface): boolean
|
||||
removeUserFromSharedVault(sharedVault: SharedVaultListingInterface, userUuid: string): Promise<Result<void>>
|
||||
leaveSharedVault(sharedVault: SharedVaultListingInterface): Promise<ClientDisplayableError | void>
|
||||
isVaultUserOwner(user: SharedVaultUserServerHash): boolean
|
||||
}
|
||||
@@ -36,6 +36,7 @@ export * from './Contacts/ContactService'
|
||||
export * from './Contacts/ContactServiceInterface'
|
||||
export * from './Contacts/SelfContactManager'
|
||||
export * from './Contacts/UseCase/CreateOrEditContact'
|
||||
export * from './Contacts/UseCase/DeleteContact'
|
||||
export * from './Contacts/UseCase/EditContact'
|
||||
export * from './Contacts/UseCase/FindContact'
|
||||
export * from './Contacts/UseCase/GetAllContacts'
|
||||
@@ -57,15 +58,15 @@ export * from './Device/MobileDeviceInterface'
|
||||
export * from './Device/TypeCheck'
|
||||
export * from './Device/WebOrDesktopDeviceInterface'
|
||||
export * from './Diagnostics/ServiceDiagnostics'
|
||||
export * from './Encryption/UseCase/DecryptBackupFile'
|
||||
export * from './Encryption/EncryptionService'
|
||||
export * from './Encryption/EncryptionProviderInterface'
|
||||
export * from './Encryption/EncryptionService'
|
||||
export * from './Encryption/EncryptionServiceEvent'
|
||||
export * from './Encryption/Functions'
|
||||
export * from './Encryption/UseCase/Asymmetric/DecryptMessage'
|
||||
export * from './Encryption/UseCase/Asymmetric/DecryptOwnMessage'
|
||||
export * from './Encryption/UseCase/Asymmetric/EncryptMessage'
|
||||
export * from './Encryption/UseCase/Asymmetric/GetMessageAdditionalData'
|
||||
export * from './Encryption/UseCase/DecryptBackupFile'
|
||||
export * from './Encryption/UseCase/ItemsKey/CreateNewDefaultItemsKey'
|
||||
export * from './Encryption/UseCase/ItemsKey/CreateNewItemsKeyWithRollback'
|
||||
export * from './Encryption/UseCase/ItemsKey/FindDefaultItemsKey'
|
||||
@@ -111,6 +112,7 @@ export * from './Item/ItemRelationshipDirection'
|
||||
export * from './Item/ItemsServerInterface'
|
||||
export * from './Item/StaticItemCounter'
|
||||
export * from './ItemsEncryption/ItemsEncryption'
|
||||
export * from './ItemsEncryption/ItemsEncryption'
|
||||
export * from './KeySystem/KeySystemKeyManager'
|
||||
export * from './Mutator/ImportDataUseCase'
|
||||
export * from './Mutator/MutatorClientInterface'
|
||||
@@ -121,39 +123,28 @@ export * from './Protection/ProtectionClientInterface'
|
||||
export * from './Protection/TimingDisplayOption'
|
||||
export * from './Revision/RevisionClientInterface'
|
||||
export * from './Revision/RevisionManager'
|
||||
export * from './RootKeyManager/RootKeyManager'
|
||||
export * from './RootKeyManager/KeyMode'
|
||||
export * from './ItemsEncryption/ItemsEncryption'
|
||||
export * from './RootKeyManager/RootKeyManager'
|
||||
export * from './Service/AbstractService'
|
||||
export * from './Service/ApplicationServiceInterface'
|
||||
export * from './Session/SessionEvent'
|
||||
export * from './Session/SessionManagerResponse'
|
||||
export * from './Session/SessionsClientInterface'
|
||||
export * from './Session/UserKeyPairChangedEventData'
|
||||
export * from './SharedVaults/PendingSharedVaultInviteRecord'
|
||||
export * from './SharedVaults/SharedVaultService'
|
||||
export * from './SharedVaults/SharedVaultServiceEvent'
|
||||
export * from './SharedVaults/SharedVaultServiceInterface'
|
||||
export * from './SharedVaults/UseCase/AcceptVaultInvite'
|
||||
export * from './SharedVaults/UseCase/ContactBelongsToVault'
|
||||
export * from './SharedVaults/UseCase/ConvertToSharedVault'
|
||||
export * from './SharedVaults/UseCase/CreateSharedVault'
|
||||
export * from './SharedVaults/UseCase/DeleteExternalSharedVault'
|
||||
export * from './SharedVaults/UseCase/DeleteSharedVault'
|
||||
export * from './SharedVaults/UseCase/GetVaultContacts'
|
||||
export * from './SharedVaults/UseCase/GetVaultContacts'
|
||||
export * from './SharedVaults/UseCase/GetVaultUsers'
|
||||
export * from './SharedVaults/UseCase/InviteToVault'
|
||||
export * from './SharedVaults/UseCase/LeaveSharedVault'
|
||||
export * from './SharedVaults/UseCase/GetOwnedSharedVaults'
|
||||
export * from './SharedVaults/UseCase/GetSharedVaults'
|
||||
export * from './SharedVaults/UseCase/NotifyVaultUsersOfKeyRotation'
|
||||
export * from './SharedVaults/UseCase/RemoveSharedVaultMember'
|
||||
export * from './SharedVaults/UseCase/ReuploadAllInvites'
|
||||
export * from './SharedVaults/UseCase/ReuploadInvite'
|
||||
export * from './SharedVaults/UseCase/ReuploadVaultInvites'
|
||||
export * from './SharedVaults/UseCase/SendVaultDataChangedMessage'
|
||||
export * from './SharedVaults/UseCase/SendVaultInvite'
|
||||
export * from './SharedVaults/UseCase/SendVaultKeyChangedMessage'
|
||||
export * from './SharedVaults/UseCase/ShareContactWithVault'
|
||||
export * from './SharedVaults/UseCase/UpdateSharedVaultInvite'
|
||||
export * from './Singleton/SingletonManagerInterface'
|
||||
export * from './Status/StatusService'
|
||||
export * from './Status/StatusServiceInterface'
|
||||
@@ -186,14 +177,38 @@ export * from './User/UserClientInterface'
|
||||
export * from './User/UserService'
|
||||
export * from './UserEvent/UserEventService'
|
||||
export * from './UserEvent/UserEventServiceEvent'
|
||||
export * from './Vaults/ChangeVaultOptionsDTO'
|
||||
export * from './Vaults/UseCase/ChangeVaultKeyOptions'
|
||||
export * from './Vaults/UseCase/CreateVault'
|
||||
export * from './Vaults/UseCase/DeleteVault'
|
||||
export * from './Vaults/UseCase/GetVault'
|
||||
export * from './Vaults/UseCase/MoveItemsToVault'
|
||||
export * from './Vaults/UseCase/RemoveItemFromVault'
|
||||
export * from './Vaults/UseCase/RotateVaultKey'
|
||||
export * from './Vaults/VaultService'
|
||||
export * from './Vaults/VaultServiceEvent'
|
||||
export * from './Vaults/VaultServiceInterface'
|
||||
export * from './VaultInvite/InviteRecord'
|
||||
export * from './VaultInvite/UseCase/AcceptVaultInvite'
|
||||
export * from './VaultInvite/UseCase/InviteToVault'
|
||||
export * from './VaultInvite/UseCase/ReuploadAllInvites'
|
||||
export * from './VaultInvite/UseCase/ReuploadInvite'
|
||||
export * from './VaultInvite/UseCase/ReuploadVaultInvites'
|
||||
export * from './VaultInvite/UseCase/SendVaultInvite'
|
||||
export * from './VaultInvite/VaultInviteService'
|
||||
export * from './VaultInvite/VaultInviteServiceEvent'
|
||||
export * from './VaultInvite/VaultInviteServiceInterface'
|
||||
export * from './Vault/UseCase/ChangeVaultKeyOptionsDTO'
|
||||
export * from './Vault/UseCase/ChangeVaultKeyOptions'
|
||||
export * from './Vault/UseCase/CreateVault'
|
||||
export * from './Vault/UseCase/DeleteVault'
|
||||
export * from './Vault/UseCase/GetVault'
|
||||
export * from './Vault/UseCase/GetVaults'
|
||||
export * from './Vault/UseCase/MoveItemsToVault'
|
||||
export * from './Vault/UseCase/RemoveItemFromVault'
|
||||
export * from './Vault/UseCase/RotateVaultKey'
|
||||
export * from './Vault/VaultService'
|
||||
export * from './Vault/VaultServiceEvent'
|
||||
export * from './Vault/VaultServiceInterface'
|
||||
export * from './VaultLock/VaultLockService'
|
||||
export * from './VaultLock/VaultLockServiceEvent'
|
||||
export * from './VaultLock/VaultLockServiceInterface'
|
||||
export * from './VaultUser/UseCase/GetVaultContacts'
|
||||
export * from './VaultUser/UseCase/GetVaultContacts'
|
||||
export * from './VaultUser/UseCase/GetVaultUsers'
|
||||
export * from './VaultUser/UseCase/IsVaultOwner'
|
||||
export * from './VaultUser/UseCase/LeaveSharedVault'
|
||||
export * from './VaultUser/UseCase/RemoveSharedVaultMember'
|
||||
export * from './VaultUser/VaultUserCache'
|
||||
export * from './VaultUser/VaultUserService'
|
||||
export * from './VaultUser/VaultUserServiceEvent'
|
||||
export * from './VaultUser/VaultUserServiceInterface'
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [2.202.13](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-25)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/snjs
|
||||
|
||||
## [2.202.12](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/snjs
|
||||
|
||||
## [2.202.11](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-24)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/snjs
|
||||
|
||||
## [2.202.10](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2023-07-23)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/snjs
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user