@secrecy/lib 1.73.1 → 1.73.2-fix-save-in-cloud-sharing.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/base-client.js
CHANGED
|
@@ -18,6 +18,7 @@ export class BaseClient {
|
|
|
18
18
|
client;
|
|
19
19
|
secrecyUrls;
|
|
20
20
|
sessionId;
|
|
21
|
+
#me = null;
|
|
21
22
|
constructor(opts) {
|
|
22
23
|
this.sessionId = opts.session;
|
|
23
24
|
this.secrecyUrls = {
|
|
@@ -52,7 +53,19 @@ export class BaseClient {
|
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
async me() {
|
|
55
|
-
|
|
56
|
+
if (this.#me === null ||
|
|
57
|
+
this.sessionId !== this.#me.sessionId ||
|
|
58
|
+
Date.now() - this.#me.fetchedAt > 5 * 60 * 1000) {
|
|
59
|
+
const data = await this.client.user.self.query({
|
|
60
|
+
// t: Date.now(), // TODO needed or what?
|
|
61
|
+
});
|
|
62
|
+
this.#me = {
|
|
63
|
+
data,
|
|
64
|
+
sessionId: this.sessionId,
|
|
65
|
+
fetchedAt: Date.now(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return this.#me.data;
|
|
56
69
|
}
|
|
57
70
|
static async getUser(userId, opts) {
|
|
58
71
|
const user = await getPublicUser(this.getBaseClient(opts), userId);
|
|
@@ -29,7 +29,9 @@ export class SecrecyCloudClient {
|
|
|
29
29
|
const node = await apiNodeFullToInternalFull(addDataToHistory, this.#keys);
|
|
30
30
|
const data = node.history.find((d) => d.id === dataId);
|
|
31
31
|
if (data !== undefined) {
|
|
32
|
-
|
|
32
|
+
// TODO sad to have to make this extra request
|
|
33
|
+
const me = await this.#client.me();
|
|
34
|
+
const users = node.users.filter(([u]) => u.id !== me.id);
|
|
33
35
|
const userIds = users.map(([user]) => user.id);
|
|
34
36
|
const userKeys = await this.#client.app.userPublicKey(userIds);
|
|
35
37
|
const shares = users.map(([user]) => {
|
|
@@ -295,8 +297,7 @@ export class SecrecyCloudClient {
|
|
|
295
297
|
nameKey: encryptedNameKey,
|
|
296
298
|
});
|
|
297
299
|
const folder = await apiNodeToExternalNodeFull(createdFolder, this.#keys);
|
|
298
|
-
const users = folder.parent?.users?.filter(([u]) => u.id !==
|
|
299
|
-
[];
|
|
300
|
+
const users = folder.parent?.users?.filter(([u]) => u.id !== folder.owner.id) ?? [];
|
|
300
301
|
if (users.length > 0) {
|
|
301
302
|
await this.shareNode(users.map(([user, permissions]) => ({
|
|
302
303
|
userId: user.id,
|
|
@@ -618,15 +619,13 @@ export class SecrecyCloudClient {
|
|
|
618
619
|
nameKey: encryptedNameKey,
|
|
619
620
|
});
|
|
620
621
|
const node = await apiNodeToExternalNodeFull(saveInCloud, this.#keys);
|
|
621
|
-
const me = node.parent?.users.find(([u]) => u.id ===
|
|
622
|
+
const me = node.parent?.users.find(([u]) => u.id === node.owner.id);
|
|
622
623
|
// TODO: ??
|
|
623
624
|
if (me !== undefined && ['delete', 'write'].includes(me[1].rights)) {
|
|
624
|
-
const others = node.parent?.users.filter(([u]) => u.id !==
|
|
625
|
-
[];
|
|
625
|
+
const others = node.parent?.users.filter(([u]) => u.id !== node.owner.id) ?? [];
|
|
626
626
|
if (others.length > 0) {
|
|
627
627
|
await this.shareNode(others.map(([user, permissions]) => ({
|
|
628
628
|
userId: user.id,
|
|
629
|
-
permissions,
|
|
630
629
|
nodeId: node.id,
|
|
631
630
|
...permissions,
|
|
632
631
|
})));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@secrecy/lib",
|
|
3
3
|
"author": "Anonymize <anonymize@gmail.com>",
|
|
4
4
|
"description": "Anonymize Secrecy Library",
|
|
5
|
-
"version": "1.73.
|
|
5
|
+
"version": "1.73.2-fix-save-in-cloud-sharing.2",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|