diff --git a/package.json b/package.json index f678a50c..4b3c43aa 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Contacts.ts b/src/Contacts.ts index 74b0f314..73af6b94 100644 --- a/src/Contacts.ts +++ b/src/Contacts.ts @@ -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' @@ -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) diff --git a/src/crypto/Signature.ts b/src/crypto/Signature.ts index 0e9c07ab..f83601df 100644 --- a/src/crypto/Signature.ts +++ b/src/crypto/Signature.ts @@ -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 diff --git a/yarn.lock b/yarn.lock index a272794b..3b072be1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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"