@civic/icp-gateway-react-ui
v0.0.3
Published
Civic Pass ICP React Component
Downloads
23
Maintainers
Keywords
Readme
ICP Civic Credential Check Button
This React component provides a button for checking and obtaining Civic Pass credentials on the Internet Computer Protocol (ICP) network.
Features
- Check for existing Civic Pass credentials
- Obtain new Civic Pass credentials if none exist
- Configurable for different environments (development/production)
- Customizable appearance using Emotion CSS
Installation
To use this component, you need to have the following dependencies installed:
npm install @civic/icp-gateway-react-ui
or
yarn add @civic/icp-gateway-react-ui
Usage
import React from 'react';
import { Principal } from '@dfinity/principal';
import ICPCredentialCheckButton from './ICPCredentialCheckButton';
const App = () => {
const principal = Principal.fromText('your-principal-id');
const gatekeeperNetwork = 'your-gatekeeper-network';
const handleCredentialCheck = (response, error) => {
if (error) {
console.error('Error checking credential:', error);
} else {
console.log('Credential check response:', response);
}
};
return (
<ICPCredentialCheckButton
principal={principal}
gatekeeperNetwork={gatekeeperNetwork}
onCredentialCheck={handleCredentialCheck}
/>
);
};
export default App;
Props
| Prop | Type | Description |
|------|------|-------------|
| principal
| Principal
| The user's ICP principal |
| gatekeeperNetwork
| string
| The Gatekeeper network for the Civic Pass |
| config
| Partial<Config>
| (Optional) Configuration options |
| onCredentialCheck
| (response?: CredentialCheckResponse, error?: Error) => void
| (Optional) Callback function for credential check results |
Configuration
You can customize the component's behavior by passing a config
prop:
<ICPCredentialCheckButton
principal={principal}
gatekeeperNetwork={gatekeeperNetwork}
onCredentialCheck={handleCredentialCheck}
/>
What does the Credential issued by the Civic Canister look like?
The credentials issued by the Civic Canister adhere to the W3C Verifiable Credentials specification, ensuring compatibility and interoperability with various systems and platforms.
Here is an example of a credential the Civic Canister can issue:
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://www.w3.org/ns/credentials/examples/v2"
],
"id": "urn:uuid:6a9c92a9-2530-4e2b-9776-530467e9bbe0",
"type": ["VerifiableCredential", "CivicPass"],
"issuer": "did:icp:v0:tglqb-kbqlj-to66e-3w5sg-kkz32-c6ffi-nsnta-vj2gf-vdcc5-5rzjk-jae",
"expiry": "2024-04-04T00:00:00Z",
"credentialSubject": {
"id": "did:icp:user-principal",
"passType": "ag13vc1KaV5kMjp3Gb5yTq8cyZSnHPVkTHdNJ2fWXk1",
"status": "ACTIVE",
"expirationDate": "2024-12-31T23:59:59Z"
}
}
Styling
The button is styled using Emotion CSS. You can customize the appearance by modifying the buttonStyles
constant in the component file.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
We welcome contributions to improve the ICP Credential Check Button! Here are some ways you can contribute:
- Report bugs or suggest features by opening an issue.
- Submit pull requests to fix issues or add new features.
- Improve documentation or add examples.
Please ensure that your code adheres to the existing style and that you've added appropriate tests for your changes.
To contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Support
For support, please email [email protected]. We'll do our best to assist you with any issues or questions you may have about the ICP Civic Credential Check Button.