HomeDocs

Documentation

Passkey SDK Usage

Include the SDK in your HTML file:

<script src="https://passkey.okuso.uk/passkey-sdk.js"></script>

Initialize the SDK:

const passkey = new PasskeySDK();

Registration

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);
    }
}

Login

async function loginUser() {
    try {
        const { user, token } = await passkey.login();
        console.log('Login successful:', user);
    } catch (error) {
        console.error('Login failed:', error);
    }
}

Logout

async function logoutUser() {
    await passkey.logout();
    console.log('Logged out');
}

Get Current User Profile

async function getUserProfile() {
    try {
        const profile = await passkey.getProfile();
        console.log('User profile:', profile);
    } catch (error) {
        console.error('Failed to get profile:', error);
    }
}

Get Full User Profile

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);
    }
}

Update User Profile

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);
    }
}

API Reference

Authentication

User Management