( commitBuilder: CommitBuilderI, /** Subject URL of the Agent signing the Commit */ agent: string, /** Base64 serialized private key matching the public key of the agent */ privateKey: string, /** Time of signing in millisecons since unix epoch */ createdAt: number, )
| 141 | |
| 142 | /** Creates a signature for a Commit using the private Key of some Agent. */ |
| 143 | export const signAt = async ( |
| 144 | commitBuilder: CommitBuilderI, |
| 145 | /** Subject URL of the Agent signing the Commit */ |
| 146 | agent: string, |
| 147 | /** Base64 serialized private key matching the public key of the agent */ |
| 148 | privateKey: string, |
| 149 | /** Time of signing in millisecons since unix epoch */ |
| 150 | createdAt: number, |
| 151 | ): Promise<Commit> => { |
| 152 | if (agent == undefined) { |
| 153 | throw new Error('No agent passed to sign commit'); |
| 154 | } |
| 155 | const commitPreSigned: CommitPreSigned = { |
| 156 | ...commitBuilder, |
| 157 | createdAt, |
| 158 | signer: agent, |
| 159 | }; |
| 160 | const serializedCommit = serializeDeterministically(commitPreSigned); |
| 161 | const signature = await signToBase64(serializedCommit, privateKey); |
| 162 | const commitPostSigned: Commit = { |
| 163 | ...commitPreSigned, |
| 164 | signature, |
| 165 | }; |
| 166 | return commitPostSigned; |
| 167 | }; |
| 168 | |
| 169 | // /** Checks whether the commit signature is correct */ |
| 170 | // function verifyCommit(commit: Commit, publicKey: string): boolean { |
no test coverage detected