@secrecy/lib 1.64.1-feat-share-up-to.1 → 1.64.2-feat-share-up-to.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.
- package/dist/lib/client/SecrecyCloudClient.js +53 -12
- package/dist/lib/client/convert/node.js +5 -2
- package/dist/types/client/SecrecyCloudClient.d.ts +10 -8
- package/dist/types/client/types/node.d.ts +6 -7
- package/dist/types/client.d.ts +578 -612
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -308,7 +308,11 @@ export class SecrecyCloudClient {
|
|
|
308
308
|
await this.shareNode(users.map(([user, permissions]) => ({
|
|
309
309
|
userId: user.id,
|
|
310
310
|
nodeId: folder.id,
|
|
311
|
-
permissions,
|
|
311
|
+
rights: permissions.rights,
|
|
312
|
+
addAccess: permissions.addAccess,
|
|
313
|
+
delAccess: permissions.delAccess,
|
|
314
|
+
sharingAddAccess: permissions.sharingAddAccess,
|
|
315
|
+
sharingDelAccess: permissions.sharingDelAccess,
|
|
312
316
|
})));
|
|
313
317
|
}
|
|
314
318
|
return folder;
|
|
@@ -355,21 +359,49 @@ export class SecrecyCloudClient {
|
|
|
355
359
|
.filter((entry) => entry !== null));
|
|
356
360
|
const infos = await this.encryptNodesForUsers(nodesToEncrypt, publicKeysMap);
|
|
357
361
|
const shares = Array.isArray(input)
|
|
358
|
-
? input
|
|
362
|
+
? input.map((opt) => ({
|
|
363
|
+
nodeId: opt.nodeId,
|
|
364
|
+
userId: opt.userId,
|
|
365
|
+
permissions: {
|
|
366
|
+
rights: opt.rights,
|
|
367
|
+
addAccess: opt.addAccess,
|
|
368
|
+
delAccess: opt.delAccess,
|
|
369
|
+
sharingAddAccess: opt.sharingAddAccess,
|
|
370
|
+
sharingDelAccess: opt.sharingDelAccess,
|
|
371
|
+
},
|
|
372
|
+
}))
|
|
359
373
|
: 'userIds' in input
|
|
360
374
|
? 'nodeIds' in input
|
|
361
375
|
? input.userIds.flatMap((userId) => input.nodeIds.map((nodeId) => ({
|
|
362
|
-
permissions:
|
|
376
|
+
permissions: {
|
|
377
|
+
rights: input.rights,
|
|
378
|
+
addAccess: input.addAccess,
|
|
379
|
+
delAccess: input.delAccess,
|
|
380
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
381
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
382
|
+
},
|
|
363
383
|
userId,
|
|
364
384
|
nodeId,
|
|
365
385
|
})))
|
|
366
386
|
: input.userIds.map((userId) => ({
|
|
367
|
-
permissions:
|
|
387
|
+
permissions: {
|
|
388
|
+
rights: input.rights,
|
|
389
|
+
addAccess: input.addAccess,
|
|
390
|
+
delAccess: input.delAccess,
|
|
391
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
392
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
393
|
+
},
|
|
368
394
|
userId,
|
|
369
395
|
nodeId: input.nodeId,
|
|
370
396
|
}))
|
|
371
397
|
: input.nodeIds.map((nodeId) => ({
|
|
372
|
-
permissions:
|
|
398
|
+
permissions: {
|
|
399
|
+
rights: input.rights,
|
|
400
|
+
addAccess: input.addAccess,
|
|
401
|
+
delAccess: input.delAccess,
|
|
402
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
403
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
404
|
+
},
|
|
373
405
|
nodeId,
|
|
374
406
|
userId: input.userId,
|
|
375
407
|
}));
|
|
@@ -389,10 +421,20 @@ export class SecrecyCloudClient {
|
|
|
389
421
|
};
|
|
390
422
|
}),
|
|
391
423
|
]));
|
|
392
|
-
const withKeys = Object.fromEntries(Object.entries(infos).map('
|
|
424
|
+
const withKeys = Object.fromEntries(Object.entries(infos).map('rights' in input
|
|
393
425
|
? ([userId, nodes]) => [
|
|
394
426
|
userId,
|
|
395
|
-
{
|
|
427
|
+
{
|
|
428
|
+
userId,
|
|
429
|
+
nodes,
|
|
430
|
+
permissions: {
|
|
431
|
+
rights: input.rights,
|
|
432
|
+
addAccess: input.addAccess,
|
|
433
|
+
delAccess: input.delAccess,
|
|
434
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
435
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
436
|
+
},
|
|
437
|
+
},
|
|
396
438
|
]
|
|
397
439
|
: ([userId, nodes]) => {
|
|
398
440
|
const share = shares.find((share) => share.userId === userId && share.nodeId === nodes[0].id);
|
|
@@ -410,12 +452,12 @@ export class SecrecyCloudClient {
|
|
|
410
452
|
userId,
|
|
411
453
|
nodes: nodes.nodes.map((node) => ({
|
|
412
454
|
id: node.id,
|
|
413
|
-
permissions: nodes.permissions,
|
|
414
455
|
nameKey: node.nameKey,
|
|
415
456
|
data: node.data.map((d) => ({
|
|
416
457
|
id: d.id,
|
|
417
458
|
key: d.key,
|
|
418
459
|
})),
|
|
460
|
+
...nodes.permissions,
|
|
419
461
|
})),
|
|
420
462
|
});
|
|
421
463
|
}
|
|
@@ -425,8 +467,8 @@ export class SecrecyCloudClient {
|
|
|
425
467
|
nodes: [
|
|
426
468
|
{
|
|
427
469
|
id: node.nodeId,
|
|
428
|
-
permissions: node.permissions,
|
|
429
470
|
data: [],
|
|
471
|
+
...node.permissions,
|
|
430
472
|
},
|
|
431
473
|
],
|
|
432
474
|
})));
|
|
@@ -662,6 +704,7 @@ export class SecrecyCloudClient {
|
|
|
662
704
|
userId: user.id,
|
|
663
705
|
permissions,
|
|
664
706
|
nodeId: node.id,
|
|
707
|
+
...permissions,
|
|
665
708
|
})));
|
|
666
709
|
}
|
|
667
710
|
}
|
|
@@ -683,9 +726,7 @@ export class SecrecyCloudClient {
|
|
|
683
726
|
}
|
|
684
727
|
// Retrieve and format nodes.
|
|
685
728
|
for (const nodeId of nodeIds) {
|
|
686
|
-
let node;
|
|
687
|
-
node ??= nodesEncryptionCache.get(nodeId);
|
|
688
|
-
node ??= nodesCache.get(nodeId);
|
|
729
|
+
let node = nodesEncryptionCache.get(nodeId) ?? nodesCache.get(nodeId);
|
|
689
730
|
if (node &&
|
|
690
731
|
'history' in node &&
|
|
691
732
|
node.history.length > 0 &&
|
|
@@ -25,7 +25,6 @@ async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
25
25
|
parentId: apiNode.parentId ?? null,
|
|
26
26
|
currentDataId: apiNode.currentDataId ?? null,
|
|
27
27
|
};
|
|
28
|
-
internal.access = { ...apiNode.access };
|
|
29
28
|
if (apiNode.access.nameKey !== null) {
|
|
30
29
|
const key = decryptCryptoBox(sodium.from_hex(apiNode.access.nameKey), apiNode.access.sharedByPubKey, keyPair.privateKey);
|
|
31
30
|
internal.name = sodium.to_string(await decryptSecretStream(key, sodium.from_hex(internal.name)));
|
|
@@ -68,7 +67,11 @@ function internalNodeToNode(internal) {
|
|
|
68
67
|
access: {
|
|
69
68
|
isRoot: internal.access.isRoot,
|
|
70
69
|
sharedByPubKey: internal.access.sharedByPubKey,
|
|
71
|
-
|
|
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,
|
|
72
75
|
},
|
|
73
76
|
};
|
|
74
77
|
return node;
|
|
@@ -134,18 +134,20 @@ export declare class SecrecyCloudClient {
|
|
|
134
134
|
userId: string;
|
|
135
135
|
current: {
|
|
136
136
|
rights: "delete" | "write" | "read";
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
} & {
|
|
138
|
+
addAccess?: "delete" | "write" | "read" | null | undefined;
|
|
139
|
+
sharingAddAccess?: "delete" | "write" | "read" | null | undefined;
|
|
140
|
+
delAccess?: "delete" | "write" | "read" | null | undefined;
|
|
141
|
+
sharingDelAccess?: "delete" | "write" | "read" | null | undefined;
|
|
141
142
|
};
|
|
142
143
|
nodeId: string;
|
|
143
144
|
expect: {
|
|
144
145
|
rights: "delete" | "write" | "read";
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
} & {
|
|
147
|
+
addAccess?: "delete" | "write" | "read" | null | undefined;
|
|
148
|
+
sharingAddAccess?: "delete" | "write" | "read" | null | undefined;
|
|
149
|
+
delAccess?: "delete" | "write" | "read" | null | undefined;
|
|
150
|
+
sharingDelAccess?: "delete" | "write" | "read" | null | undefined;
|
|
149
151
|
};
|
|
150
152
|
}[];
|
|
151
153
|
};
|
|
@@ -1,9 +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
|
|
5
|
-
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & {
|
|
6
|
-
permissions: Permissions;
|
|
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 & {
|
|
7
6
|
isRoot: boolean;
|
|
8
7
|
sharedByPubKey: string;
|
|
9
8
|
};
|
|
@@ -34,7 +33,7 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
|
|
|
34
33
|
breadcrumb: T[];
|
|
35
34
|
owner: PublicUser;
|
|
36
35
|
access: NodeAccess<U>;
|
|
37
|
-
users: Array<[PublicUser,
|
|
36
|
+
users: Array<[PublicUser, Permissions]>;
|
|
38
37
|
currentDataId: string | null;
|
|
39
38
|
parentId: string | null;
|
|
40
39
|
}
|
|
@@ -83,9 +82,9 @@ export type ShareNodeDetails = {
|
|
|
83
82
|
}[];
|
|
84
83
|
invalidRightsAccesses: {
|
|
85
84
|
userId: string;
|
|
86
|
-
current:
|
|
85
|
+
current: Permissions;
|
|
87
86
|
nodeId: string;
|
|
88
|
-
expect:
|
|
87
|
+
expect: Permissions;
|
|
89
88
|
}[];
|
|
90
89
|
};
|
|
91
90
|
export {};
|