@secrecy/lib 1.65.0-feat-next15.4 → 1.66.0-feat-next15.1
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.
|
@@ -389,7 +389,7 @@ export class SecrecyCloudClient {
|
|
|
389
389
|
.map((node) => {
|
|
390
390
|
const share = shares.find((share) => share.nodeId === node.nodeId && share.userId === userId);
|
|
391
391
|
if (!share) {
|
|
392
|
-
throw new Error('Unable to retrieve
|
|
392
|
+
throw new Error('Unable to retrieve permissions!');
|
|
393
393
|
}
|
|
394
394
|
return {
|
|
395
395
|
nodeId: node.nodeId,
|
|
@@ -401,12 +401,22 @@ export class SecrecyCloudClient {
|
|
|
401
401
|
const withKeys = Object.fromEntries(Object.entries(infos).map('rights' in input
|
|
402
402
|
? ([userId, nodes]) => [
|
|
403
403
|
userId,
|
|
404
|
-
{
|
|
404
|
+
{
|
|
405
|
+
userId,
|
|
406
|
+
nodes,
|
|
407
|
+
permissions: {
|
|
408
|
+
rights: input.rights,
|
|
409
|
+
addAccess: input.addAccess,
|
|
410
|
+
delAccess: input.delAccess,
|
|
411
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
412
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
413
|
+
},
|
|
414
|
+
},
|
|
405
415
|
]
|
|
406
416
|
: ([userId, nodes]) => {
|
|
407
417
|
const share = shares.find((share) => share.userId === userId && share.nodeId === nodes[0].id);
|
|
408
418
|
if (!share) {
|
|
409
|
-
throw new Error('Unable to retrieve
|
|
419
|
+
throw new Error('Unable to retrieve permissions!');
|
|
410
420
|
}
|
|
411
421
|
return [
|
|
412
422
|
userId,
|
|
@@ -419,9 +429,12 @@ export class SecrecyCloudClient {
|
|
|
419
429
|
userId,
|
|
420
430
|
nodes: nodes.nodes.map((node) => ({
|
|
421
431
|
id: node.id,
|
|
422
|
-
...nodes.permissions,
|
|
423
432
|
nameKey: node.nameKey,
|
|
424
|
-
data: node.data.map((d) => ({
|
|
433
|
+
data: node.data.map((d) => ({
|
|
434
|
+
id: d.id,
|
|
435
|
+
key: d.key,
|
|
436
|
+
})),
|
|
437
|
+
...nodes.permissions,
|
|
425
438
|
})),
|
|
426
439
|
});
|
|
427
440
|
}
|
|
@@ -648,13 +661,14 @@ export class SecrecyCloudClient {
|
|
|
648
661
|
});
|
|
649
662
|
const node = await apiNodeToExternalNodeFull(saveInCloud, this.#keys);
|
|
650
663
|
const me = node.parent?.users.find(([u]) => u.id === this.#client.app.userId);
|
|
651
|
-
// TODO:
|
|
652
|
-
if (me !== undefined && ['
|
|
664
|
+
// TODO: ??
|
|
665
|
+
if (me !== undefined && ['delete', 'write'].includes(me[1].rights)) {
|
|
653
666
|
const others = node.parent?.users.filter(([u]) => u.id !== this.#client.app.userId) ??
|
|
654
667
|
[];
|
|
655
668
|
if (others.length > 0) {
|
|
656
669
|
await this.shareNode(others.map(([user, permissions]) => ({
|
|
657
670
|
userId: user.id,
|
|
671
|
+
permissions,
|
|
658
672
|
nodeId: node.id,
|
|
659
673
|
...permissions,
|
|
660
674
|
})));
|
|
@@ -678,9 +692,7 @@ export class SecrecyCloudClient {
|
|
|
678
692
|
}
|
|
679
693
|
// Retrieve and format nodes.
|
|
680
694
|
for (const nodeId of nodeIds) {
|
|
681
|
-
let node;
|
|
682
|
-
node ??= nodesEncryptionCache.get(nodeId);
|
|
683
|
-
node ??= nodesCache.get(nodeId);
|
|
695
|
+
let node = nodesEncryptionCache.get(nodeId) ?? nodesCache.get(nodeId);
|
|
684
696
|
if (node &&
|
|
685
697
|
'history' in node &&
|
|
686
698
|
node.history.length > 0 &&
|
|
@@ -66,8 +66,12 @@ function internalNodeToNode(internal) {
|
|
|
66
66
|
})),
|
|
67
67
|
access: {
|
|
68
68
|
isRoot: internal.access.isRoot,
|
|
69
|
-
rights: internal.access.rights,
|
|
70
69
|
sharedByPubKey: internal.access.sharedByPubKey,
|
|
70
|
+
rights: internal.access.rights,
|
|
71
|
+
addAccess: internal.access.addAccess,
|
|
72
|
+
delAccess: internal.access.delAccess,
|
|
73
|
+
sharingAddAccess: internal.access.sharingAddAccess,
|
|
74
|
+
sharingDelAccess: internal.access.sharingDelAccess,
|
|
71
75
|
},
|
|
72
76
|
};
|
|
73
77
|
return node;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RouterOutputs } from '../../client.js';
|
|
2
2
|
import type { DataMetadata, InternalData, PublicUser } from './index.js';
|
|
3
|
-
export type
|
|
4
|
-
export type Rights =
|
|
5
|
-
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T &
|
|
3
|
+
export type Permissions = ApiNode['users'][number][1];
|
|
4
|
+
export type Rights = Permissions['rights'];
|
|
5
|
+
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & Permissions & {
|
|
6
6
|
isRoot: boolean;
|
|
7
7
|
sharedByPubKey: string;
|
|
8
8
|
};
|
|
@@ -33,7 +33,7 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
|
|
|
33
33
|
breadcrumb: T[];
|
|
34
34
|
owner: PublicUser;
|
|
35
35
|
access: NodeAccess<U>;
|
|
36
|
-
users: Array<[PublicUser,
|
|
36
|
+
users: Array<[PublicUser, Permissions]>;
|
|
37
37
|
currentDataId: string | null;
|
|
38
38
|
parentId: string | null;
|
|
39
39
|
}
|
|
@@ -82,9 +82,9 @@ export type ShareNodeDetails = {
|
|
|
82
82
|
}[];
|
|
83
83
|
invalidRightsAccesses: {
|
|
84
84
|
userId: string;
|
|
85
|
-
current:
|
|
85
|
+
current: Permissions;
|
|
86
86
|
nodeId: string;
|
|
87
|
-
expect:
|
|
87
|
+
expect: Permissions;
|
|
88
88
|
}[];
|
|
89
89
|
};
|
|
90
90
|
export {};
|
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.
|
|
5
|
+
"version": "1.66.0-feat-next15.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|