Use with AI Assistants
If you use an AI coding assistant (Claude, GPT, Copilot, etc.), copy the following block and paste it into your assistant's context. It contains everything needed to get a basic integration working.
# AutoProctor SDK — Integration Context
AutoProctor is a JavaScript SDK that monitors candidates during online exams via camera, microphone, and screen share. It runs entirely in the browser.
## Loading the SDK
Add this script tag to your HTML:
```html
<script src="https://cdn.autoproctor.co/ap-entry.js"></script>
```
## Authentication
- You receive a CLIENT_ID and CLIENT_SECRET from AutoProctor.
- NEVER expose CLIENT_SECRET in frontend code. Compute hashes on your backend.
- For each test attempt, compute an HMAC-SHA256 hash of the testAttemptId using CLIENT_SECRET as the key.
## The Integration
```js
// 1. Build credentials (hash must be computed server-side in production)
const credentials = {
clientId: 'your-client-id',
testAttemptId: 'unique-id-from-your-database', // max 40 chars
hashedTestAttemptId: 'hmac-sha256-of-testAttemptId-using-CLIENT_SECRET'
}
// 2. Choose what to monitor
const proctoringOptions = {
trackingOptions: {
audio: true, // Background noise detection
numHumans: true, // Face count monitoring
tabSwitch: true, // Tab/window switch detection
photosAtRandom: true, // Random photo capture
}
}
// 3. Initialize, set up, and start
let apInst = new AutoProctor(credentials)
await apInst.setup(proctoringOptions)
apInst.start()
// 4. When the candidate submits their test
apInst.stop()
// 5. On a separate page, show the proctoring report
let apInst = new AutoProctor(credentials)
apInst.showReport({ showReport: true })
```
## Key Events (window.addEventListener)
- `apSetupCompleted` — .setup() finished, ready to start
- `apMonitoringStarted` — .start() finished, monitoring is active
- `apMonitoringStopped` — .stop() finished, test finalized
## Resuming
If .stop() has NOT been called, calling .start() with the same testAttemptId automatically resumes the session.
## Common Pitfalls
1. Never expose CLIENT_SECRET in browser code. Compute hashes server-side.
2. After .stop(), you cannot call .start() with the same testAttemptId.
3. The testAttemptId max length is 40 characters.