Include the SDK in your HTML file:
<script src="https://passkey.okuso.uk/passkey-sdk.js"></script>Initialize the SDK:
const passkey = new PasskeySDK();async function registerUser() {
try {
const { user, token } = await passkey.register('newuser', 'New User', '[email protected]');
console.log('Registration successful:', user);
} catch (error) {
console.error('Registration failed:', error);
}
}async function loginUser() {
try {
const { user, token } = await passkey.login();
console.log('Login successful:', user);
} catch (error) {
console.error('Login failed:', error);
}
}async function logoutUser() {
await passkey.logout();
console.log('Logged out');
}async function getUserProfile() {
try {
const profile = await passkey.getProfile();
console.log('User profile:', profile);
} catch (error) {
console.error('Failed to get profile:', error);
}
}async function getFullUserProfile(userId) {
try {
const fullProfile = await passkey.getFullProfile(userId);
console.log('Full user profile:', fullProfile);
} catch (error) {
console.error('Failed to get full profile:', error);
}
}async function updateUserProfile(userId, profileData) {
try {
const result = await passkey.updateProfile(userId, profileData);
console.log('Profile updated:', result);
} catch (error) {
console.error('Failed to update profile:', error);
}
}