🟢 Vue 3 Single File Component (Login.vue)
Here is the equivalent, beautifully styled Vue 3 Single File Component using <script setup> syntax and scoped CSS:
<template>
<div class="praman-auth-container">
<!-- Logged Out / Login Card -->
<div v-if="!user" class="login-card">
<div class="glow-effect"></div>
<!-- Card Header -->
<div class="card-header">
<div class="logo-box">
<span class="logo-text">P</span>
</div>
<h2 class="title">PramanAuth Test App</h2>
<p class="subtitle">Decentralized Zero-Knowledge Biometric Authentication</p>
</div>
<!-- Scanner Indicator -->
<div class="scanner-section">
<div class="scanner-ring" :class="{ 'is-loading': loading }">
<svg class="biometric-icon" :class="{ 'active-icon': loading }" viewBox="0 0 24 24" width="64" height="64">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/>
</svg>
<div v-if="loading" class="scanner-bar"></div>
</div>
</div>
<!-- Action Button & Errors -->
<div class="action-section">
<div v-if="error" class="error-msg">
{{ error }}
</div>
<button
@click="handleLogin"
:disabled="loading"
class="login-button"
>
<template v-if="loading">
<span class="spinner"></span>
Verifying Biometrics...
</template>
<template v-else>
Sign In with PramanAuth
</template>
</button>
</div>
</div>
<!-- Logged In State -->
<div v-else class="success-card">
<div class="check-badge">✓</div>
<h2 class="title">Authenticated Successfully</h2>
<p class="did-info"><strong>DID:</strong> {{ user.did }}</p>
<button @click="logout" class="signout-button">Sign Out</button>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
import { initPraman } from '@praman-network/sdk';
// Initialize with your test credentials
const praman = initPraman({
apiKey: 'pk_test_DOd1GeOt6KW4SzO7EGLIwWYF', // Replace with your actual API key
network: "polygon-amoy",
idpUrl: "https://auth.praman.network",
backendUrl: "https://api.praman.network"
});
const user = ref(null);
const loading = ref(false);
const error = ref(null);
const handleLogin = async () => {
loading.value = true;
error.value = null;
try {
const result = await praman.loginWithPopup({ scopes: ['email', 'profile'] });
if (result.success) {
user.value = result.user;
console.log("User Data:", result.user);
} else {
error.value = "Authentication failed. Please try again.";
}
} catch (err) {
console.error("Auth failed:", err);
error.value = err.message || "An unexpected error occurred.";
} finally {
loading.value = false;
}
};
const logout = () => {
user.value = null;
};
</script>
<style scoped>
.praman-auth-container {
min-height: 100vh;
background-color: #0a0a0c;
color: #ffffff;
font-family: 'Inter', system-ui, sans-serif;
display: flex;
align-items: center;
justifyContent: center;
padding: 20px;
}
.login-card, .success-card {
position: relative;
background: rgba(15, 15, 20, 0.7);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 24px;
padding: 40px 32px;
max-width: 440px;
width: 100%;
backdrop-filter: blur(20px);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
overflow: hidden;
}
.glow-effect {
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, transparent 60%);
pointer-events: none;
z-index: 0;
}
.card-header {
text-align: center;
margin-bottom: 32px;
z-index: 1;
}
.logo-box {
width: 48px;
height: 48px;
border-radius: 12px;
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
display: flex;
align-items: center;
justifyContent: center;
margin: 0 auto 16px;
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.logo-text {
font-weight: bold;
font-size: 22px;
color: #fff;
}
.title {
font-size: 22px;
font-weight: 700;
margin-bottom: 8px;
color: #ffffff;
letter-spacing: -0.025em;
}
.subtitle {
font-size: 13px;
color: #8e8e9f;
line-height: 1.5;
margin: 0;
}
.scanner-section {
margin-bottom: 32px;
z-index: 1;
}
.scanner-ring {
position: relative;
width: 120px;
height: 120px;
border-radius: 50%;
border: 2px solid rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justifyContent: center;
background-color: rgba(255, 255, 255, 0.02);
overflow: hidden;
transition: all 0.3s ease;
}
.scanner-ring.is-loading {
border-color: #6366f1;
animation: pulse 1.5s infinite ease-in-out;
}
.biometric-icon {
fill: #a1a1aa;
transition: fill 0.3s ease;
}
.biometric-icon.active-icon {
fill: #6366f1;
}
.scanner-bar {
position: absolute;
left: 0;
width: 100%;
height: 3px;
background: linear-gradient(90deg, transparent, #6366f1, transparent);
box-shadow: 0 0 8px #6366f1;
animation: scan 2s infinite linear;
}
.action-section {
width: 100%;
z-index: 1;
}
.login-button {
width: 100%;
padding: 14px;
border-radius: 12px;
border: none;
background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
color: #ffffff;
font-size: 15px;
font-weight: 600;
box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
justifyContent: center;
gap: 8px;
}
.login-button:disabled {
opacity: 0.7;
cursor: not-allowed;
}
.error-msg {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.2);
border-radius: 8px;
padding: 12px;
color: #f87171;
font-size: 13px;
margin-bottom: 16px;
text-align: center;
}
.spinner {
width: 16px;
height: 16px;
border-radius: 50%;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: #ffffff;
animation: spin 0.8s infinite linear;
}
/* Success State Styles */
.check-badge {
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
display: flex;
align-items: center;
justifyContent: center;
margin-bottom: 20px;
font-size: 24px;
}
.did-info {
color: #9ca3af;
font-size: 14px;
margin-bottom: 24px;
word-break: break-all;
text-align: center;
}
.signout-button {
width: 100%;
padding: 12px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.15);
background: transparent;
color: #ffffff;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
}
/* Animations */
@keyframes pulse {
0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
50% { transform: scale(1.03); box-shadow: 0 0 20px 10px rgba(99, 102, 241, 0.1); }
100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}
@keyframes scan {
0% { top: 0%; }
50% { top: 100%; }
100% { top: 0%; }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
Basic Usage Example
If you just want the minimal init + login flow without the full styled card, here's the simplest version:
<template>
<button @click="handleLogin">Sign in with Praman</button>
</template>
<script setup>
import { onMounted } from 'vue';
import { initPraman, loginWithPraman } from '@praman-network/sdk';
onMounted(() => {
// Initialize with your developer API Key
initPraman({
apiKey: 'pm_dev_your_api_key_here',
backendUrl: 'https://auth.praman.network'
});
});
const handleLogin = async () => {
try {
const authResult = await loginWithPraman();
console.log('User Authenticated:', authResult);
} catch (err) {
console.error('Authentication error:', err);
}
};
</script>