@arcblock/app-agent-storage
v0.40.9
Published
Storage interface for delegated did-auth between application and wallet
Downloads
5
Readme
@arcblock/app-agent-storage
Interface for define a storage class that can be used by [@arcblock/did-auth].
Table of Contents
Motivation & Spec
Fields
Possible fields to exist in a did-agent storage record
authorizeId
: Primary keyownerDid
: Owner DIDagentDid
: Agent DIDappDid
: Application DIDappPk
: Application public keyappName
: Application nameappDescription
: Application descriptionappLogo
: Application logocertificate
: Application authorize certificate
APIs
Basic APIs that a did-agent storage should support:
create(authorizeId, payload)
: 创建记录update(authorizeId, updates)
: 更新记录read(authorizeId)
:按 authorizeId 查询delete(authorizeId)
:删除记录listByApp(appDid)
: 按应用查询listByOwner(ownerDid)
: 按所有者查询
Install
npm install @arcblock/app-agent-storage
// or
yarn add @arcblock/app-agent-storage
Usage
const StorageInterface = require('@arcblock/app-agent-storage');
module.exports = class KeystoneStorage extends StorageInterface {
constructor() {
this.model = keystone.list('LoginToken').model;
}
create(token, status = 'created') {
const LoginToken = this.model;
const item = new LoginToken({ token, status });
return item.save();
}
read(token) {
return this.model.findOne({ token });
}
update(token, updates) {
return this.model.findOneAndUpdate({ token }, updates);
}
delete(token) {
return this.model.remove({ token });
}
exist(token, did) {
return this.model.findOne({ token, did });
}
};
Contributors
| Name | Website | | -------------- | -------------------------- | | wangshijun | https://ocap.arcblock.io |