JavaScript SDK
Installation and usage guide for the Humanmark JavaScript SDK.
Installation
npm install @humanmark/sdk-js
# or
yarn add @humanmark/sdk-js
# or
pnpm add @humanmark/sdk-js Quick Start
Initialize the SDK with your API key and a challenge token from your backend:
import { HumanmarkSdk, ErrorCode } from '@humanmark/sdk-js';
const sdk = new HumanmarkSdk({
apiKey: 'your-api-key',
challengeToken: 'challenge-token-from-backend'
});
try {
const receipt = await sdk.verify();
// Send receipt to your backend for verification
console.log('Receipt:', receipt);
} catch (error) {
if (error.code === ErrorCode.USER_CANCELLED) {
console.log('User cancelled verification');
} else {
console.error('Verification failed:', error);
}
} Configuration Options
| Option | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Yes | Your Humanmark API key |
| challengeToken | string | Yes | Challenge token from your backend |
| baseUrl | string | No | Base URL for API requests (default: 'https://humanmark.io') |
| theme | 'light' | 'dark' | 'auto' | No | Modal theme (default: 'dark') |
CDN
<!-- Browser bundle (IIFE) -->
<script
src="https://cdn.jsdelivr.net/npm/@humanmark/sdk-js@1.0.1/dist/browser/index.js"
integrity="sha384-mysw5+aX4bvSFaHpoASX5uIByx2UWBd5AdEdu9l9IW+/YwX89y1JU6g8TRLKIigV"
crossorigin="anonymous">
</script>
<!-- Or UMD bundle -->
<script
src="https://cdn.jsdelivr.net/npm/@humanmark/sdk-js@1.0.1/dist/umd/index.js"
integrity="sha384-JCX9KMVmMXEZw2ckSuEEp6vtB1IlPsspCdyInEbw9oF530+uONfpnZR1ecKfKzvi"
crossorigin="anonymous">
</script> Security Note
Always use SRI (Subresource Integrity) hashes when loading scripts from CDN to ensure the integrity of the code.
Find the latest SRI hashes in the README at npm: @humanmark/sdk-js
Note: Humanmark is currently in beta. To get API credentials, please email sales@humanmark.io.