diff --git a/docs/docs/guide/usingFreighterWebApp.md b/docs/docs/guide/usingFreighterWebApp.md index c0aaf543eb..d07ad57e83 100644 --- a/docs/docs/guide/usingFreighterWebApp.md +++ b/docs/docs/guide/usingFreighterWebApp.md @@ -200,9 +200,9 @@ The second parameter is an optional `opts` object where you can specify which ac ### signMessage -#### `signMessage(message: string, opts: { address: string }) -> >` +#### `signMessage(message: string, opts: { address: string }) -> >` -This function accepts a string as the first parameter, which it will decode, sign as the user, and return a Buffer of the signed contents. +This function accepts a string as the first parameter, which it will decode, sign as the user, and return a base64 encoded string of the signed contents. The second parameter is an optional `opts` object where you can specify which account's signature you’re requesting. If Freighter has the public key requested, it will switch to that account. If not, it will alert the user that they do not have the requested account. diff --git a/docs/docs/playground/signMessage.mdx b/docs/docs/playground/signMessage.mdx index fe0e311969..fd4b803c82 100644 --- a/docs/docs/playground/signMessage.mdx +++ b/docs/docs/playground/signMessage.mdx @@ -3,9 +3,17 @@ id: signMessage title: signMessage --- -#### `signMessage(message: string, opts: { address: string }) -> >` +#### `signMessage(message: string, opts: { address: string }) -> >` import { SignMessageDemo } from "./components/SignMessageDemo"; +

The signed message from the response is a base64 encoded string of the signature. Verification Example:

+

+``` +const kp = +const res = await stellarApi.signMessage("hi", { networkPassphrase: SorobanClient.Networks.TESTNET }) +const passes = kp.verify(Buffer.from("hi", "base64"), Buffer.from(res.signedMessage, "base64")) // true +``` +

Test Freighter's `signMessage` method: diff --git a/extension/src/background/messageListener/freighterApiMessageListener.ts b/extension/src/background/messageListener/freighterApiMessageListener.ts index 471c059d44..9e71feec4c 100644 --- a/extension/src/background/messageListener/freighterApiMessageListener.ts +++ b/extension/src/background/messageListener/freighterApiMessageListener.ts @@ -341,7 +341,7 @@ export const freighterApiMessageListener = ( localStore.setItem(ALLOWLIST_ID, allowList.join()); } - if (semver.gte(apiVersion, "4.0.0")) { + if (apiVersion && semver.gte(apiVersion, "4.0.0")) { resolve({ signedBlob: Buffer.from(signedBlob).toString("base64"), signerAddress,