0.1.1 • Published 3 years ago
@spruceid/zcap-providers v0.1.1
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())