@secrecy/lib 1.83.0 → 1.83.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.
@@ -179,19 +179,24 @@ export class SecrecyCloudClient {
179
179
  deleted,
180
180
  fromIdentityPubKey: this.#client.currentIdentity.identityPubKey,
181
181
  });
182
- const errors = apiNodes.missingIds.map((id) => `Node ${id} not found`);
183
- const decryptedNodes = await Promise.allSettled(apiNodes.nodes.map((node) => apiNodeToExternal(node, this.#client.keyPairs)));
184
- const nodes = decryptedNodes
185
- .filter((result) => result.status === 'fulfilled')
186
- .map((result) => result.value);
187
- const errorNodes = decryptedNodes
188
- .filter((result) => result.status === 'rejected')
189
- .map((result) => result.reason);
190
- errors.push(...errorNodes.map((err) => typeof err === 'string'
191
- ? err
192
- : err instanceof Error
193
- ? err.message
194
- : JSON.stringify(err)));
182
+ const errors = apiNodes.missingIds.map((id) => ({
183
+ message: `Node ${id} not found`,
184
+ nodeId: id,
185
+ }));
186
+ const nodes = [];
187
+ const handleNode = async (node) => {
188
+ try {
189
+ const externalNode = await apiNodeToExternal(node, this.#client.keyPairs);
190
+ nodes.push(externalNode);
191
+ }
192
+ catch (error) {
193
+ errors.push({
194
+ message: error instanceof Error ? error.message : String(error),
195
+ nodeId: node.id,
196
+ });
197
+ }
198
+ };
199
+ await Promise.all(apiNodes.nodes.map(handleNode));
195
200
  return { nodes, errors };
196
201
  }
197
202
  async nodesFull({ ids, deleted, }) {
@@ -200,19 +205,24 @@ export class SecrecyCloudClient {
200
205
  deleted,
201
206
  fromIdentityPubKey: this.#client.currentIdentity.identityPubKey,
202
207
  });
203
- const errors = apiNodes.missingIds.map((id) => `Node ${id} not found`);
204
- const decryptedNodes = await Promise.allSettled(apiNodes.nodes.map((node) => apiNodeToExternalNodeFull(node, this.#client.keyPairs)));
205
- const nodes = decryptedNodes
206
- .filter((result) => result.status === 'fulfilled')
207
- .map((result) => result.value);
208
- const errorNodes = decryptedNodes
209
- .filter((result) => result.status === 'rejected')
210
- .map((result) => result.reason);
211
- errors.push(...errorNodes.map((err) => typeof err === 'string'
212
- ? err
213
- : err instanceof Error
214
- ? err.message
215
- : JSON.stringify(err)));
208
+ const errors = apiNodes.missingIds.map((id) => ({
209
+ message: `Node ${id} not found`,
210
+ nodeId: id,
211
+ }));
212
+ const nodes = [];
213
+ const handleNode = async (node) => {
214
+ try {
215
+ const externalNode = await apiNodeToExternalNodeFull(node, this.#client.keyPairs);
216
+ nodes.push(externalNode);
217
+ }
218
+ catch (error) {
219
+ errors.push({
220
+ message: error instanceof Error ? error.message : String(error),
221
+ nodeId: node.id,
222
+ });
223
+ }
224
+ };
225
+ await Promise.all(apiNodes.nodes.map(handleNode));
216
226
  return { nodes, errors };
217
227
  }
218
228
  async dataMetadata({ id }) {
@@ -61,14 +61,20 @@ export declare class SecrecyCloudClient {
61
61
  deleted?: boolean | null | undefined;
62
62
  }): Promise<{
63
63
  nodes: Node[];
64
- errors: string[];
64
+ errors: {
65
+ message: string;
66
+ nodeId: string;
67
+ }[];
65
68
  }>;
66
69
  nodesFull({ ids, deleted, }: {
67
70
  ids: string[];
68
71
  deleted?: boolean | null | undefined;
69
72
  }): Promise<{
70
73
  nodes: NodeFull[];
71
- errors: string[];
74
+ errors: {
75
+ message: string;
76
+ nodeId: string;
77
+ }[];
72
78
  }>;
73
79
  dataMetadata({ id }: {
74
80
  id: string;
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.83.0",
5
+ "version": "1.83.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"