@secrecy/lib 1.61.0 → 1.61.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.
|
@@ -532,13 +532,16 @@ export class SecrecyCloudClient {
|
|
|
532
532
|
}
|
|
533
533
|
perNode = async (nodeId, publicKey) => {
|
|
534
534
|
let node = nodesCache.get(nodeId);
|
|
535
|
-
if (node === undefined) {
|
|
535
|
+
if (node === undefined || !('history' in node)) {
|
|
536
536
|
await this.node({ id: nodeId });
|
|
537
537
|
node = nodesCache.get(nodeId);
|
|
538
538
|
if (node === undefined) {
|
|
539
539
|
return null;
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
+
if (!('history' in node) || node.history.length === 0) {
|
|
543
|
+
throw new Error("Can't share a node whitout data!");
|
|
544
|
+
}
|
|
542
545
|
const nameKey = node.access?.nameKey;
|
|
543
546
|
return {
|
|
544
547
|
id: node.id,
|
|
@@ -44,7 +44,7 @@ export async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
44
44
|
}
|
|
45
45
|
export async function apiNodeFullToInternalFull(apiNodeFull, keyPair) {
|
|
46
46
|
const f = await apiNodeToInternal(apiNodeFull, keyPair);
|
|
47
|
-
|
|
47
|
+
const nodeFull = {
|
|
48
48
|
...f,
|
|
49
49
|
current: apiNodeFull.current !== null
|
|
50
50
|
? apiDataToInternal(apiNodeFull.current, keyPair)
|
|
@@ -55,6 +55,8 @@ export async function apiNodeFullToInternalFull(apiNodeFull, keyPair) {
|
|
|
55
55
|
children: await Promise.all(apiNodeFull.children.map(async (s) => await apiNodeToInternal(s, keyPair))),
|
|
56
56
|
history: apiNodeFull.history.map((f) => apiDataToInternal(f, keyPair)),
|
|
57
57
|
};
|
|
58
|
+
nodesCache.set(f.id, nodeFull);
|
|
59
|
+
return nodeFull;
|
|
58
60
|
}
|
|
59
61
|
export function internalNodeToNode(internal) {
|
|
60
62
|
const node = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node, ApiNode, InternalNode, ApiNodeFull, InternalNodeFull, NodeFull, KeyPair, ApiNodeParent } from '../types/index.js';
|
|
2
|
-
export declare function apiNodeToInternal(apiNode: ApiNode | ApiNodeParent | ApiNodeFull, keyPair: KeyPair): Promise<InternalNode>;
|
|
2
|
+
export declare function apiNodeToInternal(apiNode: ApiNode | ApiNodeParent | ApiNodeFull, keyPair: KeyPair): Promise<InternalNode | InternalNodeFull>;
|
|
3
3
|
export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull, keyPair: KeyPair): Promise<InternalNodeFull>;
|
|
4
4
|
export declare function internalNodeToNode(internal: InternalNode): Node;
|
|
5
5
|
export declare function internalNodeFullToNodeFull(internal: InternalNodeFull): NodeFull;
|
package/package.json
CHANGED