Browse Source

Version 0.2.0

master v0.2.0
Ezerous 3 years ago
parent
commit
f5355b3138
  1. 2
      package.json
  2. 9
      src/ΕthereumContractIdentityProvider.js
  3. 9
      src/ΕthereumIdentityProvider.js

2
package.json

@ -1,6 +1,6 @@
{
"name": "@ecentrics/eth-identity-provider",
"version": "0.1.3",
"version": "0.2.0",
"description": "An Ethereum orbit-db-identity-provider.",
"license": "MIT",
"author": "Ezerous <ezerous@gmail.com>",

9
src/ΕthereumContractIdentityProvider.js

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

9
src/ΕthereumIdentityProvider.js

@ -43,7 +43,7 @@ class EthereumIdentityProvider extends IdentityProvider {
// Data to be signed is identity.publicKey + identity.signatures.id
async signIdentity(data) {
if (process.env.NODE_ENV === 'development') { // Don't sign repeatedly while in development
if (EthereumIdentityProvider.storeAuthDataLocally) {
console.debug(`${LOGGING_PREFIX}Attempting to find stored Orbit identity data...`);
const signaturePubKey = await getIdentitySignaturePubKey(data);
if (signaturePubKey) {
@ -66,7 +66,7 @@ class EthereumIdentityProvider extends IdentityProvider {
async doSignIdentity(data) {
try {
const signaturePubKey = await EthereumIdentityProvider.web3.eth.personal.sign(data, this.id, '');
if (process.env.NODE_ENV === 'development') {
if (EthereumIdentityProvider.storeAuthDataLocally) {
storeIdentitySignaturePubKey(data, signaturePubKey)
.then(() => {
console.debug(`${LOGGING_PREFIX}Successfully stored current Orbit identity data.`);
@ -100,6 +100,11 @@ class EthereumIdentityProvider extends IdentityProvider {
static setWeb3(web3) {
EthereumIdentityProvider.web3 = web3;
}
// Opt to store auth data locally to avoid repeating MetaMask signing prompts
static setStoreAuthDataLocally(storeAuthDataLocally) {
EthereumIdentityProvider.storeAuthDataLocally = storeAuthDataLocally;
}
}
EthereumIdentityProvider.web3 = {};

Loading…
Cancel
Save