@spruceid/zcap-providers
v0.1.1
Published
`@spruceid/zcap-providers` leverages [DIDKit](https://github.com/spruceid/didkit) to provide convenient integration for crypto-clients with [ZCAP-LD](https://w3c-ccg.github.io/zcap-ld/). Integrations are provided for: - Ethereum DApps (via [Metamask](http
Downloads
1
Keywords
Readme
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())