Web Sample Applications

Below are complete web sample applications demonstrating FIDO2 authentication using the Arculus JavaScript SDK (arculusfido.js). These examples are useful for developers building web applications that integrate with the Arculus FIDO2 Server.

Minimal Example

This minimal example shows the essential code to register and authenticate a user without any UI scaffolding or error handling. The Web SDK only supports the client-direct pattern.

<!DOCTYPE html>
<html>
<head>
    <script src="arculusfido.js"></script>
</head>
<body>
    <script>
        // Registration
        async function registerUser() {
            const result = await arculusfido.RegisterUser(
                "[email protected]",           // username
                "My Device",                  // displayName
                { deviceinfo: "Browser" },    // deviceInfo
                "",                           // serverUrlPrefix (empty for same origin)
                "",                           // queryParams
                {}                            // addHeaders
            );
            console.log("Registration:", result);
        }
        
        // Authentication
        async function authenticateUser() {
            const result = await arculusfido.AuthenticateUser(
                "[email protected]",           // username
                "",                           // serverUrlPrefix (empty for same origin)
                "",                           // queryParams
                {}                            // addHeaders
            );
            console.log("Authentication:", result);
        }
        
        // Call functions
        registerUser();
        authenticateUser();
    </script>
</body>
</html>

Complete Sample Applications

The following sections provide complete, production-ready sample applications with full error handling, UI components, and proper integration patterns.

Client-Direct Pattern

A complete HTML/JavaScript example demonstrating direct FIDO2 server communication:

HTML Structure

Enhanced Example with Error Handling

Multi-Tenant Example

For deployments with multiple relying parties:

Cross-Origin Example

When the FIDO2 Server is on a different domain:

Backend Implementation

Note: The Web SDK (arculusfido.js) only supports the client-direct pattern, where the web application communicates directly with the FIDO2 Server. There is no backend-proxied pattern for web applications.

The JavaScript SDK handles all FIDO2 Server REST API calls internally. Web developers do not need to implement a backend service for FIDO2 operations - the SDK abstracts all server communication.

If you need backend-proxied functionality for web applications, you would need to:

  1. Build a custom backend service (similar to the Java servlet shown in 5.2 iOS Sample Applications)

  2. Use the browser WebAuthn API directly instead of the arculusfido.js SDK

  3. Have your backend proxy requests to the FIDO2 Server

Last updated