mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-05-30 18:56:36 +00:00
chore: Simplify error checking.
This commit is contained in:
parent
7fafda8416
commit
4e5b6bb597
@ -33,12 +33,12 @@ const hashStringEncoding = base58btc
|
||||
* @instance
|
||||
*/
|
||||
const Identity = async ({ id, publicKey, signatures, type, sign, verify } = {}) => {
|
||||
if (id == null) throw new Error('Identity id is required')
|
||||
if (publicKey == null) throw new Error('Invalid public key')
|
||||
if (signatures == null) throw new Error('Signatures object is required')
|
||||
if (signatures.id == null) throw new Error('Signature of id is required')
|
||||
if (signatures.publicKey == null) throw new Error('Signature of publicKey+id is required')
|
||||
if (type == null) throw new Error('Identity type is required')
|
||||
if (!id) throw new Error('Identity id is required')
|
||||
if (!publicKey) throw new Error('Invalid public key')
|
||||
if (!signatures) throw new Error('Signatures object is required')
|
||||
if (!signatures.id) throw new Error('Signature of id is required')
|
||||
if (!signatures.publicKey) throw new Error('Signature of publicKey+id is required')
|
||||
if (!type) throw new Error('Identity type is required')
|
||||
|
||||
signatures = Object.assign({}, signatures)
|
||||
|
||||
@ -90,14 +90,14 @@ const decodeIdentity = async (bytes) => {
|
||||
* @static
|
||||
*/
|
||||
const isIdentity = (identity) => {
|
||||
return identity.id != null &&
|
||||
identity.hash != null &&
|
||||
identity.bytes != null &&
|
||||
identity.publicKey != null &&
|
||||
identity.signatures != null &&
|
||||
identity.signatures.id != null &&
|
||||
identity.signatures.publicKey != null &&
|
||||
identity.type != null
|
||||
return Boolean(identity.id &&
|
||||
identity.hash &&
|
||||
identity.bytes &&
|
||||
identity.publicKey &&
|
||||
identity.signatures &&
|
||||
identity.signatures.id &&
|
||||
identity.signatures.publicKey &&
|
||||
identity.type)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user