Vanilla JavaScript
Integrate the General Wisdom Provider SDK using a CDN import. No bundler, no framework, no build step.
Prerequisites
- A registered application in the Provider Dashboard
- Your Application ID and API Key
Complete Example
Create a single index.html file and open it directly in a browser:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My OSINT Application</title>
</head>
<body>
<div id="app">
<!-- Your application content -->
</div>
<script type="module">
import { MarketplaceSDK } from 'https://cdn.jsdelivr.net/npm/@mission_sciences/provider-sdk/dist/marketplace-sdk.es.js';
const APP_ID = 'YOUR_APP_ID';
const API_KEY = 'YOUR_API_KEY';
const sdk = new MarketplaceSDK({
applicationId: APP_ID,
apiKey: API_KEY,
environment: 'production', // 'demo' | 'production'
autoStart: true,
themeMode: 'auto', // 'light' | 'dark' | 'auto'
warningThresholdSeconds: 300, // warn user 5 min before expiry
enableHeartbeat: false, // keep-alive ping
heartbeatIntervalSeconds: 30,
debug: false,
});
sdk.initialize().catch(console.error);
// Clean up on page unload
window.addEventListener('beforeunload', () => sdk.destroy());
</script>
</body>
</html>
Replace placeholders
Swap YOUR_APP_ID and YOUR_API_KEY with the credentials from your Provider Dashboard.
How It Works
| Step | What happens |
|---|---|
| 1. CDN import | The ES module build is loaded directly from jsDelivr. |
| 2. Instantiation | MarketplaceSDK is configured with your credentials and preferences. |
| 3. Initialization | sdk.initialize() authenticates and starts the session lifecycle. |
| 4. Cleanup | The beforeunload listener ensures sdk.destroy() runs when the tab closes. |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
applicationId | string | — | Your registered application ID |
apiKey | string | — | Your API key |
environment | 'demo' | 'production' | 'production' | Target environment |
autoStart | boolean | true | Start session automatically on init |
themeMode | 'light' | 'dark' | 'auto' | 'auto' | UI theme preference |
warningThresholdSeconds | number | 300 | Seconds before expiry to show warning |
enableHeartbeat | boolean | false | Enable keep-alive pings |
heartbeatIntervalSeconds | number | 30 | Interval between heartbeat pings |
debug | boolean | false | Enable verbose console logging |
Common Gotchas
type="module" is required
The SDK is published as an ES module. Without type="module" on the script tag, the import statement throws a syntax error.
CORS when opening from file://
Browsers block ES module imports from file:// origins. Serve your file with any local HTTP server:
npx serve .
# or
python3 -m http.server 8080
No tree-shaking
Using the CDN bundle means you load the entire SDK. For production apps where bundle size matters, consider installing via npm and using a bundler.
Next Steps
- Session Lifecycle — understand session states and transitions
- Playground — experiment with SDK options interactively