npm

@spruceid/zcap-providers
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

ZCAP Providers

@spruceid/zcap-providers leverages DIDKit to provide convenient integration for crypto-clients with ZCAP-LD. Integrations are provided for:

Usage

Import the required dependancies:

import * as didkit from '@spruceid/didkit-wasm-node';
import { tz, didkey, genJWK } from '@spruceid/zcap-providers';
import { BeaconWallet } from '@taquito/beacon-wallet';

Connect to the User's Beacon Wallet and use it to create a Capabilities agent:

const wallet = new BeaconWallet(_);
await wallet.requestPermissions(_);
const walletCaps = await tz(wallet.client, didkit);

Create a client key and capabilities:

const clientKey = genJWK();
const clientCaps = await didkey(clientKey, didkit);

Use the User's wallet to delegate a READ capability to the client:

const delegation = await walletCaps.delegate({
    capabilityAction: 'READ',
    invoker: clientCaps.id()
}, []);

Use the client to invoke the READ capability:

const invocation = await clientCaps.invoke({
    capabilityAction: 'READ'
}, delegation.id())

Readme

Keywords

none

Package Sidebar

Install

npm i @spruceid/zcap-providers

Weekly Downloads

2

Version

0.1.1

License

Apache-2.0

Unpacked Size

30 kB

Total Files

15

Last publish

Collaborators

  • obstropolos
  • jszersze
  • skgbafa
  • chunningham
  • wycjs
  • sbihel
  • w4ll3
  • xtheosirian