3ID 解析器
此库旨在解析 3IDDD 文档 。 3ID是一种稀薄的身份协议,使用ipfs和etheum来发布和旋转身份所使用的密码密钥.
它支持拟议的 分散式标识符 从 W3C 证书社区小组。 。 。 .
它要求 did-resolver 库,是解析 DIDs 的主要接口.
解析已执行的文档
将 IPFS 实例传递给 getResolver() 函数。 使用返回的解析器必须传递给 did-resolver 例如:
import { Resolver } from 'did-resolver'
import { getResolver } from '3id-resolver'
const threeIdResolver = getResolver(ipfs)
const resolver = new Resolver(threeIdResolver)
resolver.resolve('did:3:QmRhjfL4HLdB8LovGf1o43NJ8QnbfqmpdnTuBvZTewnuBV').then(doc => console.log)
// You can also use ES7 async/await syntax
const doc = await resolver.resolve('did:muport:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf')
见 已解析文件 用于更一般的使用信息 .
结果 :
{
'@context': 'https://w3id.org/did/v1',
id: 'did:3:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf',
publicKeys: [ {
id: 'did:3:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf#signingKey',
type: 'Secp256k1VerificationKey2018',
publicKeyHex: '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'
}, {
id: 'did:3:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf#encryptionKey',
type: 'Curve25519EncryptionPublicKey',
publicKeyBase64: 'fake encryptionKey'
}, {
id: 'did:3:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf#managementKey',
type: 'Secp256k1VerificationKey2018',
ethereumAddress: 'fake eth addr'
}],
authentication: [{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: 'did:3:zdpuAt4qH8ur3vHpVrP1xb7rtJuyVUVbRiGatkkVcJZRgAXDf#signingKey'
}]
}