คู่มือการใช้งานระบบฉบับสมบูรณ์

คู่มือการใช้งานระบบ Login512

คำแนะนำแบบเป็นขั้นตอนสำหรับการใช้งานระบบชีวมิติหลังควอนตัม การลงทะเบียนใบหน้า Passkey และการเชื่อมต่อระบบสำหรับผู้พัฒนา

Chapter 1

1. สถาปัตยกรรมและความปลอดภัยของ Login512

Login512 ถูกสร้างขึ้นบนหลักการ Zero Trust ไร้รหัสผ่าน โดยใช้เทคโนโลยีชีวมิติที่ต้านทานคอมพิวเตอร์ควอนตัม (Post-Quantum Cryptography)

🛡️ 1.1 Zero-Image Persistence (ไร้การบันทึกภาพถ่าย)

ระบบไม่มีการบันทึกภาพถ่ายใบหน้า ภาพวิดีโอ หรือเฟรมกล้องลงดิสก์หรือฐานข้อมูลเด็ดขาด ทุกเฟรมภาพประมวลผลบนหน่วยความจำ RAM ชั่วคราว และถูกล้างทำลาย (Memory Wipe) ทันทีที่สกัดเวกเตอร์ลักษณะใบหน้าเสร็จสิ้น

🔑 1.2 Cancelable Biometrics (เทมเพลตชีวมิติเพิกถอนได้)

เวกเตอร์ชีวมิติถูกฉายและหมุนทางคณิตศาสตร์ด้วยเมทริกซ์การฉายลับ Q เฉพาะของแต่ละองค์กร (T = Q · E) ทำให้ไม่สามารถย้อนกลับเป็นภาพใบหน้าเดิมได้ และหากเกิดเหตุสงสัย สามารถหมุนเวียนคีย์ Q เพื่อสร้างเทมเพลตใหม่ได้ทันทีโดยผู้ใช้ไม่ต้องมาสแกนใหม่

⚛️ 1.3 NIST FIPS 204 ML-DSA-65 (ลายเซ็นหลังควอนตัม)

โทเคนการยืนยันตัวตนทุกใบถูกลงลายเซ็นดิจิทัลด้วยอัลกอริทึม ML-DSA-65 (Dilithium3) ซึ่งได้รับการรับรองมาตรฐานสากล FIPS 204 โดย NIST ต้านทานการเจาะรหัสผ่านจากคอมพิวเตอร์ควอนตัมในอนาคตได้อย่างสมบูรณ์

Chapter 2

2. คู่มือการใช้งานสำหรับผู้ใช้งานทั่วไป (End-User Guide)

ขั้นตอนการเข้าใช้งานระบบด้วยชีวมิติไร้รหัสผ่าน สะดวก รวดเร็วใน 1 วินาที ปลอดภัยสูงสุด

1 ขั้นตอนที่ 1: การลงทะเบียนใบหน้าครั้งแรก (Biometric Enrollment)

กดปุ่ม 'ลงทะเบียนใบหน้า' และอนุญาตให้เบราว์เซอร์เข้าถึงกล้อง จัดใบหน้าให้อยู่ตรงกลางกรอบวงรี ระบบจะตรวจจับภาพสด 15 เฟรม (3D Liveness) และบันทึกเวกเตอร์ชีวมิติเข้ารหัสลงฐานข้อมูลภายในเวลาไม่ถึง 2 วินาที

2 ขั้นตอนที่ 2: การสแกนใบหน้าเข้าสู่ระบบ (1:N Face Scan Login)

กดปุ่ม 'สแกนใบหน้าเข้าสู่ระบบ' มองกล้องโดยตรง ระบบจะทำการค้นหาเปรียบเทียบแบบ 1:N ใน RAM ทันทีโดยที่ท่านไม่ต้องกรอก Username หรือ Password ใด ๆ ทั้งสิ้น

3 ขั้นตอนที่ 3: การเข้าสู่ระบบด้วย Passkey (ลายนิ้วมือ / Face ID)

สำหรับอุปกรณ์ที่มี Touch ID, Windows Hello หรือกุญแจฮาร์ดแวร์ FIDO2 สามารถเลือก 'เข้าสู่ระบบด้วย Passkey' แล้วแตะลายนิ้วมือหรือยืนยันผ่านอุปกรณ์ของท่านได้ทันที

Chapter 3

3. คู่มือการเชื่อมต่อสำหรับนักพัฒนา (Developer Integration)

Login512 รองรับการเชื่อมต่อครบทุกแพลตฟอร์ม ทั้งเว็บแอปพลิเคชัน โมบายล์แอป และระบบเซิร์ฟเวอร์หลังบ้าน 5 รูปแบบ:

วิธีที่ 1: Drop-in Web Component (<login512-card>)

วิธีที่ง่ายและเร็วที่สุด เพียงเพิ่ม Script และวางแท็ก <login512-card> ในหน้าเว็บ

HTML / Frontend Web
<!-- 1. Include Login512 Client SDK -->
<script src="https://login512.com/sdk/login512-sdk.js"></script>
<link rel="stylesheet" href="https://login512.com/sdk/login512-sdk.css">

<!-- 2. Embed Auth Component -->
<login512-card
  publishable-key="l512_pk_live_your_key"
  template="fintech"
  system-name="MyApplication"
  logo="https://yourapp.com/logo.png">
</login512-card>

วิธีที่ 2: JavaScript SDK (Login512.init)

สำหรับผู้ที่ต้องการควบคุมปุ่มและโฟลว์การล็อกอินอย่างอิสระด้วย JavaScript, React, Vue, หรือ Angular

JavaScript / TypeScript
// Initialize SDK instance with Publishable Key
const l512 = Login512.init({
  publishableKey: "l512_pk_live_your_key",
  locale: "th" // or auto-detect
});

// Mount custom biometric trigger button
l512.mountButton("#login-container", {
  mode: "1n_face",
  onSuccess: async (token, user) => {
    // Forward PQC token to your backend session endpoint
    const res = await fetch("/api/auth/session", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ token: token })
    });
    const session = await res.json();
    console.log("Logged in user:", session);
  },
  onError: (error) => {
    console.error("Biometric authentication error:", error);
  }
});

วิธีที่ 3: OpenID Connect (OIDC) & OAuth 2.0 PKCE

ไม่ต้องเขียนโค้ดฝั่งหน้าบ้าน: ส่งผู้ใช้ไปที่ Gateway และรับ Authorization Code กลับมาแลกรับ ID Token ใช้งานร่วมกับ Supabase, NextAuth.js, Keycloak ได้ทันที

OIDC Discovery & Authorize Endpoint
# 1) Register your OIDC client once, from your server, with your SECRET key.
#    publishable_key = your tenant's publishable key (the Login512 login page uses it).
curl -X POST https://login512.com/oauth/register \
  -H "Authorization: Bearer $LOGIN512_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"client_name": "My App",
       "redirect_uris": ["https://yourapp.com/api/auth/callback/login512"],
       "publishable_key": "l512_pk_..."}'
# -> { "client_id": "l512_client_...", "client_secret": "l512_cs_..." }  (secret is shown once)

# 2) Point your OIDC library at the issuer (discovery is automatic):
#    Issuer:    https://login512.com
#    Discovery: https://login512.com/.well-known/openid-configuration
#    Flow:      authorization code + PKCE (S256), state, nonce

# Auth.js v5 (next-auth@5) provider:
{ id: "login512", name: "Login512", type: "oidc", issuer: "https://login512.com",
  clientId: process.env.LOGIN512_CLIENT_ID, clientSecret: process.env.LOGIN512_CLIENT_SECRET,
  checks: ["pkce", "state", "nonce"] }

# Users must already be enrolled in your tenant. Link accounts by "sub" or
# "preferred_username" (your external_user_id): Login512 does not verify e-mail addresses.

วิธีที่ 4: ตรวจสอบความถูกต้องของโทเคน (Backend Token Verification)

ส่งคำขอ POST /v1/token/verify พร้อมโทเคนชีวมิติเพื่อตรวจสอบความถูกต้องและดึงข้อมูล User Claims

cURL / REST API Verification
curl -X POST https://login512.com/v1/token/verify \
  -H "Authorization: Bearer l512_sk_live_your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{"token": "l512_tok_post_quantum_mldsa65_sample"}'

# Response 200 OK:
# {
#   "valid": true,
#   "claims": {
#     "sub": "usr_94b1a8f2",
#     "tenant_id": "ten_default",
#     "biometric_mode": "1n_face",
#     "pqc_algorithm": "ML-DSA-65",
#     "exp": 1731422000
#   }
# }

วิธีที่ 5: การเลือกใช้และปรับแต่งเทมเพรต 20 แบบสำเร็จรูป

กำหนด attribute template, logo, และ system-name ในแท็กเพื่อเปลี่ยนโฉมหน้าจอให้เข้ากับหมวดธุรกิจของคุณ (เช่น Fintech, Shop, Hotel, Crypto)

HTML Attributes Example
<!-- Fintech Template with Custom Logo -->
<login512-card template="fintech" logo="https://mybank.com/logo.png" system-name="FinPay Portal"></login512-card>

<!-- Healthcare Clinic Template -->
<login512-card template="healthcare" logo="https://clinic.com/logo.svg" system-name="MedCare Identity"></login512-card>

<!-- Hotel & Hospitality Template -->
<login512-card template="hospitality" logo="https://hotel.com/logo.png" system-name="Grand Resort Keyless"></login512-card>

วิธีที่ 6: เชื่อมต่อผ่าน AI Coding Agents & Model Context Protocol (MCP)

ติดตั้ง Login512 MCP Server เข้ากับ Claude Desktop, Cursor, Windsurf, หรือ VS Code Cline เพื่อให้ AI ช่วยสแกนโปรเจกต์ วางแท็กสแกนใบหน้า และตรวจสอบความปลอดภัยให้โดยอัตโนมัติ

MCP Server Config (claude_desktop_config.json / .cursor/mcp.json)
{
  "mcpServers": {
    "login512": {
      "command": "python",
      "args": ["-m", "login512_mcp"]
    }
  }
}

👉 เปิดอ่านคู่มือติดตั้ง MCP สำหรับทุก AI ในท้องตลาด (9+ ค่าย) ฉบับเต็ม →

วิธีที่ 7: ใช้ Login512 แทนระบบ TOTP / Google Authenticator คู่กับ Login แบบเก่า + ปุ่มอัปเกรดแทน Login เก่า

สำหรับเว็บที่มีระบบ Login แบบเก่าอยู่แล้ว (Username/Password, LINE Login, Google OAuth) สามารถนำ Login512 ไปใช้เป็นด่าน 2FA แทนรหัส 6 หลัก (TOTP / Google Authenticator) ได้ทันที โดยมีทั้งปุ่ม 📸 สแกนใบหน้า และ 👆 สแกนลายนิ้วมือ / Passkey (กรณีแสงน้อย) พร้อมสวิตช์ตั้งค่าพิเศษให้ผู้ใช้กดเพื่อให้ครั้งต่อไปข้ามหน้า Login เดิมเข้าสู่ระบบด้วย Login512 ทันที

HTML & JavaScript: Drop-in 2FA TOTP Replacement + Primary Upgrade
<script src="https://login512.com/sdk/login512-sdk.js"></script>
<link rel="stylesheet" href="https://login512.com/sdk/login512-sdk.css">

<!-- 1. วางกล่อง 2FA หลังผู้ใช้ล็อกอินแบบเก่าผ่าน (แทนช่องกรอก OTP 6 หลัก) -->
<div id="login512-2fa-slot"></div>
<script>
const sdk = Login512.init({ publishableKey: 'l512_pk_live_your_key' });

// ⚠️ ความปลอดภัย: เบราว์เซอร์ทำหน้าที่สแกนเท่านั้น การออกโทเคนลงทะเบียนและการยืนยัน 2FA ต้องทำที่ backend ของคุณด้วย secret key
// (/v1/2fa/* ไม่รับ publishable key ตั้งแต่ 2026-11-20) และห้ามข้ามการ login เพราะค่าใน localStorage (sdk.shouldBypassLegacyLogin() เป็นแค่ UI hint)
sdk.mount2FA('#login512-2fa-slot', {
  externalUserId: 'user_1001',
  // backend ของคุณ: POST /v1/2fa/enroll-token (Authorization: Bearer l512_sk_...) ให้ผู้ใช้ที่ login อยู่ใน session
  getEnrollmentToken: () => fetch('/api/2fa/enroll-token', { method: 'POST' }).then(r => r.json()),
  // backend ของคุณ: POST /v1/2fa/verify (secret key) โดยใช้ external_user_id จาก session ไม่ใช่ค่าที่เบราว์เซอร์ส่งมา
  verifyOnServer: (token, ctx) => fetch('/api/2fa/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token, upgradeToPrimary: ctx.upgradeToPrimary })
  }).then(r => r.json()),
  onSuccess: (res) => {
    if (res.verified === true) window.location.href = '/dashboard'; // backend ของคุณออก session หลัง verify สำเร็จแล้ว
  }
});
</script>
API Endpoints สำหรับ 2FA แทน TOTP (Backend Integration)

• POST /v1/2fa/enroll-token — ออกโทเคนผูก 2FA กับบัญชีเดิม (external_user_id)
• POST /v1/2fa/verify — ตรวจสอบผลสแกน 2FA และอัปเกรดเป็น Primary Mode เมื่อส่ง upgrade_to_primary: true
• POST /v1/2fa/upgrade-primary / GET /v1/2fa/status/{external_user_id} — เปิด/ปิด หรือเช็กสถานะการข้าม Login เดิม

วิธีที่ 8: โหมด First-Time Genesis Mode (เริ่มต้นระบบครั้งแรกแบบไร้รหัสผ่าน 100%)

หากสร้างระบบที่ตัด User/Password ออกทั้งหมดและใช้ Login512 อย่างเดียว การเปิดใช้งานครั้งแรกของ Superadmin คนแรก จะทำงานผ่านโหมด First-Time Genesis Mode เพื่อป้องกันไม่ให้คนนอกแอบสแกนหน้าตัดหน้ายึดสิทธิ์ระบบ:

ขั้นตอนการทำงาน 3 จังหวะ (Auto-Seal หลังลงทะเบียน)

1. ระบบเช็ก GET /v1/genesis/status หากพบว่ายังไม่มี Superadmin (genesis_required: true) ให้แสดง Widget sdk.mountGenesisSetup('#genesis-setup')
2. เจ้าของระบบกรอก One-Time Genesis Setup Key จากหน้าจอ Terminal / .env (LOGIN512_GENESIS_KEY) แล้วกดเลือก 📸 สแกนใบหน้า หรือ 👆 แตะลายนิ้วมือ
3. ระบบเรียก POST /v1/genesis/claim เพื่อแต่งตั้งบัญชี Superadmin คนแรก และปิดตายโหมด Genesis ทันที ไม่มีใครสามารถสแกนแย่งสิทธิ์ซ้ำได้อีก

Chapter 4

4. บัญชีนักพัฒนา & การจัดการ API Keys

การบริหารจัดการ Workspace กุญแจ API และการตรวจสอบสถิติการใช้งาน

4.1 การเปิดบัญชีและเข้าสู่ระบบด้วยชีวมิติ (Dogfooding)

Login512 ใช้ระบบชีวมิติของตนเอง 100% ในการเปิดบัญชีนักพัฒนา ท่านต้องสแกนใบหน้าหรือลงทะเบียน Passkey เพื่อสร้าง Workspace และเข้าถึงคอนโซล

4.2 ประเภทของ API Keys (Publishable vs Secret)

Publishable Key (l512_pk_...) ใช้สำหรับใส่ในโค้ดหน้าบ้าน และ Secret Key (l512_sk_...) ใช้สำหรับการตรวจสอบโทเคนฝั่งเซิร์ฟเวอร์หลังบ้าน ห้ามเปิดเผย Secret Key เด็ดขาด

4.3 การตรวจสอบสถิติการใช้งาน (Live Telemetry)

ท่านสามารถติดตามปริมาณการสแกนชีวมิติทั่วโลกและขององค์กรตนเองผ่าน Dashboard หรือยิง API สาธารณะ GET https://login512.com/v1/stats/public เพื่อดูยอด Live Scans และ Developer Workspaces ได้ตลอดเวลา

Chapter 5

5. การแก้ปัญหาและคำถามที่พบบ่อย (Troubleshooting & FAQs)

Q1: ถาม: หากเบราว์เซอร์ไม่อนุญาตให้เปิดกล้อง ต้องแก้ไขอย่างไร?

ตอบ: คลิกที่ไอคอนรูปกล้องหรือแม่กุญแจบนแถบ URL ของเบราว์เซอร์ แล้วเลือก 'อนุญาต (Allow)' การเข้าถึงกล้อง จากนั้นกดรีเฟรชหน้าเว็บ หากใช้ iOS Safari กรุณาตรวจสอบในการตั้งค่า Safari > กล้อง ให้เปิดใช้งาน

Q2: ถาม: การสวมแว่นตา เปลี่ยนทรงผม หรือแต่งหน้า มีผลต่อการสแกนใบหน้าหรือไม่?

ตอบ: ระบบถูกออกแบบมาให้รองรับการสวมแว่นสายตาทั่วไป การเปลี่ยนทรงผม และการแต่งหน้าในชีวิตประจำวัน อย่างไรก็ตาม ควรหลีกเลี่ยงการสวมแว่นตากันแดดสีเข้ม หรือหน้ากากอนามัยที่บดบังส่วนกลางของใบหน้าขณะสแกน

Q3: ถาม: ระบบสอดคล้องกับ พ.ร.บ. คุ้มครองข้อมูลส่วนบุคคล (PDPA/GDPR) หรือไม่?

ตอบ: สอดคล้อง 100% ด้วยสถาปัตยกรรม Zero-Image Persistence ที่ไม่มีการเก็บรูปภาพใบหน้าในดิสก์ และเวกเตอร์ชีวมิติถูกเข้ารหัสแบบทางเดียว (One-way Irreversible) ซึ่งปลอดภัยและได้รับความคุ้มครองสูงสุดตามมาตรฐานสากล

Chapter 6

6. คู่มือการเชื่อมต่อ SDK และ ปลั๊กอินอย่างเป็นทางการ (Official SDK & Framework Integration Guides)

คู่มือติดตั้งและตัวอย่างโค้ดจริงสำหรับการเชื่อมต่อ Login512 ครบทุกภาษาและเฟรมเวิร์กในโลก พร้อมคำสั่งติดตั้ง โฟลว์การยืนยันตัวตน และการตรวจสอบความถูกต้องของโทเคนชีวมิติหลังควอนตัม (ML-DSA-65)

🚀

วิธีติดตั้งอัตโนมัติด้วยคำสั่งเดียว (1-Click Universal Auto-Installer)

สำหรับผู้ใช้ที่ไม่ต้องการตั้งค่า Git หรือ Local Repo เอง ระบบจะตรวจจับภาษาและติดตั้ง SDK ให้ทันที 100%

curl -s https://login512.com/login512-agent.py -o login512.py && python login512.py install
💡 หรือสั่งติดตั้งผ่าน Live Package URL ในแต่ละภาษาได้ทันที (ใช้งานได้จริง ไม่ต้องรอ Registry):
• React: npm install @login512/react
• Next.js: npm install @login512/nextjs
• Vue / Nuxt / Svelte: npm install @login512/vue
• Python FastAPI: pip install login512-fastapi
• PHP / Laravel: curl -s https://login512.com/sdk/php/Login512.php -o app/Services/Login512.php
⚛️

React (React 18 / 19)

Official Package (.tgz) • React 18 / 19 • Next.js • Vite • CRA
Official SDK PQC Verified

คอมโพเนนต์ <Login512Button> และ Custom Hook useLogin512() ที่รองรับทั้งการสแกนใบหน้าและ Passkey ในตัว พร้อม TypeScript Type Definitions ครบถ้วน

ติดตั้ง: npm install @login512/react
1. ครอบแอปพลิเคชันด้วย Login512Provider (Root Layout หรือ App.tsx)
TSX
import React from 'react';
import { Login512Provider } from '@login512/react';

export default function App({ children }: { children: React.ReactNode }) {
  return (
    <Login512Provider
      publishableKey="l512_pk_live_your_key_here"
      theme="auto"
      locale="th"
    >
      {children}
    </Login512Provider>
  );
}
2. วางคอมโพเนนต์ <Login512Button /> หรือเรียกใช้ Hook useLogin512()
TSX
import React from 'react';
import { Login512Button, useLogin512 } from '@login512/react';

export function LoginPage() {
  const { authenticate, isScanning } = useLogin512();   // authenticate() opens the same auth frame without a button

  const handleSuccess = async (token: string) => {
    const res = await fetch('/api/auth/session', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ token }),
    });
    if (res.ok) window.location.href = '/dashboard';
  };

  return (
    <div className="login-card">
      <Login512Button mode="auto" onSuccess={handleSuccess} onError={(err) => console.error(err)} />
      <button disabled={isScanning} onClick={async () => handleSuccess((await authenticate()).token)}>Custom button</button>
    </div>
  );
}
3. ตรวจสอบโทเคนที่ได้จาก React บน Backend (Node.js/Python/Go)
TYPESCRIPT
// Backend Route: POST /api/auth/session (Next.js route handler, Node 18+). No extra package needed.
export async function POST(req: Request) {
  const { token } = await req.json();
  const r = await fetch('https://api.login512.com/v1/token/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.LOGIN512_SECRET_KEY}` },
    body: JSON.stringify({ token }),
  });
  const v = await r.json();
  // HTTP 200 alone is NOT success: rejected tokens return 200 { valid: false, error: 'TOKEN_ALREADY_USED' | ... }
  const ok = v.valid === true && !v.step_up_required;   // v.claims.sub = the external_user_id you enrolled
  if (!ok) return Response.json({ error: v.error || 'STEP_UP_REQUIRED' }, { status: 401 });

  // create your session for v.claims.sub here
  return Response.json({ success: true, userId: v.claims.sub });
}
▲

Next.js (App Router & Server Actions)

Official Package (.tgz) • Next.js 13 / 14 / 15 • App & Pages Router
Official SDK PQC Verified

SDK พิเศษสำหรับ Next.js App Router รองรับ Client Component Biometric Trigger, Server Actions สำหรับสร้าง Session Cookie และ Route Handler Token Verification

ติดตั้ง: npm install @login512/nextjs
1. สร้าง Client Component สำหรับปุ่มสแกนชีวมิติ (app/login/page.tsx)
TSX
'use client';

import { Login512Button } from '@login512/nextjs/client';
import { handleLoginAction } from './actions';

export default function LoginPage() {
  return (
    <main className="flex min-h-screen items-center justify-center">
      <div className="p-8 bg-white dark:bg-slate-900 rounded-2xl shadow-xl">
        <h1 className="text-xl font-bold mb-4">เข้าสู่ระบบ Next.js</h1>
        <Login512Button
          publishableKey={process.env.NEXT_PUBLIC_LOGIN512_PK!}
          mode="auto"
          onSuccess={async (token) => {
            const res = await handleLoginAction(token);
            if (res.success) window.location.href = '/dashboard';
          }}
        />
      </div>
    </main>
  );
}
2. ตรวจสอบโทเคนและเซฟ Cookie ผ่าน Server Action (app/login/actions.ts)
TYPESCRIPT
'use server';

import { cookies } from 'next/headers';
import { verifyLogin512Token } from '@login512/nextjs/server';

export async function handleLoginAction(token: string) {
  const result = await verifyLogin512Token(token, {
    secretKey: process.env.LOGIN512_SECRET_KEY!,
  });

  if (!result.valid) {
    return { success: false, error: result.error };
  }

  // ออก Session Cookie HttpOnly อย่างปลอดภัย
  const cookieStore = await cookies();
  cookieStore.set('session_user_id', result.sub, {
    httpOnly: true,
    secure: process.env.NODE_ENV === 'production',
    sameSite: 'lax',
    maxAge: 60 * 60 * 24 * 7, // 7 วัน
  });

  return { success: true, userId: result.sub };
}
3. ป้องกันหน้าด้วย Next.js Middleware (middleware.ts)
TYPESCRIPT
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(req: NextRequest) {
  const session = req.cookies.get('session_user_id');
  if (!session && req.nextUrl.pathname.startsWith('/dashboard')) {
    return NextResponse.redirect(new URL('/login', req.url));
  }
  return NextResponse.next();
}

export const config = { matcher: ['/dashboard/:path*'] };
💚

Vue.js (Vue 3 + Vite)

Official Package (.tgz) • Vue 3 • Composition API • Vite / Pinia
Official SDK PQC Verified

คอมโพเนนต์ <Login512Auth> และ Composable function useLogin512() สำหรับ Vue 3 จัดการ State การสแกนหน้าและ Passkey แบบ Reactive 100%

ติดตั้ง: npm install @login512/vue
1. ลงทะเบียน Plugin ใน main.ts (หรือ Import Component ตรง)
TYPESCRIPT
import { createApp } from 'vue';
import App from './App.vue';
import { createLogin512 } from '@login512/vue';

const app = createApp(App);
app.use(createLogin512({
  publishableKey: 'l512_pk_live_your_key_here',
  locale: 'th'
}));
app.mount('#app');
2. เรียกใช้งาน <Login512Auth> ใน Single File Component (Login.vue)
VUE
<template>
  <div class="auth-card">
    <h2>เข้าสู่ระบบด้วย Vue 3</h2>
    <Login512Auth
      mode="auto"
      theme="dark"
      @success="onSuccess"
      @error="onError"
    />
  </div>
</template>

<script setup lang="ts">
import { Login512Auth } from '@login512/vue';

const onSuccess = async ({ token, user }: { token: string; user: any }) => {
  const res = await fetch('/api/login', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token })
  });
  const data = await res.json();
  if (data.ok) window.location.href = '/home';
};

const onError = (err: any) => {
  console.error('Login error:', err);
};
</script>
3. การใช้งาน useLogin512() แบบ Headless ไร้ UI
TYPESCRIPT
import { useLogin512 } from '@login512/vue';

// inside <script setup>: uses the options given to createLogin512()
const { authenticate, isScanning, error } = useLogin512();

async function handleCustomBtnClick() {
  const { token } = await authenticate({ mode: 'auto' });   // opens the real auth frame
  await fetch('/api/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) });
}
⚡

Nuxt 3 (SSR & Universal)

Official Package (.tgz) • Nuxt 3.x • Nitro Engine • SSR / Static
Official SDK PQC Verified

Official Nuxt 3 Module รองรับ Zero-Image Post-Quantum Biometrics, Auto-Import Composables และ Server Routes สำหรับจัดการ Session

ติดตั้ง: npm install @login512/nuxt
1. เปิดใช้งานโมดูลใน nuxt.config.ts
TYPESCRIPT
export default defineNuxtConfig({
  modules: ['@login512/nuxt'],
  login512: {
    publishableKey: process.env.LOGIN512_PUBLISHABLE_KEY || 'l512_pk_your_key',
    endpoint: 'https://login512.com'
  }
});
2. ใช้งานคอมโพเนนต์ในหน้าเพจ (pages/login.vue)
VUE
<template>
  <div class="login-container">
    <Login512Auth @success="handleAuthSuccess" @error="console.error" />
  </div>
</template>

<script setup>
// <Login512Auth> (alias of <Login512Button>) is client-only and reads login512 from nuxt.config
const handleAuthSuccess = async ({ token }) => {
  const res = await $fetch('/api/auth/verify', { method: 'POST', body: { token } });
  if (res.authenticated) await navigateTo('/dashboard');
};
// Headless: const { login } = useLogin512(); const { token } = await login();
</script>
3. ตรวจสอบโทเคนใน Server Route (server/api/auth/verify.post.ts)
TYPESCRIPT
// server/api/auth/verify.post.ts
export default defineEventHandler(async (event) => {
  const { token } = await readBody(event);
  const r = await fetch('https://api.login512.com/v1/token/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.LOGIN512_SECRET_KEY}` },
    body: JSON.stringify({ token }),
  });
  const v = await r.json();
  // HTTP 200 alone is NOT success: rejected tokens return 200 { valid: false, error: 'TOKEN_ALREADY_USED' | ... }
  const ok = v.valid === true && !v.step_up_required;   // v.claims.sub = the external_user_id you enrolled
  if (!ok) throw createError({ statusCode: 401, message: v.error || 'Invalid token' });

  setCookie(event, 'user_id', v.claims.sub, { httpOnly: true, sameSite: 'lax' });   // or your session library
  return { authenticated: true, user: v.claims.sub };
});
🔥

Svelte / SvelteKit (Svelte 4 & 5)

Official Package (.tgz) • Svelte 4 / 5 • SvelteKit Form Actions
Official SDK PQC Verified

Official Svelte component ที่เบาเป็นพิเศษ (Zero Bundle Overhead) รองรับ SvelteKit Endpoints และ Form Action handling

ติดตั้ง: npm install @login512/svelte
1. ใช้งานคอมโพเนนต์ <Login512Button /> ใน +page.svelte
SVELTE
<script lang="ts">
  import { Login512Button } from '@login512/svelte';
  import { goto } from '$app/navigation';

  async function handleSuccess(event: CustomEvent<{ token: string }>) {
    const res = await fetch('/api/auth/session', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ token: event.detail.token })
    });
    if (res.ok) goto('/dashboard');
  }

  function handleError(event: CustomEvent<{ message: string }>) {
    alert('ข้อผิดพลาด: ' + event.detail.message);
  }
</script>

<div class="auth-box">
  <h2>เข้าสู่ระบบด้วย Svelte</h2>
  <Login512Button
    publishableKey="l512_pk_live_your_key"
    on:success={handleSuccess}
    on:error={handleError}
  />
</div>
2. รับการยืนยันใน SvelteKit Endpoint (+server.ts)
TYPESCRIPT
// src/routes/api/auth/session/+server.ts
import { json } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
import type { RequestHandler } from './$types';

export const POST: RequestHandler = async ({ request, cookies }) => {
  const { token } = await request.json();
  const r = await fetch('https://api.login512.com/v1/token/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${env.LOGIN512_SECRET_KEY}` },
    body: JSON.stringify({ token }),
  });
  const v = await r.json();
  // HTTP 200 alone is NOT success: rejected tokens return 200 { valid: false, error }
  if (v.valid !== true || v.step_up_required) return json({ error: v.error }, { status: 401 });

  cookies.set('session', v.claims.sub, { path: '/', httpOnly: true });   // or your session library
  return json({ success: true });
};
3. รองรับ Svelte 5 Runes ($state & $effect)
SVELTE
<script>
  // Svelte 5 runes + the headless helper (no button component)
  import { login512Login } from '@login512/svelte';

  let loading = $state(false);

  async function scan() {
    loading = true;
    try {
      const { token } = await login512Login({ publishableKey: 'l512_pk_live_...', endpoint: 'https://api.login512.com' });
      await fetch('/api/auth/session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) });
    } finally {
      loading = false;
    }
  }
</script>

<button onclick={scan} disabled={loading}>{loading ? 'Scanning...' : 'Sign in with face / passkey'}</button>
🅰️

Angular (Angular 17 / 18 Signals)

Official Package (.tgz) • Angular 16+ • Standalone Components • Signals
Official SDK PQC Verified

Angular Standalone Component <login512-ng-button> และ Login512Service สำหรับ Angular Enterprise Architecture พร้อม RxJS Observables

ติดตั้ง: npm install @login512/angular
1. Import Standalone Component และ Service
TYPESCRIPT
import { Component, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { Login512ButtonComponent, Login512Result } from '@login512/angular';

@Component({
  selector: 'app-login',
  standalone: true,
  imports: [Login512ButtonComponent],
  template: `
    <login512-ng-button mode="auto" (success)="onLoginSuccess($event)" (error)="onLoginError($event)">
    </login512-ng-button>
  `,
})
export class LoginComponent {
  private http = inject(HttpClient);
  private router = inject(Router);

  onLoginSuccess(res: Login512Result) {
    // your backend verifies res.token with the SECRET key (POST /v1/token/verify)
    this.http.post('/api/auth/token', { token: res.token }).subscribe(() => this.router.navigate(['/dashboard']));
  }

  onLoginError(err: unknown) {
    console.error('Login512 error:', err);
  }
}
2. ตั้งค่า Provide ใน app.config.ts
TYPESCRIPT
import { ApplicationConfig } from '@angular/core';
import { provideLogin512 } from '@login512/angular';

export const appConfig: ApplicationConfig = {
  providers: [
    provideLogin512({
      publishableKey: 'l512_pk_live_your_key',
      locale: 'th'
    })
  ]
};
3. สร้าง Angular AuthGuard ป้องกัน Route
TYPESCRIPT
import { inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { CanActivateFn, Router } from '@angular/router';
import { firstValueFrom } from 'rxjs';
import { Login512Service } from '@login512/angular';

// Step-up guard: requires a fresh face scan / passkey before opening a sensitive route
export const stepUpGuard: CanActivateFn = async () => {
  const l512 = inject(Login512Service);
  const http = inject(HttpClient);
  const router = inject(Router);
  try {
    const { token } = await l512.login({ mode: 'auto' });
    await firstValueFrom(http.post('/api/auth/step-up', { token }));   // server verifies with the secret key
    return true;
  } catch {
    return router.parseUrl('/login');
  }
};
🌐

HTML5 Web Component (Custom Element)

CDN • <login512-card> • ทุกเบราว์เซอร์ • Vanilla JS • PHP • Blazor • HTMX
Official SDK PQC Verified

W3C Custom Element มาตรฐานสากล ทำงานได้กับทุกภาษาและเว็บเฟรมเวิร์ก เพียงใส่แท็ก <script> และ <login512-card> โดยไม่ต้องมี build tool

ติดตั้ง: <script src="https://login512.com/sdk/login512-sdk.js"></script>
1. เพิ่ม Script และ Stylesheet ในหน้า HTML
HTML
<!-- รวม SDK Client จาก CDN (ขนาดเพียง 12KB gzip) -->
<script src="https://login512.com/sdk/login512-sdk.js"></script>
<link rel="stylesheet" href="https://login512.com/sdk/login512-sdk.css">
2. วางแท็ก <login512-card> ในตำแหน่งที่ต้องการแสดงปุ่ม
HTML
<login512-card
  publishable-key="l512_pk_live_your_key_here"
  template="fintech"
  system-name="MyApplication"
  logo="https://yourapp.com/logo.png"
  id="loginCard">
</login512-card>
3. ดักฟัง Event 'l512:success' ด้วย JavaScript ทั่วไป
JAVASCRIPT
const card = document.getElementById('loginCard');

card.addEventListener('l512:success', async (event) => {
  const { token, user } = event.detail;
  console.log('สแกนสำเร็จ โทเคนชีวมิติ:', token);

  // ส่งโทเคนไปยังเซิร์ฟเวอร์ PHP / Node.js / ASP.NET
  const response = await fetch('/auth/callback.php', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ token: token })
  });
  
  if (response.ok) {
    window.location.href = '/member.php';
  }
});

card.addEventListener('l512:error', (event) => {
  console.error('เกิดข้อผิดพลาด:', event.detail.message);
});
🟢

Node.js (Express Middleware)

Official Package (.tgz) • Node.js 18+ • Express 4 / 5 • Middleware
Official SDK PQC Verified

Middleware สำหรับ Express.js ตรวจสอบโทเคนชีวมิติหลังควอนตัม (ML-DSA-65) จาก Header 'Authorization: Bearer <token>' อัตโนมัติ

ติดตั้ง: npm install @login512/express
1. Import Middleware และติดตั้งใน Express App
JAVASCRIPT
const express = require('express');
const { login512Auth } = require('@login512/express');

const app = express();
app.use(express.json());

// ป้องกัน API Route ด้วย Login512 Middleware
app.get('/api/protected/profile',
  login512Auth({ secretKey: process.env.LOGIN512_SECRET_KEY }),
  (req, res) => {
    // ข้อมูลผู้ใช้ที่ยืนยันตัวตนสำเร็จจะแนบมาใน req.login512User
    res.json({
      message: 'ยินดีต้อนรับเข้าสู่ระบบปลอดภัย',
      userId: req.userId,
      claims: req.login512User
    });
  }
);

app.listen(3000, () => console.log('Express Server รันบนพอร์ต 3000'));
2. Route สำหรับรับโทเคนจาก Frontend เพื่อสร้าง Session
JAVASCRIPT
const { Login512Client } = require('login512-server');
const l512 = new Login512Client(process.env.LOGIN512_SECRET_KEY);

app.post('/api/auth/session', async (req, res) => {
  const { token } = req.body;
  try {
    const verification = await l512.verifyToken(token);
    if (!verification.valid) {
      return res.status(401).json({ error: verification.error });
    }

    // สร้าง Session ID ให้กับ User: verification.claims.sub
    req.session.userId = verification.claims.sub;
    res.json({ success: true, user: verification.claims.sub });
  } catch (err) {
    res.status(500).json({ error: 'Verification failed' });
  }
});
3. โครงสร้าง Claims ที่ได้รับจากระบบชีวมิติ
JSON
{
  "valid": true,
  "claims": {
    "sub": "usr_8f93e120da9a",
    "tenant_id": "ten_default",
    "biometric_mode": "1n_face",
    "pqc_algorithm": "ML-DSA-65",
    "risk_score": 0.02,
    "exp": 1731456000
  }
}
🦁

NestJS (Module & Guard)

Official Package (.tgz) • NestJS 10+ • Guards & Decorators • TypeScript
Official SDK PQC Verified

Official NestJS Module และ Auth Guard (@UseGuards(Login512Guard)) พร้อม Custom Param Decorator @CurrentUser() ดึงข้อมูลชีวมิติได้ทันที

ติดตั้ง: npm install @login512/nestjs
1. Import Login512Module ใน AppModule
TYPESCRIPT
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { Login512Module } from '@login512/nestjs';

@Module({
  imports: [
    ConfigModule.forRoot(),
    Login512Module.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        secretKey: config.get<string>('LOGIN512_SECRET_KEY')!,
      }),
    }),
  ],
})
export class AppModule {}
2. ปกป้อง Controller หรือ Endpoint ด้วย @UseGuards(Login512Guard)
TYPESCRIPT
import { Controller, Get, UseGuards } from '@nestjs/common';
import { Login512Guard, CurrentUser } from '@login512/nestjs';

@Controller('users')
export class UserController {
  @Get('profile')
  @UseGuards(Login512Guard)
  getProfile(@CurrentUser() user: any) {
    return {
      status: 'authenticated',
      userId: user.sub,
      authMode: user.biometric_mode,
      pqc: user.pqc_algorithm,
    };
  }
}
3. ตรวจสอบสิทธิ์แบบ Role-Based และ Risk Score
TYPESCRIPT
@Get('high-value-transfer')
@UseGuards(Login512Guard)
transfer(@CurrentUser() user: any) {
  // ตรวจสอบว่ายืนยันด้วย 1:N Biometric Liveness ระดับสูงสุด
  if (user.risk_score > 0.05) {
    throw new ForbiddenException('ความเสี่ยงสูงเกินกำหนด กรุณาสแกนใบหน้าใหม่อีกครั้ง');
  }
  return { approved: true };
}
⚡

Fastify (High Performance Plugin)

Official Package (.tgz) • Fastify 4 / 5 • Plugin • Ultra Low Latency
Official SDK PQC Verified

Fastify Plugin ที่เน้นความเร็วสูงสุด รองรับ preHandler hook ตรวจสอบโทเคนระดับ Microsecond สำหรับระบบ High Throughput

ติดตั้ง: npm install @login512/fastify
1. ลงทะเบียน Plugin ใน Fastify Instance
JAVASCRIPT
const fastify = require('fastify')({ logger: true });
const login512 = require('@login512/fastify');

fastify.register(login512, {
  secretKey: process.env.LOGIN512_SECRET_KEY
});
2. ป้องกัน Route ด้วย preHandler Hook
JAVASCRIPT
fastify.get('/api/secure-data', {
  preHandler: [fastify.verifyLogin512]
}, async (request, reply) => {
  return {
    success: true,
    user: request.login512User,
    userId: request.userId
  };
});

fastify.listen({ port: 3000 }, (err) => {
  if (err) throw err;
  console.log('Fastify เซิร์ฟเวอร์พร้อมทำงาน');
});
3. Endpoint ตรวจสอบโทเคนตรง (Direct Verification)
JAVASCRIPT
fastify.post('/auth/verify', async (req, reply) => {
  const result = await fastify.login512.verify(req.body.token);
  if (!result.valid) {
    return reply.status(401).send({ error: result.error });
  }
  return { valid: true, userId: result.claims.sub };
});
🐍

Python FastAPI (Bearer Dependency)

Official Package (.tar.gz) • Python 3.9+ • FastAPI 0.100+ • Async Dependency
Official SDK PQC Verified

FastAPI Security Dependency ที่ใช้งานร่วมกับ Depends(Login512Bearer()) พร้อม OpenAPI / Swagger UI Authorize Support ในตัว

ติดตั้ง: pip install login512-fastapi
1. ติดตั้ง Dependency และประกาศตัวแปร Security Guard
PYTHON
import os
from fastapi import FastAPI, Depends, HTTPException, status
from login512_fastapi import Login512Bearer

app = FastAPI(title="Secure API with Login512")

# กำหนด Security Guard ด้วย Secret Key
auth_guard = Login512Bearer(secret_key=os.environ.get("LOGIN512_SECRET_KEY"))
2. ปกป้อง Endpoint ด้วย Depends(auth_guard)
PYTHON
@app.get("/api/user/profile")
async def get_user_profile(user_claims: dict = Depends(auth_guard)):
    return {
        "status": "authenticated",
        "user_id": user_claims.get("sub"),
        "biometric_mode": user_claims.get("biometric_mode"),
        "pqc_algorithm": user_claims.get("pqc_algorithm"),
        "risk_score": user_claims.get("risk_score")
    }
3. Endpoint สำหรับแลกโทเคนชีวมิติเป็น Custom JWT
PYTHON
from pydantic import BaseModel
from login512_fastapi import verify_token

class TokenExchangeRequest(BaseModel):
    token: str

@app.post("/api/auth/exchange")
async def exchange_token(payload: TokenExchangeRequest):
    result = await verify_token(payload.token, secret_key=os.environ["LOGIN512_SECRET_KEY"])
    if not result.get("valid"):
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid biometric token")
    
    user_id = result["claims"]["sub"]
    # สร้าง App JWT ของระบบท่านเอง
    return {"access_token": f"jwt_for_{user_id}", "token_type": "bearer"}
🎸

Python Django (Auth Backend)

Official Package (.tar.gz) • Python 3.10+ • Django 4.2 / 5.0 • Auth Backend
Official SDK PQC Verified

Authentication Backend สำหรับ Django เชื่อมโยง User Model อัตโนมัติ รองรับทั้ง Django Admin Login และ REST API Views

ติดตั้ง: pip install django-login512
1. เพิ่ม Backend ใน settings.py
PYTHON
# settings.py
INSTALLED_APPS += ['login512_django']

AUTHENTICATION_BACKENDS = [
    'login512_django.backend.Login512AuthBackend',
    'django.contrib.auth.backends.ModelBackend',
]

LOGIN512_SECRET_KEY = os.getenv("LOGIN512_SECRET_KEY")
LOGIN512_ENDPOINT = "https://login512.com" 
2. View ฟังก์ชันสำหรับประมวลผลการเข้าสู่ระบบ
PYTHON
# urls.py: login view (POST token -> Django session) and nonce view are included in the package
from django.urls import include, path

urlpatterns = [
    path("login512/", include("login512_django.urls")),
]

# Frontend (any Login512 button), after onSuccess(token):
#   const { nonce } = await (await fetch('/login512/nonce/')).json()   // optional, pass it to the button
#   await fetch('/login512/login/', { method: 'POST', body: JSON.stringify({ token }),
#               headers: { 'Content-Type': 'application/json', 'X-CSRFToken': csrftoken } })
# -> 200 {"ok": true, "redirect": "..."} with a Django session, or 401 {"ok": false, "error": "TOKEN_ALREADY_USED"}

# In your own view: user = authenticate(request, login512_token=token)
3. ใช้งานใน Django REST Framework (DRF)
PYTHON
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

class SecureProfileView(APIView):
    # the session was created by POST /login512/login/
    authentication_classes = [SessionAuthentication]
    permission_classes = [IsAuthenticated]

    def get(self, request):
        return Response({'user_id': request.user.username, 'pqc': 'ML-DSA-65'})
🧪

Python Flask (Extension & Decorator)

Official Package (.tar.gz) • Python 3.9+ • Flask 2.x / 3.x • Extension & Decorator
Official SDK PQC Verified

Flask Extension พร้อม @login512_required decorator และ g.login512_user object ดึงข้อมูลสิทธิ์และสถานะชีวมิติได้ง่ายดาย

ติดตั้ง: pip install Flask-Login512
1. กำหนดค่าใน Flask Application
PYTHON
from flask import Flask, jsonify, g
from flask_login512 import Login512, login512_required

app = Flask(__name__)
app.config["LOGIN512_SECRET_KEY"] = "l512_sk_live_your_secret_key"

l512 = Login512(app)
2. ปกป้อง Endpoint ด้วย @login512_required
PYTHON
@app.route("/api/dashboard/stats")
@login512_required
def dashboard_stats():
    # ข้อมูล User ถูกผูกไว้กับ flask.g โดยอัตโนมัติ
    user = g.login512_user
    return jsonify({
        "status": "ok",
        "user_id": user["sub"],
        "algorithm": user["pqc_algorithm"]
    })

if __name__ == "__main__":
    app.run(port=5000)
3. ฟังก์ชันตรวจสอบโทเคนแบบ Manual
PYTHON
@app.route("/api/verify-manual", methods=["POST"])
def verify_manual():
    token = request.json.get("token")
    result = l512.verify(token)
    if result.is_valid:
        return jsonify({"valid": True, "subject": result.subject})
    return jsonify({"error": result.error_message}), 401
🐘

PHP & Laravel (Facade & Middleware)

Direct Service Provider (PHP) • Laravel 9 / 10 / 11 • PHP 8.1+ • 1-Line Setup
Official SDK PQC Verified

Laravel Package พร้อม Facade Login512::verifyToken() และ Middleware 'login512.verified' เชื่อมต่อ Eloquent User Model ทันที

⚡ เลือกลักษณะการติดตั้งใน Laravel ของคุณ (3 ทางเลือก):
วิธีที่ 1 (แนะนำ - ง่ายและเร็วที่สุด ไม่ต้องใช้ Composer): Drop-in Service File
curl -s https://login512.com/sdk/php/Login512.php -o app/Services/Login512.php
ดาวน์โหลดคลาส Pure PHP ไฟล์เดียวจบวางในโปรเจกต์ เรียกใช้ require_once app_path('Services/Login512.php'); \Login512\Login512::verifyToken() ได้ทันที ไม่ต้องรอ Packagist
วิธีที่ 2 (ครบเซ็ต Facade + Config + Blade): โหลด Package ZIP ดาวน์โหลด .ZIP (7.4KB)
1. แตกไฟล์ ZIP ไว้ที่ packages/login512-laravel/ ในโปรเจกต์
2. เพิ่มใน composer.json ของ Laravel: "repositories": [{"type": "path", "url": "packages/login512-laravel"}]
3. สั่งติดตั้งผ่าน Composer:
composer require login512/login512-laravel:* php artisan vendor:publish --tag=login512-config
ℹ️ ติดตั้งจาก Packagist ได้แล้ว: composer require login512/login512-laravel บรรทัดเดียวได้ครบทั้ง Facade และ Config
1. กำหนดค่าในไฟล์ .env
ENV
LOGIN512_PUBLISHABLE_KEY=l512_pk_live_your_key
LOGIN512_SECRET_KEY=l512_sk_live_your_secret_key
LOGIN512_ENDPOINT=https://login512.com
2. จัดการ Login ใน Controller (AuthController.php)
PHP
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Login512\Laravel\Facades\Login512;
use App\Models\User;
use Illuminate\Support\Facades\Auth;

class AuthController extends Controller
{
    public function verify(Request $request)
    {
        $token = $request->input('token');
        $res = Login512::verifyToken($token);

        // session_allowed, not valid: a valid token can still require a step-up
        if (empty($res['session_allowed'])) {
            return response()->json(['error' => $res['error'] ?? 'STEP_UP_REQUIRED'], 401);
        }

        // ค้นหาหรือสร้าง User จากรหัสชีวมิติ sub
        $user = User::firstOrCreate(
            ['login512_id' => $res['claims']['sub']],
            ['name' => 'Biometric User', 'email' => $res['claims']['sub'] . '@login512.me']
        );

        Auth::login($user);
        return response()->json(['success' => true, 'redirect' => route('dashboard')]);
    }
}
3. ป้องกัน Route ใน routes/api.php
PHP
use Illuminate\Support\Facades\Route;

// login512.verified needs a FRESH single-use token (header X-Login512-Token) on every request: use it for sensitive actions
Route::middleware(['auth:sanctum', 'login512.verified'])->group(function () {
    Route::post('/vip/vault/export', function () {
        return response()->json(['vault' => 'Secure PQC Data']);
    });
});
🎼

PHP Symfony (Security Authenticator)

Official Package (.zip) • Symfony 6.4 / 7.x • PHP 8.1+
Official SDK PQC Verified

Symfony Security Bundle Authenticator ทำงานร่วมกับระบบ Security Firewall และ UserProvider ของ Symfony ตามมาตรฐาน PSR

ติดตั้ง: composer require login512/login512-symfony-bundle
1. กำหนดค่าใน config/packages/security.yaml
YAML
# .env.local
#   LOGIN512_SECRET_KEY=l512_sk_live_your_secret
#   LOGIN512_PUBLISHABLE_KEY=l512_pk_live_your_key

# config/routes/login512.yaml  (GET /login512/nonce, POST /login512/verify)
login512:
    resource: '@Login512SymfonyBundle/config/routes.php'

# config/packages/security.yaml
security:
    providers:
        login512:
            id: Login512\SymfonyBundle\Security\Login512UserProvider
    firewalls:
        main:
            lazy: true
            provider: login512
            custom_authenticators:
                - Login512\SymfonyBundle\Security\Login512Authenticator
    access_control:
        - { path: ^/account, roles: ROLE_USER }

# Login page: the nonce stops login CSRF; POST /login512/verify starts the Symfony session.
#   const cfg = await (await fetch('/login512/nonce', { credentials: 'same-origin' })).json();
#   Login512.init({ publishableKey: cfg.publishableKey, endpoint: cfg.endpoint }).mountButton('#login512', {
#     nonce: cfg.nonce,
#     onSuccess: async (token) => {
#       const r = await fetch(cfg.verifyUrl, { method: 'POST', credentials: 'same-origin',
#         headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) });
#       const res = await r.json();   // 200 {ok, user, redirect} | 401 {ok: false, error}
#       if (res.ok) location.href = res.redirect;
#     },
#   });
# The user is a Login512User (identifier = claims.sub, ROLE_USER). To log in your own user class,
# set login512.user_mapper to a Login512UserMapperInterface service (match a login512_sub column, never username/email).
2. เรียกใช้งาน Login512Client ใน Controller
PHP
namespace App\Controller;

use Login512\SymfonyBundle\Login512Client;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;

class SecurityController extends AbstractController
{
    #[Route('/api/verify-token', methods: ['POST'])]
    public function verify(Request $request, Login512Client $login512): JsonResponse
    {
        $res = $login512->verifyToken((string) $request->toArray()['token']); // 2nd argument: expected nonce

        // session_allowed, not valid: a valid token can still require a step-up. Tokens are single-use.
        if (empty($res['session_allowed'])) {
            return new JsonResponse(['error' => $res['error'] ?? 'STEP_UP_REQUIRED'], 401);
        }
        return new JsonResponse(['sub' => $res['claims']['sub']]);
    }
}
3. การใช้งาน Standalone PHP ทั่วไป (No Framework)
PHP
require_once __DIR__ . '/Login512.php'; // curl -s https://login512.com/sdk/php/Login512.php -o Login512.php

use Login512\Login512;

$result = Login512::verifyToken('l512_sk_live_your_secret', $_POST['token']);

if ($result['session_allowed']) {
    $_SESSION['user_id'] = $result['claims']['sub'];
    header('Location: /dashboard.php');
} else {
    die('การสแกนไม่ถูกต้อง: ' . $result['error']);
}
☕

Java & Spring Boot (Starter & Security)

Official ZIP Package • Spring Boot 3.x • Java 17 / 21 • Spring Security
Official SDK PQC Verified

Official Spring Boot Starter พร้อม Auto-configuration, Login512Client Bean และ Spring Security AuthenticationFilter

ติดตั้ง: curl -s https://login512.com/packages/spring-boot.zip -o spring-boot.zip
1. กำหนดค่าใน application.yml
YAML
# application.yml
login512:
  secret-key: ${LOGIN512_SECRET_KEY}
  endpoint: https://api.login512.com
2. Inject Login512Client ใน RestController
JAVA
package com.example.demo.controller;

import com.login512.spring.Login512Client;
import com.login512.spring.Login512VerifyResult;
import jakarta.servlet.http.HttpSession;
import java.util.Map;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class AuthController {
    private final Login512Client login512;   // auto-configured by login512-spring-boot-starter

    public AuthController(Login512Client login512) { this.login512 = login512; }

    @PostMapping("/verify")
    public ResponseEntity<?> verify(@RequestBody Map<String, String> body, HttpSession session) {
        // nonce your server issued for this login (optional); never taken from the client
        Login512VerifyResult r = login512.verify(body.get("token"), (String) session.getAttribute("login512_nonce"));
        if (!r.sessionAllowed()) {
            return ResponseEntity.status(401).body(Map.of("error", r.error()));   // TOKEN_ALREADY_USED, ...
        }
        session.setAttribute("userId", r.subject());   // claims.sub = your external_user_id
        return ResponseEntity.ok(Map.of("success", true, "userId", r.subject()));
    }
}
3. เชื่อมต่อ Spring Security SecurityFilterChain
JAVA
# Build and install the starter once (until it is on Maven Central)
unzip spring-boot.zip -d login512-starter
mvn -f login512-starter/pom.xml install

# pom.xml of your app
<dependency>
  <groupId>com.login512</groupId>
  <artifactId>login512-spring-boot-starter</artifactId>
  <version>2.1.1</version>
</dependency>
⚡

Java Quarkus (GraalVM Native)

Official ZIP Package • Quarkus 3.x • GraalVM Native • SmallRye JWT
Official SDK PQC Verified

Extension สำหรับ Quarkus ออกแบบมาเพื่อ GraalVM Native Image เริ่มทำงานในเสี้ยววินาที (Cold start <15ms) สำหรับ Cloud-Native และ Kubernetes

ติดตั้ง: curl -s https://login512.com/packages/quarkus.zip -o quarkus.zip
1. กำหนดค่าใน src/main/resources/application.properties
PROPERTIES
quarkus.login512.secret-key=l512_sk_live_your_secret_key
quarkus.login512.endpoint=https://login512.com
2. เรียกใช้งานผ่าน CDI @Inject ใน JAX-RS Resource
JAVA
package com.example.resource;

import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import com.login512.quarkus.Login512SecurityProvider;

@Path("/quarkus/auth")
@Produces(MediaType.APPLICATION_JSON)
public class QuarkusAuthResource {

    @Inject
    Login512SecurityProvider provider;

    @POST
    @Path("/verify")
    public Response verify(@HeaderParam("Authorization") String authHeader) {
        var result = provider.verifyBearer(authHeader);
        if (result.isValid()) {
            return Response.ok(result.getClaims()).build();
        }
        return Response.status(401).entity("Invalid Biometric Token").build();
    }
}
3. คอมไพล์เป็น GraalVM Native Image
BASH
# Build Linux Native Binary (0.012s Startup Time)
./mvnw package -Dnative -Dquarkus.native.container-build=true
🐹

Go (Golang SDK)

Official ZIP Package • Go 1.20+ • Gin / Fiber / Chi / Echo • Zero Allocations
Official SDK PQC Verified

Official Go Client รองรับ Context Cancellation, Connection Pooling, Chi/Gin/Fiber Middleware และการตรวจสอบโทเคนความเร็วสูง

ติดตั้ง: curl -s https://login512.com/packages/go.zip -o login512-go.zip
1. สร้าง Client และตรวจสอบโทเคน
GO
package main

import (
	"context"
	"fmt"
	"log"
	"net/http"

	"github.com/login512/login512-go" // แตก zip แล้วใส่ replace ใน go.mod: replace github.com/login512/login512-go => ./login512-go
)

func main() {
	client, err := login512.NewClient("l512_sk_live_your_secret_key")
	if err != nil {
		log.Fatalf("เกิดข้อผิดพลาดในการสร้าง client: %v", err)
	}

	http.HandleFunc("/api/verify", func(w http.ResponseWriter, r *http.Request) {
		token := r.URL.Query().Get("token")
		result, err := client.VerifyToken(context.Background(), token, "")
		if err != nil {
			http.Error(w, "เซิร์ฟเวอร์ขัดข้อง", http.StatusInternalServerError)
			return
		}

		if !result.Valid || !result.SessionAllowed {
			http.Error(w, result.Error, http.StatusUnauthorized)
			return
		}

		fmt.Fprintf(w, "ยืนยันสำเร็จ! User ID: %s, Algorithm: %s",
			result.Claims.Subject, "ML-DSA-65")
	})

	log.Println("Go Server เริ่มทำงานที่พอร์ต 8080")
	http.ListenAndServe(":8080", nil)
}
2. การใช้งาน Gin Middleware
GO
func Login512GinMiddleware(client *login512.Client) gin.HandlerFunc {
	return func(c *gin.Context) {
		token := strings.TrimPrefix(c.GetHeader("Authorization"), "Bearer ")
		res, err := client.VerifyToken(c.Request.Context(), token, "")
		if err != nil || !res.Valid {
			c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
			return
		}
		c.Set("user_id", res.Claims.Subject)
		c.Next()
	}
}
3. ตรวจสอบ ML-DSA-65 Algorithm แบบ Native
GO
// Tokens are always signed with ML-DSA-65; the API verifies the signature.
// What your code must check is that this login may start a session:
if !result.Valid || !result.SessionAllowed {
    log.Println("คำเตือน: โทเคนไม่ได้เข้ารหัสด้วยอัลกอริทึมมาตรฐาน Post-Quantum")
}
🦀

Rust (Async Tokio & Axum)

Official ZIP Package • Rust 2021 Edition • Tokio Async • Axum / Actix-web
Official SDK PQC Verified

High-performance, memory-safe Rust SDK รองรับ Async HTTP client (reqwest), Axum State Extractor และ Zero-Copy Deserialization

ติดตั้ง: curl -s https://login512.com/packages/rust.zip -o login512-rs.zip
1. กำหนด Dependencies ใน Cargo.toml
TOML
# แตกไฟล์ login512-rs.zip เข้าสู่โปรเจกต์
# ใน Cargo.toml เชื่อมต่อ Local Crate:
[dependencies]
login512 = { path = "./login512-rs" }
tokio = { version = "1.0", features = ["full"] }
axum = "0.7"
serde_json = "1.0"
2. ตัวอย่างการเขียน Axum Route Handler
RUST
use axum::{
    extract::State,
    http::{HeaderMap, StatusCode},
    response::Json,
    routing::get,
    Router,
};
use login512::Login512Client;
use serde_json::{json, Value};
use std::sync::Arc;

async fn protected_handler(
    State(client): State<Arc<Login512Client>>,
    headers: HeaderMap,
) -> Result<Json<Value>, StatusCode> {
    let auth_header = headers.get("authorization")
        .and_then(|v| v.to_str().ok())
        .and_then(|s| s.strip_prefix("Bearer "))
        .ok_or(StatusCode::UNAUTHORIZED)?;

    let result = client.verify_token(auth_header).await
        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;

    if !result.valid {
        return Err(StatusCode::UNAUTHORIZED);
    }

    Ok(Json(json!({
        "status": "authenticated",
        "user_id": result.user_id,
        "auth_mode": result.auth_mode
    })))
}
3. เริ่มต้นรันเซิร์ฟเวอร์
RUST
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Arc::new(Login512Client::new("l512_sk_live_your_key")?);
    let app = Router::new()
        .route("/api/profile", get(protected_handler))
        .with_state(client);

    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
    axum::serve(listener, app).await?;
    Ok(())
}
🔷

C# & .NET Core (.NET 8 / ASP.NET)

Official ZIP Package • .NET 8.0 / 9.0 • ASP.NET Core Web API • C#
Official SDK PQC Verified

Official ASP.NET Core Authentication Handler รองรับ AddAuthentication("Login512") และ RequireAuthorization() ตามมาตรฐาน Microsoft Identity

ติดตั้ง: curl -s https://login512.com/packages/dotnet.zip -o login512-dotnet.zip
1. ลงทะเบียน Authentication Handler ใน Program.cs
CSHARP
using Login512;
using System.Security.Claims;

var builder = WebApplication.CreateBuilder(args);

// เพิ่ม Login512 Post-Quantum Authentication Scheme
builder.Services.AddAuthentication("Login512")
    .AddScheme<Login512AuthenticationOptions, Login512AuthenticationHandler>("Login512", opt =>
    {
        opt.SecretKey = builder.Configuration["Login512:SecretKey"] ?? "l512_sk_live_your_key";
        opt.Endpoint = "https://login512.com";
    });

builder.Services.AddAuthorization();
var app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();
2. สร้าง Endpoint ที่ต้องการสิทธิ์ (Minimal API)
CSHARP
app.MapGet("/api/profile", (ClaimsPrincipal user) =>
{
    var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
    var authMode = user.FindFirstValue("login512_mode");
    var pqc = user.FindFirstValue("pqc_algorithm");

    return Results.Ok(new {
        Status = "Success",
        UserId = userId,
        AuthMode = authMode,
        PqcAlgorithm = pqc
    });
}).RequireAuthorization();

app.Run();
3. การตรวจสอบโทเคนแบบ Direct Client (Background Worker)
CSHARP
var client = new Login512Client("l512_sk_live_your_key");
var res = await client.VerifyTokenAsync(incomingToken);

if (res.Valid) {
    Console.WriteLine($"ยืนยันสำเร็จสำหรับ User: {res.UserId}");
}
💎

Ruby on Rails (Gem & Initializer)

Official ZIP Package • Rails 7 / 8 • Ruby 3.1+ • Devise & Warden Ready
Official SDK PQC Verified

Ruby Gem พร้อม Rails Initializer และ Controller Concern สำหรับตรวจสอบโทเคนและเชื่อมต่อ User Session ของ Rails

ติดตั้ง: curl -s https://login512.com/packages/ruby-rails.zip -o login512-rails.zip
1. สร้าง Initializer (config/initializers/login512.rb)
RUBY
Login512.configure do |config|
  config.secret_key = ENV.fetch("LOGIN512_SECRET_KEY", "l512_sk_live_your_key")
  config.endpoint   = "https://login512.com"
end
2. สร้าง SessionsController สำหรับรับ Callback
RUBY
class SessionsController < ApplicationController
  skip_before_action :verify_authenticity_token, only: [:login512_callback]

  def login512_callback
    result = Login512.client.verify_token(params[:token])

    if result[:valid]
      user = User.find_or_create_by!(biometric_sub: result[:user_id])
      session[:user_id] = user.id
      render json: { success: true, redirect_to: dashboard_path }
    else
      render json: { error: result[:error] }, status: :unauthorized
    end
  end
end
3. เชื่อมต่อ Route ใน config/routes.rb
RUBY
Rails.application.routes.draw do
  post '/auth/login512/callback', to: 'sessions#login512_callback'
  get  '/dashboard', to: 'dashboard#index'
end
💙

Flutter (iOS & Android Plugin)

Official ZIP Package • Flutter 3.x • Dart 3 • iOS 14+ • Android 8+
Official SDK PQC Verified

แพ็กเกจ Flutter: Login512LoginView แสดงหน้าสแกนจริงของ Login512 ใน webview_flutter แล้วคืนโทเคนให้เซิร์ฟเวอร์ของคุณตรวจสอบ

ติดตั้ง: curl -s https://login512.com/packages/flutter.zip -o login512_flutter.zip
1. เพิ่ม Dependency ใน pubspec.yaml
YAML
# unzip flutter.zip -> ./login512_flutter
dependencies:
  flutter:
    sdk: flutter
  login512_flutter:
    path: ./login512_flutter
2. เปิดหน้า login แล้วส่งโทเคนไปที่เซิร์ฟเวอร์ของคุณ
DART
import 'package:flutter/material.dart';
import 'package:login512_flutter/login512_flutter.dart';

Future<void> signIn(BuildContext context, String nonceFromYourServer) async {
  final r = await Login512LoginView.login(context,
      publishableKey: 'l512_pk_live_...',
      appOrigin: 'https://app.example.com',   // http(s) origin registered in your tenant
      nonce: nonceFromYourServer);
  if (r.token != null) {
    // POST r.token to YOUR server; it verifies the token with the secret key
  } else {
    debugPrint('Login512: ${r.error}');      // e.g. CANCELLED
  }
}
3. กำหนด Permission ใน Android & iOS
XML
<!-- Android: android/app/src/main/AndroidManifest.xml -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

<!-- iOS: ios/Runner/Info.plist -->
<key>NSCameraUsageDescription</key>
<string>Used to scan your face to sign in</string>
📱

React Native & Expo

Official Package (.tgz) • React Native 0.72+ • Expo SDK 50+ • iOS & Android
Official SDK PQC Verified

React Native / Expo: คอมโพเนนต์ Login512Login แสดงหน้าสแกนจริงใน react-native-webview แล้วคืนโทเคนให้เซิร์ฟเวอร์ของคุณตรวจสอบ

ติดตั้ง: npm install https://login512.com/packages/react-native.tgz
1. Import คอมโพเนนต์ใน App.tsx
TSX
import { Login512Login } from '@login512/react-native';

export default function LoginScreen({ nonce }) {
  return (
    <Login512Login
      publishableKey="l512_pk_live_..."
      appOrigin="https://app.example.com"   // http(s) origin registered in your tenant
      mode="1:N"
      nonce={nonce}                         // issued by YOUR server
      onSuccess={async ({ token }) => {
        await fetch('https://api.example.com/login512', { method: 'POST', body: JSON.stringify({ token }) });
      }}
      onError={({ code }) => console.warn('Login512', code)}
    />
  );
}
2. สิทธิ์กล้องใน app.json (Expo)
JSON
{
  "expo": {
    "ios": { "infoPlist": { "NSCameraUsageDescription": "Used to scan your face to sign in" } },
    "android": { "permissions": ["CAMERA"] }
  }
}
3. ทดสอบการทำงาน
BASH
npx expo install react-native-webview
npm install https://login512.com/packages/react-native.tgz
npx expo run:ios   # or run:android (camera needs a real device)
🍎

iOS Native (Swift & SwiftUI)

Official ZIP Package • iOS 15.0+ • Swift 5.9+ • Xcode 15+ • SwiftUI & UIKit
Official SDK PQC Verified

Swift Package (iOS 15+): Login512LoginViewController / SwiftUI Login512LoginView แสดงหน้าสแกนจริงใน WKWebView แล้วคืนโทเคนให้เซิร์ฟเวอร์ของคุณ

ติดตั้ง: curl -s https://login512.com/packages/ios.zip -o Login512Kit.zip
1. ติดตั้ง Package ผ่าน Xcode SPM
SWIFT
// 1. Unzip ios.zip (folder Login512)
// 2. Xcode > File > Add Package Dependencies... > Add Local... > select the Login512 folder
// 3. Add the "Login512" library to your app target, then:
import Login512
2. เรียกใช้งานใน SwiftUI View (ContentView.swift)
SWIFT
import SwiftUI
import Login512

struct LoginView: View {
    @State private var show = true
    var body: some View {
        if show {
            Login512LoginView(options: {
                var o = Login512LoginViewController.Options(publishableKey: "l512_pk_live_...")
                o.appOrigin = "https://app.example.com"   // http(s) origin registered in your tenant
                return o
            }()) { result in
                show = false
                if case .success(let token) = result { /* POST token to YOUR server */ }
            }
        }
    }
}
3. เพิ่ม Camera Usage Description ใน Info.plist
XML
<key>NSCameraUsageDescription</key>
<string>Used to scan your face to sign in</string>
🤖

Android Native (Kotlin & Compose)

Official ZIP Package • Android API 26+ • Kotlin 1.9+ • Jetpack Compose
Official SDK PQC Verified

ไลบรารี Android (AAR): Login512LoginActivity แสดงหน้าสแกนจริงใน WebView (จัดการสิทธิ์กล้องให้) แล้วคืนโทเคนผ่าน Login512Contract

ติดตั้ง: curl -s https://login512.com/packages/android.zip -o login512-android.zip
1. เพิ่ม Dependency ใน app/build.gradle.kts
KOTLIN
// unzip android.zip and copy login512-android-2.1.1.aar to app/libs/
dependencies {
    implementation(files("libs/login512-android-2.1.1.aar"))
    implementation("androidx.activity:activity-ktx:1.9.3")
}
2. เริ่ม login จาก Activity (Login512Contract)
KOTLIN
import com.login512.android.Login512Contract

class LoginActivity : ComponentActivity() {
    private val login512 = registerForActivityResult(Login512Contract()) { r ->
        if (r.token != null) sendToServer(r.token)   // YOUR server verifies it with the secret key
        else Log.w("Login512", r.error ?: "CANCELLED")
    }

    fun startLogin(nonceFromYourServer: String) = login512.launch(
        Login512Contract.Input(
            publishableKey = "l512_pk_live_...",
            appOrigin = "https://app.example.com",   // http(s) origin registered in your tenant
            nonce = nonceFromYourServer,
        )
    )
}
3. สิทธิ์การใช้งานใน AndroidManifest.xml
XML
<!-- merged from the AAR; listed for clarity -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
🌐

WordPress & WooCommerce Plugin

Official WP Plugin ZIP • WordPress 6.0+ • WooCommerce 7.0+ • 1-Click Face Login
Official SDK PQC Verified

ปลั๊กอินอย่างเป็นทางการสำหรับ WordPress เปลี่ยนหน้า wp-login.php และขั้นตอน Checkout ของ WooCommerce ให้ล็อกอินด้วยใบหน้าหรือ Passkey ในคลิกเดียว

ติดตั้ง: wp plugin install https://login512.com/packages/wordpress.zip --activate
1. การติดตั้งปลั๊กอิน (Plugin Installation)
BASH
# วิธีที่ 1: อัปโหลดผ่าน WordPress Dashboard
1. ไปที่ Plugins (ปลั๊กอิน) -> Add New (เพิ่มปลั๊กอินใหม่) -> Upload Plugin
2. เลือกไฟล์ wordpress.zip ที่ดาวน์โหลดมา แล้วกด Install Now และกด Activate

# วิธีที่ 2: ติดตั้งผ่าน WP-CLI
wp plugin install https://login512.com/packages/wordpress.zip --activate
2. ตั้งค่า API Keys ในหน้า Settings -> Login512
TEXT
1. ไปที่เมนู Settings -> Login512 ในหน้าผู้ดูแลระบบ
2. กรอก Publishable Key และ Secret Key จาก Dashboard
3. ติ๊กเปิดใช้งาน:
   [✓] เปิดใช้ปุ่มสแกนชีวมิติในหน้า wp-login.php
   [✓] เปิดใช้ปุ่ม One-Click Biometric ในหน้า WooCommerce Checkout
4. กดบันทึก (Save Changes)
3. แทรกปุ่มสแกนชีวมิติด้วย Shortcode ใน Elementor / Gutenberg
HTML
<!-- แทรก Shortcode ในหน้าเพจ หรือวิดเจ็ตใดก็ได้ -->
[login512_button template="shop" text="เข้าสู่ระบบด้วยใบหน้า"]
🛍️

Shopify App & Checkout Extension

Official Extension ZIP • Shopify Hydrogen & Liquid Theme • Customer API
Official SDK PQC Verified

Shopify App และ Checkout UI Extension รองรับการชำระเงินด้วย Passkey & Biometric สแกนใบหน้าสั่งซื้อได้ทันที ลดปัญหาสินค้าค้างตะกร้า (Cart Abandonment)

ติดตั้ง: curl -s https://login512.com/packages/shopify.zip -o login512-shopify.zip
1. ติดตั้งแอปจาก Shopify App Store หรือ Deploy เอง
BASH
cd plugins/shopify
shopify app deploy
2. เปิดใช้งานใน Shopify Theme Editor
TEXT
1. เปิด Shopify Store Admin -> Online Store -> Themes
2. กด Customize (ปรับแต่งธีม)
3. ไปที่แท็บ App Embeds (การฝังแอป) ด้านซ้าย
4. สลับเปิดสวิตช์ "Login512 Passkey & Biometric Login"
5. กรอก Publishable Key และกด Save
3. ลูกค้าใช้งานผ่าน Touch ID / Face ID / FaceScan
HTML
<!-- ปุ่มจะแสดงขึ้นอัตโนมัติในหน้า Customer Login และ Checkout -->
<div id="shopify-login512-biometric-button"></div>
🚀

Strapi Headless CMS Plugin

Official Package (.tgz) • Strapi 5 • REST API (Users-Permissions)
Official SDK PQC Verified

Official Strapi Plugin สำหรับระบบ Headless CMS เพิ่มการเข้าสู่ระบบด้วย Login512 ให้ผู้ใช้ของ Users-Permissions Plugin (End-user API ไม่รวม Admin Panel)

ติดตั้ง: npm install strapi-plugin-login512
1. ติดตั้งและเปิดใช้งานใน config/plugins.js
JAVASCRIPT
// config/plugins.js
module.exports = ({ env }) => ({
  login512: {
    enabled: true,
    config: {
      secretKey: env('LOGIN512_SECRET_KEY'),
      endpoint: 'https://api.login512.com',
      createUsers: true, // false: only users this plugin created or linked before can log in
      // requireNonce: true (default) and linkExistingByUsername: false (default), see the package README
    },
  },
});
2. Endpoint ตรวจสอบโทเคนของ Strapi
BASH
# 1) Nonce (kept in an httpOnly cookie on the Strapi host: send credentials). Stops login CSRF.
GET /api/login512/nonce            ->  { "nonce": "..." }

# 2) Give the nonce to the Login512 button, then exchange the token (alias: /api/login512/authenticate):
#    Login512.init({ publishableKey, endpoint: 'https://api.login512.com' }).mountButton('#login512', { nonce, onSuccess })
POST /api/login512/login           (credentials: 'include')
Content-Type: application/json

{ "token": "<token from the Login512 button>" }

# 200: { "jwt": "eyJhbGciOiJIUzI1NiIsIn...", "user": { "id": 1, "username": "<claims.sub>", "email": "..." } }
#      Same session as POST /api/auth/local: new Strapi 5 apps also get the refresh token (httpOnly cookie
#      strapi_up_refresh, or "refreshToken" in the body); renew with POST /api/auth/refresh.
# 401: { "error": { "status": 401, "name": "UnauthorizedError", "message": "TOKEN_ALREADY_USED" } }
#      also NONCE_REQUIRED, NONCE_MISMATCH, TOKEN_BAD_SIGNATURE, STEP_UP_REQUIRED, USER_BLOCKED
# Clients without cookies (mobile, SPA on another site): generate the nonce yourself and send { token, nonce }.
# A subject equal to an existing username or email gets its OWN account (l512_...), not that user's.
3. การปกป้อง Custom Strapi Controller
JAVASCRIPT
module.exports = {
  async secureAction(ctx) {
    try {
      // a fresh Login512 token sent by the client, e.g. header X-Login512-Token
      await strapi.plugin('login512').service('auth').verifyToken(ctx.request.header['x-login512-token']);
    } catch (err) {
      return ctx.unauthorized(err.message);
    }
    return { data: 'Super Secret Headless Data' };
  },
};
💧

Drupal Module

Official Package (.zip) • Drupal 10 / 11
Official SDK PQC Verified

โมดูล Drupal 10/11 เพิ่มปุ่ม Login512 ในหน้าเข้าสู่ระบบ ตรวจโทเคนฝั่งเซิร์ฟเวอร์ด้วย Secret Key แล้วสร้าง session ของ Drupal

ติดตั้ง: curl -LO https://login512.com/packages/drupal.zip && unzip drupal.zip -d web/modules/custom
1. ติดตั้งและเปิดใช้งานโมดูล
BASH
curl -LO https://login512.com/packages/drupal.zip
unzip drupal.zip -d web/modules/custom
drush en login512
# then: Configuration > People > Login512 (/admin/config/people/login512)
2. ขั้นตอนการเข้าสู่ระบบ
TEXT
GET  /login512/nonce   -> one-time nonce in the visitor's Drupal session
POST /login512/verify  {"token": "..."}  (JSON only, foreign Origin refused)
     -> token verified with your SECRET key + expected_nonce
     -> account linked by user data (never matched by user name)
     -> Drupal session (user_login_finalize)
🧩

Joomla System Plugin

Official Package (.zip) • Joomla 4 / 5
Official SDK PQC Verified

ปลั๊กอินระบบ Joomla 4/5 เพิ่มปุ่ม Login512 ในฟอร์มเข้าสู่ระบบ ตรวจโทเคนฝั่งเซิร์ฟเวอร์ แล้วเข้าสู่ระบบผ่านระบบผู้ใช้ของ Joomla

ติดตั้ง: https://login512.com/packages/joomla.zip
1. ติดตั้งและตั้งค่าปลั๊กอิน
TEXT
1. System > Install > Extensions > Install from URL:
   https://login512.com/packages/joomla.zip
2. System > Plugins > "System - Login512": enable it and set
   API endpoint, Publishable key (l512_pk_...), Secret key (l512_sk_...)
2. ขั้นตอนการเข้าสู่ระบบ
TEXT
The Login512 button appears on the site and administrator login forms.
com_ajax: task=nonce -> nonce in the Joomla session
          task=verify {"token"} -> verified with your SECRET key + expected_nonce
-> account linked in #__user_profiles (never by user name or e-mail)
-> signed in through Joomla's own onUserLogin (blocked users stay blocked)
🛡️

Nginx / Kong Gateway

Official Package (.zip) • nginx auth_request • Kong 3.x
Official SDK PQC Verified

ป้องกันทุกแอปหลัง nginx หรือ Kong: เข้าสู่ระบบด้วย Login512 ครั้งเดียว แล้วใช้ session cookie ที่เซ็นไว้ แอปได้รับผู้ใช้ทาง X-Login512-User

ติดตั้ง: curl -LO https://login512.com/packages/gateway.zip
1. รัน session gateway คู่กับ nginx / Kong
BASH
curl -LO https://login512.com/packages/gateway.zip && unzip gateway.zip
export LOGIN512_SECRET_KEY=l512_sk_...  LOGIN512_PUBLISHABLE_KEY=l512_pk_...
export L512_GW_SESSION_SECRET="$(openssl rand -hex 32)"
python3 login512-gateway/nginx/login512_gateway.py   # 127.0.0.1:8513
2. ป้องกัน location (nginx) หรือ route (Kong)
NGINX
# nginx: include login512-gateway/nginx/login512-auth.conf in your server { } block
location /protected/ {
    auth_request /_login512_auth;
    auth_request_set $login512_user $upstream_http_x_login512_user;
    error_page 401 = @login512_login;
    proxy_set_header X-Login512-User $login512_user;   # percent-encoded user id
    proxy_pass http://backend_upstream;
}
# Kong: plugin login512 (login512-gateway/kong) + kong.yml.example
📱

Ionic / Capacitor

Official Package (.tgz) • Capacitor 5+ • iOS & Android WebView
Official SDK PQC Verified

ใช้ Login512 ในแอป Ionic / Capacitor ผ่าน WebView: ปุ่มจริงและหน้าสแกนจริง แล้วตรวจโทเคนที่เซิร์ฟเวอร์ของคุณ

ติดตั้ง: npm install https://login512.com/packages/capacitor.tgz
1. เข้าสู่ระบบจากแอปของคุณ
TYPESCRIPT
import { login512Login, mountLogin512Button } from '@login512/capacitor';

const { token } = await login512Login({ publishableKey: 'l512_pk_live_...', endpoint: 'https://api.login512.com' });
await fetch('https://your-api.example/login512', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) });
2. การตั้งค่าแอปที่จำเป็น
TEXT
capacitor.config.ts:  server: { iosScheme: 'https' }      (Login512 accepts http(s) origins only)
Tenant allowed origins: https://localhost
iOS:     NSCameraUsageDescription in Info.plist
Android: <uses-permission android:name="android.permission.CAMERA" />
Passkeys do not work inside an app WebView: use face scan.