( commit: CommitPreSigned | Commit, )
| 116 | * https://docs.atomicdata.dev/core/json-ad.html#canonicalized-json-ad |
| 117 | */ |
| 118 | export function serializeDeterministically( |
| 119 | commit: CommitPreSigned | Commit, |
| 120 | ): string { |
| 121 | // Remove empty arrays, objects, false values from root |
| 122 | if (commit.remove?.length == 0) { |
| 123 | delete commit.remove; |
| 124 | } |
| 125 | if (commit.set?.length == 0) { |
| 126 | delete commit.remove; |
| 127 | } |
| 128 | if (commit.destroy == false) { |
| 129 | delete commit.destroy; |
| 130 | } |
| 131 | replaceKey(commit, 'createdAt', urls.properties.commit.createdAt); |
| 132 | replaceKey(commit, 'subject', urls.properties.commit.subject); |
| 133 | replaceKey(commit, 'set', urls.properties.commit.set); |
| 134 | replaceKey(commit, 'signer', urls.properties.commit.signer); |
| 135 | replaceKey(commit, 'signature', urls.properties.commit.signature); |
| 136 | replaceKey(commit, 'remove', urls.properties.commit.remove); |
| 137 | replaceKey(commit, 'destroy', urls.properties.commit.destroy); |
| 138 | commit[urls.properties.isA] = [urls.classes.commit]; |
| 139 | return stringify(commit); |
| 140 | } |
| 141 | |
| 142 | /** Creates a signature for a Commit using the private Key of some Agent. */ |
| 143 | export const signAt = async ( |
no test coverage detected