0.0.3 • Published 10 months ago

@civic/icp-gateway-react-ui v0.0.3

Weekly downloads
-
License
MIT*
Repository
github
Last release
10 months ago

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

PropTypeDescription
principalPrincipalThe user's ICP principal
gatekeeperNetworkstringThe Gatekeeper network for the Civic Pass
configPartial<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:

  1. Report bugs or suggest features by opening an issue.
  2. Submit pull requests to fix issues or add new features.
  3. 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:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Support

For support, please email dev@civic.com. We'll do our best to assist you with any issues or questions you may have about the ICP Civic Credential Check Button.

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.1-beta.5

10 months ago

0.0.1-beta.4

10 months ago

0.0.1-beta.3

10 months ago

0.0.1-beta.2

10 months ago

0.0.1-beta.1

10 months ago

0.0.1-beta.0

10 months ago