@@ -839,7 +839,8 @@ export async function updateDbFromEthTransaction(txId: string) {
839
839
}
840
840
841
841
export async function storeOffchainAttestation ( pkg : AttestationShareablePackageObject ) {
842
- console . log ( "Storing offchain attestation" , pkg ) ;
842
+ const sanitizedPkg = JSON . stringify ( pkg ) . replace ( / [ \n \r ] / g, "" ) ;
843
+ console . log ( "Storing offchain attestation" , sanitizedPkg ) ;
843
844
844
845
const config : OffchainConfig = {
845
846
address : pkg . sig . domain . verifyingContract ,
@@ -851,12 +852,14 @@ export async function updateDbFromEthTransaction(txId: string) {
851
852
const isValidAttestation = offchain . verifyOffchainAttestationSignature ( pkg . signer , pkg . sig ) ;
852
853
853
854
if ( ! isValidAttestation ) {
854
- console . log ( "Invalid offchain attestation signature" , pkg . sig ) ;
855
+ const sanitizedSig = JSON . stringify ( pkg . sig ) . replace ( / \n | \r / g, "" ) ;
856
+ console . log ( "Invalid offchain attestation signature" , sanitizedSig ) ;
855
857
throw new Error ( "Invalid offchain attestation signature" ) ;
856
858
}
857
859
858
- if ( pkg . sig . message . time < dayjs ( ) . startOf ( "day" ) . unix ( ) ) {
859
- console . log ( "Offchain attestation is too old" , pkg . sig . message . time ) ;
860
+ const sanitizedTime = String ( pkg . sig . message . time ) . replace ( / \n | \r / g, "" ) ;
861
+ if ( Number ( sanitizedTime ) < dayjs ( ) . startOf ( "day" ) . unix ( ) ) {
862
+ console . log ( "Offchain attestation is too old" , sanitizedTime ) ;
860
863
throw new Error ( "Offchain attestation is too old" ) ;
861
864
}
862
865
0 commit comments