@komo-tech/embed-core
v0.1.1
Published
Platform-neutral session core for Komo embeds.
Downloads
55
Readme
@komo-tech/embed-core
Platform-neutral session core for Komo embeds. Owns identity exchange, memory-only session state, refresh scheduling, and typed events without binding to web or React Native runtime APIs.
Copyright Komo Technologies. All rights reserved.
Usage
import {
FetchEmbedSessionClient,
KomoEmbedSessionManager
} from '@komo-tech/embed-core';
const session = new KomoEmbedSessionManager({
appId: 'app-id',
siteId: 'site-guid',
getIdentityToken: async () => ({
type: 'jwt',
token: await host.getJwt()
}),
client: new FetchEmbedSessionClient({
region: 'au1',
fetch: hostFetch
})
});
const bearer = await session.getBearerToken();Use region: 'au1' or region: 'us1' for the public Komo API region.
Use email identity without siteId:
const session = new KomoEmbedSessionManager({
appId: 'app-id',
getIdentityToken: () => ({
type: 'email',
attributes: { email: '[email protected]' }
}),
client
});Subscribe to events:
const unsubscribe = session.onAuthenticated(({ contactId, trustLevel }) => {
logger.info('Komo session authenticated', { contactId, trustLevel });
});
unsubscribe();
session.dispose();