@secrecy/lib 1.69.1 → 1.69.2-fix-node-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.
|
@@ -342,114 +342,57 @@ export class SecrecyCloudClient {
|
|
|
342
342
|
})
|
|
343
343
|
.filter((entry) => entry !== null));
|
|
344
344
|
const infos = await this.encryptNodesForUsers(nodesToEncrypt, publicKeysMap);
|
|
345
|
-
const shares = Array.isArray(input)
|
|
346
|
-
? input.map((opt) => ({
|
|
347
|
-
nodeId: opt.nodeId,
|
|
348
|
-
userId: opt.userId,
|
|
349
|
-
permissions: {
|
|
350
|
-
rights: opt.rights,
|
|
351
|
-
addAccess: opt.addAccess,
|
|
352
|
-
delAccess: opt.delAccess,
|
|
353
|
-
sharingAddAccess: opt.sharingAddAccess,
|
|
354
|
-
sharingDelAccess: opt.sharingDelAccess,
|
|
355
|
-
},
|
|
356
|
-
}))
|
|
357
|
-
: 'userIds' in input
|
|
358
|
-
? 'nodeIds' in input
|
|
359
|
-
? input.userIds.flatMap((userId) => input.nodeIds.map((nodeId) => ({
|
|
360
|
-
permissions: {
|
|
361
|
-
rights: input.rights,
|
|
362
|
-
addAccess: input.addAccess,
|
|
363
|
-
delAccess: input.delAccess,
|
|
364
|
-
sharingAddAccess: input.sharingAddAccess,
|
|
365
|
-
sharingDelAccess: input.sharingDelAccess,
|
|
366
|
-
},
|
|
367
|
-
userId,
|
|
368
|
-
nodeId,
|
|
369
|
-
})))
|
|
370
|
-
: input.userIds.map((userId) => ({
|
|
371
|
-
permissions: {
|
|
372
|
-
rights: input.rights,
|
|
373
|
-
addAccess: input.addAccess,
|
|
374
|
-
delAccess: input.delAccess,
|
|
375
|
-
sharingAddAccess: input.sharingAddAccess,
|
|
376
|
-
sharingDelAccess: input.sharingDelAccess,
|
|
377
|
-
},
|
|
378
|
-
userId,
|
|
379
|
-
nodeId: input.nodeId,
|
|
380
|
-
}))
|
|
381
|
-
: input.nodeIds.map((nodeId) => ({
|
|
382
|
-
permissions: {
|
|
383
|
-
rights: input.rights,
|
|
384
|
-
addAccess: input.addAccess,
|
|
385
|
-
delAccess: input.delAccess,
|
|
386
|
-
sharingAddAccess: input.sharingAddAccess,
|
|
387
|
-
sharingDelAccess: input.sharingDelAccess,
|
|
388
|
-
},
|
|
389
|
-
nodeId,
|
|
390
|
-
userId: input.userId,
|
|
391
|
-
}));
|
|
392
345
|
const nodesToUpdateRights = Object.fromEntries(Object.entries(nodesMap).map(([userId, nodes]) => [
|
|
393
346
|
userId,
|
|
394
347
|
nodes
|
|
395
348
|
.filter((node) => !node.includeKeys)
|
|
396
349
|
.map((node) => {
|
|
397
|
-
const share = shares.find((share) => share.nodeId === node.nodeId && share.userId === userId);
|
|
398
|
-
if (!share) {
|
|
399
|
-
throw new Error('Unable to retrieve permissions!');
|
|
400
|
-
}
|
|
401
350
|
return {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
351
|
+
id: node.nodeId,
|
|
352
|
+
data: [],
|
|
353
|
+
nameKey: null,
|
|
354
|
+
rights: node.rights,
|
|
355
|
+
addAccess: node.addAccess,
|
|
356
|
+
delAccess: node.delAccess,
|
|
357
|
+
sharingAddAccess: node.sharingAddAccess,
|
|
358
|
+
sharingDelAccess: node.sharingDelAccess,
|
|
405
359
|
};
|
|
406
360
|
}),
|
|
407
361
|
]));
|
|
408
|
-
const withKeys = Object.fromEntries(Object.entries(infos).map(
|
|
409
|
-
|
|
362
|
+
const withKeys = Object.fromEntries(Object.entries(infos).map(([userId, nodes]) => {
|
|
363
|
+
return [
|
|
410
364
|
userId,
|
|
411
365
|
{
|
|
412
366
|
userId,
|
|
413
|
-
nodes
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
367
|
+
nodes: nodes.map((node) => {
|
|
368
|
+
const map = nodesMap[userId];
|
|
369
|
+
if (!map) {
|
|
370
|
+
throw new Error('Unable to retrieve mapped nodes!');
|
|
371
|
+
}
|
|
372
|
+
const item = map.find(({ nodeId }) => nodeId === node.id);
|
|
373
|
+
if (!item) {
|
|
374
|
+
throw new Error('Unable to retrieve user mapped nodes!');
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
id: node.id,
|
|
378
|
+
data: node.data,
|
|
379
|
+
nameKey: node.nameKey,
|
|
380
|
+
rights: item.rights,
|
|
381
|
+
addAccess: item.addAccess,
|
|
382
|
+
delAccess: item.delAccess,
|
|
383
|
+
sharingAddAccess: item.sharingAddAccess,
|
|
384
|
+
sharingDelAccess: item.sharingDelAccess,
|
|
385
|
+
};
|
|
386
|
+
}),
|
|
421
387
|
},
|
|
422
|
-
]
|
|
423
|
-
|
|
424
|
-
const share = shares.find((share) => share.userId === userId && share.nodeId === nodes[0].id);
|
|
425
|
-
if (!share) {
|
|
426
|
-
throw new Error('Unable to retrieve permissions!');
|
|
427
|
-
}
|
|
428
|
-
return [
|
|
429
|
-
userId,
|
|
430
|
-
{ userId, nodes, permissions: share.permissions },
|
|
431
|
-
];
|
|
432
|
-
}));
|
|
388
|
+
];
|
|
389
|
+
}));
|
|
433
390
|
const finishInput = [];
|
|
434
391
|
for (const [userId, nodes] of Object.entries(withKeys)) {
|
|
435
|
-
finishInput.push({
|
|
436
|
-
userId,
|
|
437
|
-
nodes: nodes.nodes.map((node) => ({
|
|
438
|
-
id: node.id,
|
|
439
|
-
nameKey: node.nameKey,
|
|
440
|
-
data: node.data.map((d) => ({
|
|
441
|
-
id: d.id,
|
|
442
|
-
key: d.key,
|
|
443
|
-
})),
|
|
444
|
-
...nodes.permissions,
|
|
445
|
-
})),
|
|
446
|
-
});
|
|
392
|
+
finishInput.push({ userId, nodes: nodes.nodes });
|
|
447
393
|
}
|
|
448
394
|
for (const [userId, nodes] of Object.entries(nodesToUpdateRights)) {
|
|
449
|
-
finishInput.push(
|
|
450
|
-
userId,
|
|
451
|
-
nodes: [{ id: node.nodeId, data: [], ...node.permissions }],
|
|
452
|
-
})));
|
|
395
|
+
finishInput.push({ userId, nodes });
|
|
453
396
|
}
|
|
454
397
|
const subState = finishInput.length > 0
|
|
455
398
|
? await this.#apiClient.cloud.shareNodeFinish.mutate(finishInput)
|
package/dist/types/client.d.ts
CHANGED
|
@@ -2581,10 +2581,17 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
2581
2581
|
delAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2582
2582
|
sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2583
2583
|
});
|
|
2584
|
-
output: Record<string, {
|
|
2584
|
+
output: Record<string, ({
|
|
2585
2585
|
nodeId: string;
|
|
2586
2586
|
includeKeys: boolean;
|
|
2587
|
-
}
|
|
2587
|
+
} & {
|
|
2588
|
+
rights: "delete" | "read" | "write";
|
|
2589
|
+
} & {
|
|
2590
|
+
addAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2591
|
+
sharingAddAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2592
|
+
delAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2593
|
+
sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
|
|
2594
|
+
})[]>;
|
|
2588
2595
|
meta: any;
|
|
2589
2596
|
}>;
|
|
2590
2597
|
updateNode: import("@trpc/server").TRPCMutationProcedure<{
|
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.69.
|
|
5
|
+
"version": "1.69.2-fix-node-sharing.2",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@commitlint/cli": "^19.8.1",
|
|
53
53
|
"@commitlint/config-conventional": "^19.8.1",
|
|
54
|
-
"@prisma/client": "6.
|
|
54
|
+
"@prisma/client": "6.16.1",
|
|
55
55
|
"@types/bun": "^1.2.21",
|
|
56
56
|
"@types/jsonwebtoken": "^9.0.10",
|
|
57
57
|
"@types/spark-md5": "^3.0.5",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@js-temporal/polyfill": "^0.5.1",
|
|
78
|
+
"@secrecy/trpc-api-types": "1.33.0-fix-share-nodes-error.1",
|
|
78
79
|
"@trpc/client": "11.5.1",
|
|
79
|
-
"@trpc/server": "11.5.1",
|
|
80
|
-
"@secrecy/trpc-api-types": "1.33.0-feat-unlog-upload.16",
|
|
80
|
+
"@trpc/server": "^11.5.1",
|
|
81
81
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|
|
82
82
|
"axios": "^1.11.0",
|
|
83
83
|
"bson": "^6.10.4",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"lru-cache": "^11.2.1",
|
|
90
90
|
"spark-md5": "^3.0.2",
|
|
91
91
|
"superjson": "2.2.2",
|
|
92
|
-
"zod": "4.1.
|
|
92
|
+
"zod": "4.1.8"
|
|
93
93
|
}
|
|
94
94
|
}
|