Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (privateKey) {
this.signer = SimpleSigner(privateKey)
}
if (did) {
this.did = did
} else if (address) {
if (isMNID(address)) {
this.did = `did:uport:${address}`
}
if (address.match('^0x[0-9a-fA-F]{40}$')) {
this.did = `did:ethr:${address}`
}
} else if (privateKey) {
const kp = secp256k1.keyFromPrivate(privateKey)
const address = toEthereumAddress(kp.getPublic('hex'))
this.did = `did:ethr:${address}`
}
this.signJWT = (payload, expiresIn) =>
createJWT(payload, {
issuer: this.did,
signer: this.signer,
alg: this.did.match('^did:uport:') || isMNID(this.did) ? 'ES256K' : 'ES256K-R',
expiresIn,
})
UportDIDResolver(registry || UportLite({ networks: networks ? configNetworks(networks) : {} }))
EthrDIDResolver(ethrConfig || {})
HttpsDIDResolver()
}
static createIdentity() {
const kp = secp256k1.genKeyPair()
const publicKey = kp.getPublic('hex')
const privateKey = kp.getPrivate('hex')
const address = toEthereumAddress(publicKey)
const did = `did:ethr:${address}`
return { did, privateKey }
}