Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
Signed-off-by: Shruti3004 <mail2shruti.ag@gmail.com>
  • Loading branch information
Shruti3004 committed Sep 23, 2023
1 parent d6285cd commit 0318772
Showing 1 changed file with 67 additions and 11 deletions.
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,77 @@
# Digilocker-SDK
# Digilocker Package πŸ“

## Current List of APIs
## Overview πŸš€

1. Login
2. Get Documents
3. Upload Documents (WIP)
4. eSign (WIP)
The Digilocker Package is a library that simplifies the integration of the Digilocker API into your applications. Digilocker is a platform that allows users to store, access, and share their documents digitally.

## Usage
## Installation πŸ“¦

### Frontend
You can install the Digilocker Package via npm:

### Backend
```bash
npm install digilocker-sdk
```

### Type Definitions
## Usage 🧰

See all the types [here](./src/types.ts)
1. Initialize Digilocker πŸ› οΈ
To start using the Digilocker functions, you need to create an instance of the Digilocker class and provide the necessary configuration. Here's how to initialize the Digilocker instance:

```js
import {
Digilocker,
Config,
DigiLockerFunctions,
} from 'your-digilocker-package-name';

// Configure Digilocker βš™οΈ
const digilockerConfig: Config = {
clientId: 'yourClientId',
clientSecret: 'yourClientSecret',
callbackURL: 'yourCallbackURL',
};

// Create an instance of Digilocker πŸš€
const digilockerInstance: Digilocker = new DigiLockerFunctions(
digilockerConfig
);
```

2. Generate Login URL 🌐
You can generate a login URL that users can click to initiate the Digilocker login process:

```js
const loginUrl = digilockerInstance.generateLoginUrl();
// Use this loginUrl in your application to redirect users to the Digilocker login page.
```

3. Exchange Code for Access Token πŸ”‘
After the user logs in and you receive an authorization code, use the following function to exchange the code for an access token:

```js
const authorizationCode = 'codeReceivedFromDigilocker'; // Replace with the actual code
await digilockerInstance.exchangeCodeForToken(authorizationCode);
// The access token is now available in the digilockerInstance.accessToken property.
```

4. Fetch Issued Files πŸ“‚

```js
try {
const issuedFiles = await digilockerInstance.fetchIssuedFiles();
console.log('Issued Files:', issuedFiles);
} catch (error) {
console.error('Error fetching issued files:', error);
}
```

## Error Handling ❌

Make sure to handle errors and user interactions appropriately in your application based on your specific requirements.

## License πŸ“œ

This project is licensed under the MIT License - see the LICENSE.md file for details.

## References

Expand Down

0 comments on commit 0318772

Please sign in to comment.