Skip to main content

Vanilla JavaScript

Integrate the General Wisdom Provider SDK using a CDN import. No bundler, no framework, no build step.

Prerequisites

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

StepWhat happens
1. CDN importThe ES module build is loaded directly from jsDelivr.
2. InstantiationMarketplaceSDK is configured with your credentials and preferences.
3. Initializationsdk.initialize() authenticates and starts the session lifecycle.
4. CleanupThe beforeunload listener ensures sdk.destroy() runs when the tab closes.

Configuration Options

OptionTypeDefaultDescription
applicationIdstringYour registered application ID
apiKeystringYour API key
environment'demo' | 'production''production'Target environment
autoStartbooleantrueStart session automatically on init
themeMode'light' | 'dark' | 'auto''auto'UI theme preference
warningThresholdSecondsnumber300Seconds before expiry to show warning
enableHeartbeatbooleanfalseEnable keep-alive pings
heartbeatIntervalSecondsnumber30Interval between heartbeat pings
debugbooleanfalseEnable 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