|
@ -51,7 +51,7 @@ class EthereumContractIdentityProvider extends IdentityProvider { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async signIdentity(data) { |
|
|
async signIdentity(data) { |
|
|
if (process.env.NODE_ENV === 'development') { // Don't sign repeatedly while in development
|
|
|
if (EthereumContractIdentityProvider.storeAuthDataLocally) { |
|
|
console.debug(`${LOGGING_PREFIX}Attempting to find stored Orbit identity data...`); |
|
|
console.debug(`${LOGGING_PREFIX}Attempting to find stored Orbit identity data...`); |
|
|
const signaturePubKey = await getIdentitySignaturePubKey(data); |
|
|
const signaturePubKey = await getIdentitySignaturePubKey(data); |
|
|
if (signaturePubKey) { |
|
|
if (signaturePubKey) { |
|
@ -74,7 +74,7 @@ class EthereumContractIdentityProvider extends IdentityProvider { |
|
|
async doSignIdentity(data) { |
|
|
async doSignIdentity(data) { |
|
|
try { |
|
|
try { |
|
|
const signaturePubKey = await EthereumContractIdentityProvider.web3.eth.personal.sign(data, this.userAddress, ''); |
|
|
const signaturePubKey = await EthereumContractIdentityProvider.web3.eth.personal.sign(data, this.userAddress, ''); |
|
|
if (process.env.NODE_ENV === 'development') { |
|
|
if (EthereumContractIdentityProvider.storeAuthDataLocally) { |
|
|
storeIdentitySignaturePubKey(data, signaturePubKey) |
|
|
storeIdentitySignaturePubKey(data, signaturePubKey) |
|
|
.then(() => { |
|
|
.then(() => { |
|
|
console.debug(`${LOGGING_PREFIX}Successfully stored current Orbit identity data.`); |
|
|
console.debug(`${LOGGING_PREFIX}Successfully stored current Orbit identity data.`); |
|
@ -116,6 +116,11 @@ class EthereumContractIdentityProvider extends IdentityProvider { |
|
|
EthereumContractIdentityProvider.contractAddress = contractAddress; |
|
|
EthereumContractIdentityProvider.contractAddress = contractAddress; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Opt to store auth data locally to avoid repeating MetaMask signing prompts
|
|
|
|
|
|
static setStoreAuthDataLocally(storeAuthDataLocally) { |
|
|
|
|
|
EthereumContractIdentityProvider.storeAuthDataLocally = storeAuthDataLocally; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static splitId(id) { |
|
|
static splitId(id) { |
|
|
const regex = /(0x.*)(0x.*)/g; |
|
|
const regex = /(0x.*)(0x.*)/g; |
|
|
const match = regex.exec(id); |
|
|
const match = regex.exec(id); |
|
|