1. Baidu Identity hub
Baidu Identity hub的域名是https://did.baidu.com/v1/identity-hub
2. hub 交互接口
Identity hub 的接口比较特殊,并非 Restful API 形式,所有的请求都是以加密形式发送到统一接口,Identity hub 解密请求内容后根据具体的信息来判断是请求什么接口操作,进而进行处理。例如发送一个查询 Object 的请求ObjectQueryRequest
,具有如下的形式:
请求结构
POST /v1/identity-hub HTTP/1.1
Host: did.baidu.com
Content-Type: application/json
{
"data": "..."
}
请求参数
参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
---|---|---|---|---|
data | String | 是 | RequestBody | 加密后的请求的具体内容,JWE 格式 |
返回参数
参数名称 | 类型 | 描述 |
---|---|---|
data | String | 加密后的响应内容,JWE 格式 |
请求示例
POST /v1/identity-hub HTTP/1.1
Host: did.baidu.com
Content-Type: application/json
{
"data": "eyJraWQiOiJkaWQ6Y2NwOjRYRjhCM0tTN05CcDNLaHFqWlp5QlJvdzJwVXUja2V5cy0xIiwiYWxnIjoiRVMyNTZLIiwiZW5jIjoiQTEyOEdDTSJ9.BEazNqcDYcXMMUGP-1pDGSnfxYpVs40Cnabp7C_uruHuoNZWZ35y-QBMgtbbGPjdoU4vTxeCGJaK2Tn1qK_Y0Jt3xC2OuErZLZdMUHPrQnV5Z6PFW0nHYL8RYkDe_h3LpEjHm8Ku01AiHJ8qY0rogHQt27NDMe1TTwA1V2y8U57ld45GAfmTF677UJmg-n3gnA.y61K4ySWww7tfGQO.udG3JRienGN0_AYSMHOqTrrOiwlDHDr0eiIxjCe0AysC-fv1GCisSeUBue4tOqtj9UsHbbGGay7fKgFICeUbyAvxU_IUhecQYXy6dlK7RtvwGK-eUdiyUkYCoPKdQdwx5ePj-YUGYh0X_AIagWiU9FhUPNS1h8vMkp-fDS_H7tRu72K8iyTg9WPpaEIx-1mxAft5ntFDo9D9W9PinFEjO92Q2h1G5JtVGe7X4qU1hZMD7uSrnUj9fQLWGapGDBCk4TCmhC_QqAzpat4O532xd_njejGLEeNrgO3hvxEu6z7_m4Zr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lLnsGQv6J7dHrjVE1GuhpGQFQIOAyOLBF0_Tc3o-9EmdNajBk8PaThTwiNPN0lks9ykC7f2UZFqBruu2gjoCOoEyNwMESelU-AxQpf-mt3MReLQRfYTgKQB_bQkgXS6wioHdo4SNrfjiwA6m6Ou8fb587myCQ0dBJ3n8tM7I0BUFyPq8sOFji3kLAf5uM3w.NpEcw2G3o15xq5E2eb-TEQ"
}
解密后的响应内容为:
{"@context":"https://schema.identity.foundation/0.1","@type":"ObjectQueryResponse","objects":[],"skip_token":null}
Identity hub 的交互采用 jose 认证,加密封装等过程比较麻烦,所以建议使用 js-sdk进行交互。
3. 获取 hub did
Identity hub 提供一个公开的接口,用于查询 hub did,该请求不需要 jose 认证,可用于检测 hub 的有效性。
请求结构
GET /v1/identity-hub HTTP/1.1
Host: did.baidu.com
响应示例
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
did:ccp:4XF8B3KS7NBp3KhqjZZyBRow2pUu