Skip to content

Commit

Permalink
fix: update consent proof text
Browse files Browse the repository at this point in the history
updated to package for creating consent proof
  • Loading branch information
Alex Risch authored and Alex Risch committed May 6, 2024
1 parent 9096006 commit 155c719
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
},
"dependencies": {
"@noble/secp256k1": "1.7.1",
"@xmtp/consent-proof-signature": "^0.1.2",
"@xmtp/proto": "3.54.0",
"@xmtp/user-preferences-bindings-wasm": "^0.3.6",
"async-mutex": "^0.5.0",
Expand Down
8 changes: 3 additions & 5 deletions src/Contacts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createConsentMessage } from '@xmtp/consent-proof-signature'
import { privatePreferences, type invitation } from '@xmtp/proto'
import { hashMessage, hexToBytes } from 'viem'
import { ecdsaSignerKey, WalletSigner } from '@/crypto/Signature'
import { ecdsaSignerKey } from '@/crypto/Signature'
import { splitSignature } from '@/crypto/utils'
import type { EnvelopeWithMessage } from '@/utils/async'
import { fromNanoString } from '@/utils/date'
Expand Down Expand Up @@ -275,10 +276,7 @@ export class Contacts {
return false
}
const signatureData = splitSignature(signature as `0x${string}`)
const message = WalletSigner.consentProofRequestText(
peerAddress,
timestampMs
)
const message = createConsentMessage(peerAddress, timestampMs)
const digest = hexToBytes(hashMessage(message))
// Recover public key
const publicKey = ecdsaSignerKey(digest, signatureData)
Expand Down
14 changes: 0 additions & 14 deletions src/crypto/Signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,6 @@ export class WalletSigner implements KeySigner {
)
}

static consentProofRequestText(
peerAddress: string,
timestampMs: number
): string {
return (
'XMTP : Grant inbox consent to sender\n' +
'\n' +
`Current Time: ${new Date(timestampMs).toUTCString()}\n` +
`From Address: ${peerAddress}\n` +
'\n' +
'For more info: https://xmtp.org/signatures/'
)
}

static signerKey(
key: SignedPublicKey,
signature: ECDSACompactWithRecovery
Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,16 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/consent-proof-signature@npm:^0.1.2":
version: 0.1.2
resolution: "@xmtp/consent-proof-signature@npm:0.1.2"
dependencies:
"@xmtp/proto": "npm:3.56.0"
long: "npm:^5.2.3"
checksum: 10/d7701a98c72b5ca985dbeb5f676a7475e9db25fa5e7b560885d32740d3cc5821249252e5832e758b2dc45fee2794ff47b8d1d972dff3da9d6bc2720fd5537c3c
languageName: node
linkType: hard

"@xmtp/proto@npm:3.54.0":
version: 3.54.0
resolution: "@xmtp/proto@npm:3.54.0"
Expand All @@ -3166,6 +3176,18 @@ __metadata:
languageName: node
linkType: hard

"@xmtp/proto@npm:3.56.0":
version: 3.56.0
resolution: "@xmtp/proto@npm:3.56.0"
dependencies:
long: "npm:^5.2.0"
protobufjs: "npm:^7.0.0"
rxjs: "npm:^7.8.0"
undici: "npm:^5.8.1"
checksum: 10/f752e6858692464319d6f22861fe8f23c46d9bb0eb390fe2220e0b4932a4de84be2e9e1cbafc0200e1bfe2a0ed3a3fb6079941630e57fb80e6325bc2a52bf10d
languageName: node
linkType: hard

"@xmtp/rollup-plugin-resolve-extensions@npm:1.0.1":
version: 1.0.1
resolution: "@xmtp/rollup-plugin-resolve-extensions@npm:1.0.1"
Expand Down Expand Up @@ -3206,6 +3228,7 @@ __metadata:
"@typescript-eslint/eslint-plugin": "npm:^7.2.0"
"@typescript-eslint/parser": "npm:^7.2.0"
"@vitest/coverage-v8": "npm:^1.3.1"
"@xmtp/consent-proof-signature": "npm:^0.1.2"
"@xmtp/proto": "npm:3.54.0"
"@xmtp/rollup-plugin-resolve-extensions": "npm:1.0.1"
"@xmtp/user-preferences-bindings-wasm": "npm:^0.3.6"
Expand Down

0 comments on commit 155c719

Please sign in to comment.