From d5958cbf6b1395cf3f10648952aa185aa0e35822 Mon Sep 17 00:00:00 2001 From: Jan Dvorak Date: Tue, 10 May 2022 10:56:28 +0200 Subject: [PATCH] Add message for signing in web3 & documentation for it --- README.md | 3 +++ community-services/web3.js | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7378a9c..9d6c91e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ You will call this on the page where you allow your users to connect to other se `options` is expecting configuration object. Most often that is going to be: `{ loginStyle: 'popup' }` +##### `freedombase:web3-login` +The `options` object accepts `linkMessage` key where you can set message for signature. + ### Server side #### Accounts.unlinkService(userId, serviceName) Given the `userId` and the name of the service (`serviceName`) as it is named in the user document (most often lower case name of the service). diff --git a/community-services/web3.js b/community-services/web3.js index 251cd9b..ee0ff24 100644 --- a/community-services/web3.js +++ b/community-services/web3.js @@ -1,5 +1,10 @@ import { Meteor } from 'meteor/meteor' +/** + * + * @param options.linkMessage { String } Message to display on wallet confirmation + * @param callback { Function } + */ Meteor.linkWithWeb3 = function (options, callback) { if (!Meteor.userId()) { throw new Meteor.Error( @@ -22,12 +27,14 @@ Meteor.linkWithWeb3 = function (options, callback) { // Since the flow for Web3 is different we are using a custom flow here. const credentialRequestCompleteCallback = (error, address) => { if (error.error === 403) { - Meteor.call('bozhao:linkAccountsWeb3', address, callback) + Meteor.call('bozhao:linkAccountsWeb3', address) } else { throw error } } Package['freedombase:web3-login'].loginWithWeb3( + options?.linkMessage || + `Please verify that you want to link your wallet to ${Meteor.absoluteUrl()}.`, credentialRequestCompleteCallback ) }