Login के साथ private demo share करें: हल्का access control

· jsdeck team · 5 मिनट पढ़ना
Login के साथ private demo share करें: हल्का access control

अगर आपने share a private demo with login खोजा है, तो शायद static app पर login चाहिए बिना Node server खड़े, OAuth configure, या full auth platform pay किए। jsdeck के secure accounts (auth API)visitor auth भी कहते हैं — हर hosted app को अपने email/password accounts, session tokens, और optional per-user datastore rows देते हैं। यह गाइड बताती है कैसे काम करता है, real API calls दिखाती है, और ईमानदारी से बताती है कब Clerk, Auth0, या full backend use करें।

Use case: public URL, private audience

आप client email में https://my-demo.jsdeck.com चाहते हैं — screen share नहीं — लेकिन ऐप पूरे internet को visible नहीं होना चाहिए। Secure accounts एक stable link share करने देते हैं जबकि demo UI render होने से पहले login ज़रूरी है।

secure accounts (auth API) क्या है

jsdeck का auth API visitors के लिए per-app secure accounts बनाता है जो https://your-slug.jsdeck.com पर hosted app में sign in करते हैं। हर account email + password है जो सिर्फ उस app slug तक scoped है। register या login के बाद API accessToken देता है — bearer session token (default 7 days, server-side)।

यह आपका jsdeck dashboard login नहीं है। Dashboard accounts apps deploy/configure करते हैं; secure accounts *आपके* demo या product UI में sign in करते हैं। Full route reference: Secure accounts (auth API) docs

Auth HTTP routes (summary)

सभी calls apex base https://jsdeck.com/api/v1 use करती हैं (CORS *.jsdeck.com allow करता है)। {slug} को app name से replace करें:

MethodPathPurpose
POST/public/apps/{slug}/users/registerAccount बनाएँ (email, password min 8 chars)
POST/public/apps/{slug}/users/loginSign in — accessToken, expiresAt, user return
GET/public/apps/{slug}/users/meCurrent user — Authorization: Bearer <session token>
POST/public/apps/{slug}/users/logoutSession revoke
POST/public/apps/{slug}/users/forgot-passwordReset email भेजें
POST/public/apps/{slug}/users/reset-passwordtoken + newPassword से reset complete

OpenAPI spec: /tenant-auth-api.yaml

Example: static frontend से login

const API = 'https://jsdeck.com/api/v1';
const SLUG = 'your-app';

async function login(email, password) {
  const res = await fetch(`${API}/public/apps/${SLUG}/users/login`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email, password }),
  });
  if (!res.ok) throw new Error('Invalid email or password');
  const { accessToken, user } = await res.json();
  sessionStorage.setItem('sessionToken', accessToken);
  return user;
}

async function currentUser(token) {
  const res = await fetch(`${API}/public/apps/${SLUG}/users/me`, {
    headers: { Authorization: `Bearer ${token}` },
  });
  return res.ok ? (await res.json()).user : null;
}

Session token session cookie जैसा store करें — HTTPS only, log न करें। @jsdeck/toolkit package register, login, datastore calls को configure({ tenantUserToken }) से wrap करता है।

Login के पीछे demo gate करें (backend code के बिना)

Static bundle valid session token तक login form show कर सकता है:

// Pseudocode — adapt to React, Vue, Svelte, etc.
const token = sessionStorage.getItem('sessionToken');

async function boot() {
  if (!token) {
    renderLoginForm({ onSuccess: (t) => { sessionStorage.setItem('sessionToken', t); boot(); } });
    return;
  }
  const user = await currentUser(token);
  if (!user) {
    sessionStorage.removeItem('sessionToken');
    boot();
    return;
  }
  renderYourApp(user); // demo visible only after auth
}

Hosted HTML अभी भी public है — login से पहले क्या render करना है आप client code में decide करते हैं। Client preview के लिए एक shared demo account बनाएँ या stakeholder के हिसाब से अलग accounts register करवाएँ।

Per-user private data (owner rows)

Auth optional JSON datastore के साथ pair होता है। Login के बाद visibility: "owner" records PUT करें — सिर्फ उस user का session token read/write कर सकता है, shared store_ key नहीं। Lists owner rows omit करती हैं जब तक valid session token request में न हो। datastore key session token के साथ use करने के लिए owner-row docs देखें।

Password reset

User email के साथ forgot-password call करें और optional redirectPath (जैसे "/reset-password") दें ताकि reset link hosted app पर खुले। Reset page URL से ?token= read कर reset-password POST कर newPassword के साथ। नया password माँगने से पहले reset-password/status?token= से "link expired" show करें।

Limits और auth API कब enough नहीं

jsdeck auth email/password per app, gated demos, owner-scoped JSON rows के लिए fit है। social/OAuth login, MFA, SAML/SSO, org roles, audit logs, compliance certifications नहीं। Apps 5,000 secure accounts per app तक capped — demos और small products के लिए plenty। Google sign-in, enterprise SSO, fine-grained RBAC चाहिए? Clerk, Auth0, या Supabase Auth use करें और jsdeck सिर्फ static hosting के लिए रखें। Scope details: what the auth API covers

Practical client-preview workflow

  1. Latest build jsdeck पर deploy करें
  2. Minimal login/register screen (email + password) जोड़ें
  3. Load पर GET /users/me call करें; fail हो तो सिर्फ login form show करें
  4. Option A — shared demo user: एक बार register ([email protected]) और client को credentials share करें
  5. Option B — per-viewer accounts: हर stakeholder first visit पर अपना email register करे
  6. Optional: client-specific notes owner datastore rows में save करें ताकि data per login private रहे

Link जल्दी भेजें; credentials leak हों तो demo password rotate करें या app logic से accounts disable करें।

यह किसके लिए है, और jsdeck auth कब नहीं

अच्छा fit: gated demos, client previews, hackathon apps, MVPs, owner rows के साथ per-user JSON।

Fit नहीं: OAuth-only login, MFA requirements, enterprise SSO, complex roles, regulated identity workloads — Clerk, Auth0, या Supabase Auth use करें।

अक्सर पूछे जाने वाले प्रश्न

क्या login के साथ private demo share करना वाकई मुफ़्त है?

हाँ। jsdeck HTTPS सहित free static hosting देता है। Secure accounts (auth API) और optional datastore typical demo/side-project scale पर included — start के लिए credit card नहीं।

क्या secure accounts jsdeck dashboard login जैसा है?

नहीं। Dashboard account jsdeck.com पर apps deploy करता है। Secure accounts end-users हैं जो auth API से your-slug.jsdeck.com पर *आपके* app में sign in करते हैं।

क्या visitors Google या GitHub से sign in कर सकते हैं?

अभी नहीं — सिर्फ email और password। Social login या SSO के लिए dedicated identity provider use करें। what jsdeck auth covers और comparisons hub देखें।

अगले कदम

लेखक के बारे में

jsdeck टीम static JavaScript ऐप्स के लिए व्यावहारिक deployment गाइड लिखती है। प्रतिक्रिया भेजें.

डिप्लॉय करने के लिए तैयार?

अपना static ऐप मिनटों में live URL पर प्रकाशित करें — वैकल्पिक datastore और visitor auth के साथ मुफ़्त होस्टिंग।

मुफ़्त शुरू करें