@yaotoshi/ginee-auth-relay
v0.10.2
Published
SDK for ginee-auth-relay — API client + React component
Downloads
19
Readme
@yaotoshi/ginee-auth-relay
SDK for ginee-auth-relay — TypeScript API client + React component.
Install
npm install @yaotoshi/ginee-auth-relayAPI Client
import { GineeAuthRelayClient } from '@yaotoshi/ginee-auth-relay';
const client = new GineeAuthRelayClient({
baseUrl: 'http://your-server:9989',
apiKey: 'your-api-key',
timeout: 10000, // optional, default 10s
});
// Create a session
const session = await client.createSession({
callbackUrl: 'https://your-app.com/webhook',
type: 'session', // optional: 'session' | 'base' | 'base_access_token'
ttlSeconds: 120, // optional, default 120
startUrl: 'https://erp.ginee.com/add-integration', // optional
consumerId: 'user-123', // optional
});
console.log(session.novncUrl); // noVNC URL for iframe embedding
// List all profiles
const { profiles, count } = await client.listProfiles();
// Get a specific profile
const profile = await client.getProfile(session.id);
// Kill a profile
await client.killProfile(session.id);
// Health check
const health = await client.health();React Component
Embed the noVNC session in your React app:
import { GineeAuthRelay } from '@yaotoshi/ginee-auth-relay/react';
function MyComponent() {
return (
<GineeAuthRelay
url={session.novncUrl}
style={{ width: '100%', height: 600 }}
onLoad={() => console.log('Session loaded')}
onDisconnect={() => console.log('Session ended')}
onError={(err) => console.error('Error:', err)}
/>
);
}Props
| Prop | Type | Description |
|------|------|-------------|
| url | string | noVNC URL from session.novncUrl |
| style | CSSProperties | Container style |
| className | string | Container CSS class |
| onLoad | () => void | Called when iframe loads |
| onDisconnect | () => void | Called when session ends |
| onError | (error: string) => void | Called on load error |
Webhook Types
Type your webhook handler:
import type { WebhookPayload } from '@yaotoshi/ginee-auth-relay';
// WebhookPayload.status: 'STARTED' | 'SUCCESS' | 'FAILED' | 'TIMEOUT'
app.post('/webhook', (req, res) => {
const payload: WebhookPayload = req.body;
if (payload.status === 'SUCCESS') {
console.log('Auth completed:', payload.body);
}
res.sendStatus(200);
});License
MIT
