@atproto/lexicon-resolver (英语)
ATProto Lexicon 分辨率
使用量
这个软件包可用于根据其NSID确定一个Lexicon的DD权威,并根据其NSID解决一个Lexicon 语法解析度 从网络。 决议总是核查向ATProto网络发布的Lexicon schema文件的包含证明.
import {
resolveLexicon,
resolveLexiconDidAuthority,
} from '@atproto/lexicon-resolver'
// Which DID is the authority over this Lexicon?
const didAuthority = await resolveLexiconDidAuthority('app.bsky.feed.post')
// Resolve the Lexicon document with resolution details
const resolved = await resolveLexicon('app.bsky.feed.post')
/**
* {
* commit: {
* did: 'did:plc:4v4y5r3lwsbtmsxhile2ljac',
* rev: '3lnlpukgipj2c',
* sig: Uint8Array(64),
* ...
* },
* uri: AtUri(at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.feed.post),
* cid: CID(bafyreidgbehqwweghrrddfu6jgj7lyr6fwhzgazhirnszdb5lvr7iynkiy),
* nsid: NSID('app.bsky.feed.post'),
* lexicon: {
* '$type': 'com.atproto.lexicon.schema',
* lexicon: 1
* id: 'app.bsky.feed.post',
* defs: { main: [Object], ... },
* }
* }
*/
有身份隐形
身份数据用于获取和核实记录内容。 @atproto/dentity 套件可以用来对缓存和身份检查的其他行为提供更多的控制.
import { IdResolver, MemoryCache } from '@atproto/identity'
import { buildLexiconResolver } from '@atproto/lexicon-resolver'
const resolveLexicon = buildLexiconResolver({
idResolver: new IdResolver({
didCache: new MemoryCache(),
}),
})
const resolved = await resolveLexicon('app.bsky.feed.post')
以 DOD 权限覆盖
您可以指定一个特定的权限, 用于执行 Lexicon 解析, 压倒 ATProto 基于 DNS 的对 Lexicon 的权限。 详情见以下各节 权力和控制。 。 。 .
import { resolveLexicon } from '@atproto/lexicon-resolver'
const resolved = await resolveLexicon('app.bsky.feed.post', {
didAuthority: 'did:plc:...',
})
许可证
根据麻省理工学院和Apache 2.0条款,这个项目具有双重许可证:
- 麻省理工学院许可证LICENSE-MIT.txt (英语) 或者说 http://opensource.org/licenses/MIT 互联网档案馆的存檔,存档日期2013-12-02(中文(简体) )
- Apache 许可证,2.0版本, ((原始内容存档于2017-09-31) (英语). LICENSE-APACHE.txt 或者说 http://www.apache.org/licenses/LICENSE-2.0 (中文(简体) )(中文(简体) )
下游项目和终端用户可自行选择单独或共同发放许可证。 这种双重许可的动机是Apache 2.0提供的额外软件专利保证.