JavaScript SDK pour l'écosystème Coldwell Banker. À inclure dans les apps HTML via <script>.
Ajoutez ce snippet dans le <head> de votre application HTML :
<script
src="https://sdk.mybestplace.immo/v0.2.0/cb-sdk.js"
integrity="sha384-g7DJCSIXk08CJ5xDmLVl9MPKhDR9kaiMXQMiOO6oDWfzPVfMFYhIF0DHFyzz5qta"
crossorigin="anonymous"></script>
integrity garantit que le fichier n'a pas été modifié. C'est une protection Subresource Integrity (SRI) standard.
Définissez window.__CB_CONFIG__ avant de charger le SDK :
<script>
window.__CB_CONFIG__ = {
CB_CORE_URL: 'https://yoqbqewkmfrcnaxxoahs.supabase.co',
CB_CORE_ANON_KEY: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
CB_APP_SOURCE: 'votre-app-id'
};
</script>
<script src="https://sdk.mybestplace.immo/v0.2.0/cb-sdk.js" ...></script>
Le SDK expose l'objet global window.CBSDK avec les fonctions suivantes :
CBSDK.createApp() — Crée un client CB depuis window.__CB_CONFIG__CBSDK.requireAuth(options) — Helper d'authentification avec callbacksCBSDK.signInWithGoogle(client, options) — Login Google OAuthCBSDK.signOut(client) — DéconnexionCBSDK.getSession(client) — Récupération de la session activeCBSDK.getCurrentAgent(client) — Profil de l'agent connectéCBSDK.requireAuth({
onAuthenticated: (session, agent) => {
console.log('Connecté:', agent.email);
document.body.innerHTML = `
<h1>Bonjour ${agent.prenom} ${agent.nom}</h1>
`;
},
onUnauthenticated: () => {
console.log('Non connecté');
document.body.innerHTML = `
<button onclick="location.reload()">Se connecter</button>
`;
}
});