Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

@arcblock/did-agent-storage-mongo

1.0.13 • Public • Published

@arcblock/did-agent-storage-mongo

styled with prettier

Storage engine that uses mongo to store data, implements interfaces defined in @arcblock/did-auth-storage.

Table of Contents

Install

npm install @arcblock/did-agent-storage-mongo
// or
yarn add @arcblock/did-agent-storage-mongo

Usage

const MongoStorage = require('@arcblock/did-agent-storage-mongo');
 
const storage = new MongoStorage({
  url: 'mongodb://localhost/forge-web-starter',
  collection: 'app-agent-authorizations',
});
 
(async () => {
  const agent = fromRandom(type);
  const authorizer = fromRandom(type);
  const authorizeId = authorizer.toAddress();
 
  const authorization = Jwt.sign(authorizeId, authorizer.secretKey, {
    sub: agent.toAddress(),
    ops: {
      profile: ['fullName', 'mobilePhone', 'mailingAddress'],
    },
  });
 
  const [, content, sig] = authorization.split('.');
  const item = await storage.create(authorizeId, {
    ownerDid: user.toAddress(),
    agentDid: agent.toAddress(),
    appDid: authorizeId,
    appPk: authorizer.publicKey,
    appName: 'ABT Wallet Demo',
    appDescription: 'Demo application to show the potential of ABT Wallet',
    appIcon: 'https://arcblock.oss-cn-beijing.aliyuncs.com/images/wallet-round.png',
    certificateContent: content,
    certificateSignature: sig,
  });
})();

Contributors

Name Website
wangshijun https://ocap.arcblock.io

Install

npm i @arcblock/did-agent-storage-mongo

DownloadsWeekly Downloads

2

Version

1.0.13

License

Apache-2.0

Unpacked Size

11.4 kB

Total Files

5

Last publish

Collaborators

  • avatar
  • avatar