@secrecy/lib 1.69.1 → 1.69.2-fix-node-sharing.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.
|
@@ -342,115 +342,56 @@ 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
351
|
nodeId: node.nodeId,
|
|
403
352
|
userId: userId,
|
|
404
|
-
permissions:
|
|
353
|
+
permissions: {
|
|
354
|
+
rights: node.rights,
|
|
355
|
+
addAccess: node.addAccess,
|
|
356
|
+
delAccess: node.delAccess,
|
|
357
|
+
sharingAddAccess: node.sharingAddAccess,
|
|
358
|
+
sharingDelAccess: node.sharingDelAccess,
|
|
359
|
+
},
|
|
405
360
|
};
|
|
406
361
|
}),
|
|
407
362
|
]));
|
|
408
|
-
const withKeys = Object.fromEntries(Object.entries(infos).map(
|
|
409
|
-
|
|
363
|
+
const withKeys = Object.fromEntries(Object.entries(infos).map(([userId, nodes]) => {
|
|
364
|
+
return [
|
|
410
365
|
userId,
|
|
411
366
|
{
|
|
412
367
|
userId,
|
|
413
|
-
nodes
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
368
|
+
nodes: nodes.map((node) => {
|
|
369
|
+
const map = nodesMap[userId];
|
|
370
|
+
if (!map) {
|
|
371
|
+
throw new Error('Unable to retrieve mapped nodes!');
|
|
372
|
+
}
|
|
373
|
+
const item = map.find(({ nodeId }) => nodeId === node.id);
|
|
374
|
+
if (!item) {
|
|
375
|
+
throw new Error('Unable to retrieve user mapped nodes!');
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
id: node.id,
|
|
379
|
+
data: node.data,
|
|
380
|
+
nameKey: node.nameKey,
|
|
381
|
+
rights: item.rights,
|
|
382
|
+
addAccess: item.addAccess,
|
|
383
|
+
delAccess: item.delAccess,
|
|
384
|
+
sharingAddAccess: item.sharingAddAccess,
|
|
385
|
+
sharingDelAccess: item.sharingDelAccess,
|
|
386
|
+
};
|
|
387
|
+
}),
|
|
421
388
|
},
|
|
422
|
-
]
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return [
|
|
429
|
-
userId,
|
|
430
|
-
{ userId, nodes, permissions: share.permissions },
|
|
431
|
-
];
|
|
432
|
-
}));
|
|
433
|
-
const finishInput = [];
|
|
434
|
-
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
|
-
});
|
|
447
|
-
}
|
|
448
|
-
for (const [userId, nodes] of Object.entries(nodesToUpdateRights)) {
|
|
449
|
-
finishInput.push(...nodes.map((node) => ({
|
|
450
|
-
userId,
|
|
451
|
-
nodes: [{ id: node.nodeId, data: [], ...node.permissions }],
|
|
452
|
-
})));
|
|
453
|
-
}
|
|
389
|
+
];
|
|
390
|
+
}));
|
|
391
|
+
const finishInput = Object.fromEntries([
|
|
392
|
+
...Object.entries(withKeys),
|
|
393
|
+
...Object.entries(nodesToUpdateRights),
|
|
394
|
+
]);
|
|
454
395
|
const subState = finishInput.length > 0
|
|
455
396
|
? await this.#apiClient.cloud.shareNodeFinish.mutate(finishInput)
|
|
456
397
|
: { isFinished: true, details: {} };
|
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.1",
|
|
5
|
+
"version": "1.69.2-fix-node-sharing.1",
|
|
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
|
}
|