# Using The Provider

This snippet illustrates how to accomplish the APIs above, which includes:

* Request authorization from the User
* Get the User's DID Information
* Request kinds of Credential Disclosure from the User
* Ask the User to sign a message and return a signature
* ....

### **Install packages**

First, you need to install the following packages, you can install them with the command below.

* @zcloak/login-providers
* @zcloak/login-verify
* @zcloak/did-resolver

```bash
# use yarn
yarn add @zcloak/login-providers @zcloak/login-verify @zcloak/did-resolver

# use npm
npm install @zcloak/login-providers @zcloak/login-verify @zcloak/did-resolver
```

### **A Simple Example Of How To Use The Provider:**

```typescript
// import ZkidWalletProvider
import { ZkidWalletProvider } from "@zcloak/login-providers";
import { ArweaveDidResolver } from "@zcloak/did-resolver";

import {
  verifyCredentialContent,
  verifyCredentialDigest,
  verifyDidLogin>
  } from '@zcloak/login-verify';

// init zkid wallet provider, make sure zkid wallet is install
const provider = new ZkidWalletProvider();

// init zkid did resolver
const resolver = new ArweaveDidResolver({ server: "https://did-service.zkid.app" });

async function main() {
  // API for checking authorization status: can be used to check whether the User has permitted the authorization to this website. 
  const isAuth = await provider.isAuth();
  
  // API for request authorization: If the authorization has not been permitted yet, request authorization from the User
  await provider.requestAuth();
  
  // API for getting user DID: Get current DID of User from the zkID Wallet
  const currentDid = await provider.getCurrentDid();

  // Create a message to sign    
  const message = 'Test_String';
  
  const signature = await provider.sign(message);
  
  const verifyDidLoginResult = await verifyDidLogin(message, signature, resolver);
  
  
  const challenge = 'Some_Random_Challenge';
    
  // API for obtaining a credential Digest Disclosure from the User     
  const credentialDigest = await provider.requestCredentialDigest(challenge);
  
  const credentialDigestResult = await verifyCredentialDigest(credentialDigest, challenge, currentDid.didUri, resolver);
  
  // API for getting a credential Selective Disclosure from the User (e.g. disclose `name` and `age`)    
  const credential = await provider.requestCredentialContent(challenge, ['name', 'age']);
  
  const credentialContentResult = await verifyCredentialContent(credential, challenge, currentDid.didUri, resolver);
  
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zkid.app/api/using_the_provider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
