@seed-hypermedia/client 0.0.28 → 0.0.29
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/index.mjs +22 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -668,6 +668,20 @@ function cleanContentOfUndefined(content) {
|
|
|
668
668
|
if (children) cleanContentOfUndefined(children);
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
|
+
function deepStripUndefined(value) {
|
|
672
|
+
if (Array.isArray(value)) {
|
|
673
|
+
return value.map((item) => deepStripUndefined(item));
|
|
674
|
+
}
|
|
675
|
+
if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
|
|
676
|
+
const result = {};
|
|
677
|
+
for (const [k, v] of Object.entries(value)) {
|
|
678
|
+
if (v === void 0) continue;
|
|
679
|
+
result[k] = deepStripUndefined(v);
|
|
680
|
+
}
|
|
681
|
+
return result;
|
|
682
|
+
}
|
|
683
|
+
return value;
|
|
684
|
+
}
|
|
671
685
|
function createUnsignedComment({
|
|
672
686
|
content,
|
|
673
687
|
docId,
|
|
@@ -724,7 +738,8 @@ async function createCommentBlob({
|
|
|
724
738
|
rootReplyCommentVersion,
|
|
725
739
|
visibility
|
|
726
740
|
});
|
|
727
|
-
const
|
|
741
|
+
const cleanedUnsignedComment = deepStripUndefined(unsignedComment);
|
|
742
|
+
const signedComment = await createSignedComment(cleanedUnsignedComment, signer);
|
|
728
743
|
return cborEncode6(signedComment);
|
|
729
744
|
}
|
|
730
745
|
function generateBlockId(length = 8) {
|
|
@@ -809,8 +824,9 @@ async function deleteComment(input, signer) {
|
|
|
809
824
|
sig: new Uint8Array(64)
|
|
810
825
|
};
|
|
811
826
|
if (input.visibility) tombstone.visibility = input.visibility;
|
|
812
|
-
|
|
813
|
-
|
|
827
|
+
const cleanedTombstone = deepStripUndefined(tombstone);
|
|
828
|
+
cleanedTombstone.sig = await signObject(signer, cleanedTombstone);
|
|
829
|
+
const encoded = cborEncode6(cleanedTombstone);
|
|
814
830
|
return toPublishInput(encoded, []);
|
|
815
831
|
}
|
|
816
832
|
async function updateComment(input, signer) {
|
|
@@ -836,8 +852,9 @@ async function updateComment(input, signer) {
|
|
|
836
852
|
if (input.replyParentVersion) comment.replyParent = CID3.parse(input.replyParentVersion);
|
|
837
853
|
if (input.rootReplyCommentVersion) comment.threadRoot = CID3.parse(input.rootReplyCommentVersion);
|
|
838
854
|
if (input.visibility) comment.visibility = input.visibility;
|
|
839
|
-
|
|
840
|
-
|
|
855
|
+
const cleanedComment = deepStripUndefined(comment);
|
|
856
|
+
cleanedComment.sig = await signObject(signer, cleanedComment);
|
|
857
|
+
const encoded = cborEncode6(cleanedComment);
|
|
841
858
|
return toPublishInput(encoded, []);
|
|
842
859
|
}
|
|
843
860
|
async function commentRecordIdFromBlob(blobData) {
|