Variable: HolderContext

typescript
1
const HolderContext: Context<undefined | AgentContextType & object>

Defined in: packages/identus-react/src/context/index.ts:541

React context for credential holder operations.

Provides functionality for receiving, storing, and presenting verifiable credentials. Includes support for parsing credential offers, accepting credentials, and responding to presentation requests.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { HolderContext } from '@trust0/identus-react/context';
import { useContext } from 'react';
function CredentialHolder() {
const context = useContext(HolderContext);
if (!context) {
throw new Error('CredentialHolder must be used within HolderProvider');
}
const { parseOOBOffer, acceptOOBOffer, handlePresentationRequest } = context;
const acceptCredentialOffer = async (offerUrl: string, peerDID: SDK.Domain.DID) => {
try {
// Parse the offer
const message = await parseOOBOffer(offerUrl, peerDID);
// Accept and store the credential
await acceptOOBOffer(message);
console.log('Credential accepted and stored');
} catch (error) {
console.error('Failed to accept credential:', error);
}
};
return (
<div>
<button onClick={() => acceptCredentialOffer(offerUrl, myPeerDID)}>
Accept Credential Offer
</button>
</div>
);
}