open-index/open-npm huggingface dataset:
npm package: @spruceid/zcap-providers
Description: `@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
Latest version: 0.1.1

# ZCAP Providers

`@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](https://github.com/MetaMask/providers))
- Tezos DApps (via the [BeaconSDK](https://github.com/airgap-it/beacon-sdk))
- JWKs (via [`did:key`](https://w3c-ccg.github.io/did-method-key/))

## Usage

Import the required dependancies:

``` typescript
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:

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

Create a client key and capabilities:

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

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

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

Use the client to invoke the `READ` capability:

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