{"_id":"@atlantis-gr/svelte-auth","_rev":"3-d0eb070d2c0b035ee87b512566c70c74","name":"@atlantis-gr/svelte-auth","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@atlantis-gr/svelte-auth","version":"1.0.0","keywords":["svelte","oauth","oidc","authentication","auth","openid-connect"],"author":{"name":"Atlantis GR"},"license":"MIT","_id":"@atlantis-gr/svelte-auth@1.0.0","maintainers":[{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"}],"homepage":"https://github.com/Atlantis-GR/svelte-components#readme","bugs":{"url":"https://github.com/Atlantis-GR/svelte-components/issues"},"dist":{"shasum":"cfd12145ab8cc87a02748df0cebbbcf816c2e1b2","tarball":"https://registry.npmjs.org/@atlantis-gr/svelte-auth/-/svelte-auth-1.0.0.tgz","fileCount":39,"integrity":"sha512-MR+/AE9XhpiIlAAmotnJVJTwnqiat1LQwO68A0DGsSEQ65uP3dCnrSnRE3fNBdVcqFgzClyDWux/akxy45h96g==","signatures":[{"sig":"MEQCIA07z7qzmAjjhkl0RY+QIq2hxn8xh+csc/ChLuVpG3HHAiAEWQ8q/qt7bFC7Miyh4sosdw8M6a9RojXTHPEPuqqtxg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":105884},"type":"module","types":"./dist/index.d.ts","svelte":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"},"./components":{"types":"./dist/components/index.d.ts","svelte":"./dist/components/index.js"}},"gitHead":"16727484f3d58752261c764e99295222514cb890","scripts":{"dev":"vite dev","lint":"prettier --check .","build":"svelte-package","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","format":"prettier --write .","prepack":"svelte-package","prepare":"svelte-kit sync || echo ''","preview":"vite preview","build:pack":"svelte-package && npm pack","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"},"_npmUser":{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"},"repository":{"url":"git+https://github.com/Atlantis-GR/svelte-components.git","type":"git"},"_npmVersion":"10.9.1","description":"OAuth/OIDC authentication library for Svelte applications","directories":{},"sideEffects":["**/*.css"],"_nodeVersion":"24.2.0","dependencies":{"oidc-client-ts":"^3.3.0","@atlantis-gr/svelte-logging-abstractions":"file:../Svelte.Logging.Abstractions"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.1.7","svelte":"^5.39.5","publint":"^0.3.13","prettier":"^3.6.2","typescript":"^5.9.2","tailwindcss":"^4.1.13","svelte-check":"^4.3.2","@sveltejs/kit":"^2.43.2","@sveltejs/package":"^2.5.4","@sveltejs/adapter-auto":"^6.1.0","prettier-plugin-svelte":"^3.4.0","prettier-plugin-tailwindcss":"^0.6.14","@sveltejs/vite-plugin-svelte":"^6.2.0"},"peerDependencies":{"svelte":"^5.0.0","@sveltejs/kit":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte-auth_1.0.0_1760716843598_0.6835640423548133","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@atlantis-gr/svelte-auth","version":"1.0.1","keywords":["svelte","oauth","oidc","authentication","auth","openid-connect"],"author":{"name":"Atlantis GR"},"license":"MIT","_id":"@atlantis-gr/svelte-auth@1.0.1","maintainers":[{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"}],"homepage":"https://github.com/Atlantis-GR/svelte-components#readme","bugs":{"url":"https://github.com/Atlantis-GR/svelte-components/issues"},"dist":{"shasum":"492d4d9ca355ebc2fcf3db47ab5e30db0e0d28fa","tarball":"https://registry.npmjs.org/@atlantis-gr/svelte-auth/-/svelte-auth-1.0.1.tgz","fileCount":39,"integrity":"sha512-iEjfWN0RpVHcGOk7nOgwgd6XUMPXmYzcqLdiQz+ZlWsydJ2ODXshcCNYZFmF3qgZ8OYa9hEKMcMKMyyHpZSkZA==","signatures":[{"sig":"MEUCIQDVudW4Zk+bhmgxOp3Nh9OdjwEvutgym7BhR3Hc+Y63tQIgS1+CEdIVjoj0//FwxTTlXIHR7XXLzVxfvDEVJZ58Fjo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":105854},"type":"module","types":"./dist/index.d.ts","svelte":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"},"./components":{"types":"./dist/components/index.d.ts","svelte":"./dist/components/index.js"}},"gitHead":"137e0990ef179a7a96718e6db5186bbc15d47f13","scripts":{"dev":"vite dev","lint":"prettier --check .","build":"svelte-package","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","format":"prettier --write .","prepack":"svelte-package","prepare":"svelte-kit sync || echo ''","preview":"vite preview","build:pack":"svelte-package && npm pack","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"},"_npmUser":{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"},"repository":{"url":"git+https://github.com/Atlantis-GR/svelte-components.git","type":"git"},"_npmVersion":"10.9.1","description":"OAuth/OIDC authentication library for Svelte applications","directories":{},"sideEffects":["**/*.css"],"_nodeVersion":"24.2.0","dependencies":{"oidc-client-ts":"^3.3.0","@atlantis-gr/svelte-logging-abstractions":"1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.1.7","svelte":"^5.39.5","publint":"^0.3.13","prettier":"^3.6.2","typescript":"^5.9.2","tailwindcss":"^4.1.13","svelte-check":"^4.3.2","@sveltejs/kit":"^2.43.2","@sveltejs/package":"^2.5.4","@sveltejs/adapter-auto":"^6.1.0","prettier-plugin-svelte":"^3.4.0","prettier-plugin-tailwindcss":"^0.6.14","@sveltejs/vite-plugin-svelte":"^6.2.0"},"peerDependencies":{"svelte":"^5.0.0","@sveltejs/kit":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte-auth_1.0.1_1760717657907_0.17670945315884223","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@atlantis-gr/svelte-auth","version":"1.0.2","description":"OAuth/OIDC authentication library for Svelte applications","scripts":{"dev":"vite dev","build:pack":"svelte-package && npm pack","build":"svelte-package","preview":"vite preview","prepare":"svelte-kit sync || echo ''","prepack":"svelte-package","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","format":"prettier --write .","lint":"prettier --check ."},"sideEffects":["**/*.css"],"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"},"./components":{"types":"./dist/components/index.d.ts","svelte":"./dist/components/index.js"}},"peerDependencies":{"@sveltejs/kit":"^2.0.0","svelte":"^5.0.0"},"dependencies":{"@atlantis-gr/svelte-logging-abstractions":"1.0.0","esm-env":"^1.2.2","oidc-client-ts":"^3.3.0"},"devDependencies":{"@sveltejs/adapter-auto":"^6.1.0","@sveltejs/kit":"^2.43.2","@sveltejs/package":"^2.5.4","@sveltejs/vite-plugin-svelte":"^6.2.0","prettier":"^3.6.2","prettier-plugin-svelte":"^3.4.0","prettier-plugin-tailwindcss":"^0.6.14","publint":"^0.3.13","svelte":"^5.39.5","svelte-check":"^4.3.2","tailwindcss":"^4.1.13","typescript":"^5.9.2","vite":"^7.1.7"},"author":{"name":"Atlantis GR"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Atlantis-GR/svelte-components.git"},"keywords":["svelte","oauth","oidc","authentication","auth","openid-connect"],"_id":"@atlantis-gr/svelte-auth@1.0.2","gitHead":"f7e1b1c746375ff9dafda844fdb6edc690d6b8ab","bugs":{"url":"https://github.com/Atlantis-GR/svelte-components/issues"},"homepage":"https://github.com/Atlantis-GR/svelte-components#readme","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-004fhlWlSJx1xQpTC4qWEP7ljVCrJEzNvkfRKQBdbVLNcU7akwXgnc4yfmYxFyMkoB3flS0qFam7n4PADR3zRA==","shasum":"ecbe5904c4e107de1b78ee0dab255710994b1d5a","tarball":"https://registry.npmjs.org/@atlantis-gr/svelte-auth/-/svelte-auth-1.0.2.tgz","fileCount":39,"unpackedSize":103186,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCa1JrcDbh3QQMyzFgemlLpPg6uuxYbN0fQSsJARM/UogIhAIBJHIHpDBGfZkzAHA0R854icA1K0n01PiukrElBzDpn"}]},"_npmUser":{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"},"directories":{},"maintainers":[{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svelte-auth_1.0.2_1760725031857_0.5855138068575811"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-17T16:00:43.476Z","modified":"2025-10-17T18:17:12.270Z","1.0.0":"2025-10-17T16:00:43.832Z","1.0.1":"2025-10-17T16:14:18.093Z","1.0.2":"2025-10-17T18:17:12.053Z"},"bugs":{"url":"https://github.com/Atlantis-GR/svelte-components/issues"},"author":{"name":"Atlantis GR"},"license":"MIT","homepage":"https://github.com/Atlantis-GR/svelte-components#readme","keywords":["svelte","oauth","oidc","authentication","auth","openid-connect"],"repository":{"type":"git","url":"git+https://github.com/Atlantis-GR/svelte-components.git"},"description":"OAuth/OIDC authentication library for Svelte applications","maintainers":[{"name":"lefterisrentas","email":"lefteris.rentasac@gmail.com"}],"readme":"# @atlantis-gr/svelte-auth\n\nOAuth/OIDC authentication library for Svelte applications.\n\n## Features\n\n- OAuth 2.0 / OpenID Connect support\n- Automatic token refresh with configurable intervals\n- Route guards for protected pages\n- Authentication context for component access\n- Keycloak integration\n- TypeScript support with full type definitions\n- Svelte 5 compatibility using runes\n\n## Installation\n\n```bash\nnpm install @atlantis-gr/svelte-auth\n```\n\n## Usage\n\n### 1. Configure Authentication\n\nCreate your auth configuration:\n\n```typescript\n// app.html or app configuration\nconst authConfig = {\n\tauthority: 'https://your-keycloak-server.com/realms/your-realm',\n\tclient_id: 'your-client-id',\n\tredirect_uri: 'http://localhost:5173/auth-callback',\n\tresponse_type: 'code',\n\tscope: 'openid profile email',\n\tautomaticSilentRenew: true,\n\tsilentRequestTimeout: 10000\n};\n```\n\n### 2. Set Up Authentication Provider\n\n```svelte\n<!-- app.html or root layout -->\n<script>\n\timport { AuthProvider } from '@atlantis-gr/svelte-auth/components';\n\n\tconst authConfig = {\n\t\t// your configuration\n\t};\n</script>\n\n<AuthProvider config={authConfig}>\n\t<slot />\n</AuthProvider>\n```\n\n### 3. Use Authentication in Components\n\n```svelte\n<script>\n\timport { getAuthStores } from '@atlantis-gr/svelte-auth';\n\n\tconst { isAuthenticated, user } = getAuthStores();\n</script>\n\n{#if $isAuthenticated}\n\t<p>Welcome, {$user?.profile?.name}!</p>\n\t<button onclick={logout}>Logout</button>\n{:else}\n\t<button onclick={login}>Login</button>\n{/if}\n```\n\n### 4. Handle Authentication Callbacks\n\n```svelte\n<!-- src/routes/auth-callback/+page.svelte -->\n<script>\n\timport { AuthCallback } from '@atlantis-gr/svelte-auth/components';\n</script>\n\n<AuthCallback />\n```\n\n## 🔧 API Reference\n\n### Components\n\n#### `<AuthProvider>`\n\nProvides authentication context to child components.\n\n**Props:**\n\n- `config: AuthConfig` - OIDC client configuration\n- `onSigninCallback?: (user: User) => void` - Called after successful login\n- `onSignoutCallback?: () => void` - Called after logout\n\n#### `<AuthCallback>`\n\nHandles OAuth callback and token exchange.\n\n#### `<AuthRenew>`\n\nHandles silent token renewal.\n\n#### `<LoggedOut>`\n\nComponent displayed when user is logged out.\n\n### Stores\n\n#### `getAuthStores()`\n\nReturns reactive stores for authentication state:\n\n```typescript\nconst {\n\tisAuthenticated, // Writable<boolean>\n\tuser, // Writable<User | null>\n\tisLoading // Writable<boolean>\n} = getAuthStores();\n```\n\n### Services\n\n#### `createScopedLogger(scope: string)`\n\nCreates a scoped logger for debugging:\n\n```typescript\nconst logger = createScopedLogger('MyComponent');\nlogger.info('Authentication successful');\n```\n\n## 🛡️ Route Protection\n\n### Using Guards\n\n```svelte\n<script>\n\timport { onMount } from 'svelte';\n\timport { goto } from '$app/navigation';\n\timport { getAuthStores } from '@atlantis-gr/svelte-auth';\n\n\tconst { isAuthenticated } = getAuthStores();\n\n\tonMount(() => {\n\t\tif (!$isAuthenticated) {\n\t\t\tgoto('/login');\n\t\t}\n\t});\n</script>\n\n<!-- Protected content -->\n{#if $isAuthenticated}\n\t<h1>Protected Page</h1>\n{/if}\n```\n\n### Automatic Redirects\n\n```typescript\n// In your auth configuration\nconst authConfig = {\n\t// ... other config\n\tpost_logout_redirect_uri: 'http://localhost:5173/',\n\tautomaticSilentRenew: true\n};\n```\n\n## 🔑 Identity Provider Setup\n\n### Keycloak Configuration\n\n1. **Create a new client** in your Keycloak realm\n2. **Set client type** to \"OpenID Connect\"\n3. **Configure redirect URIs**:\n   - `http://localhost:5173/auth-callback` (development)\n   - `https://your-domain.com/auth-callback` (production)\n4. **Enable required features**:\n   - Standard Flow Enabled\n   - Direct Access Grants Enabled (if needed)\n5. **Set up client scopes** (openid, profile, email)\n\n### Other OIDC Providers\n\nThis library works with any OIDC-compliant provider:\n\n- Auth0\n- Azure AD\n- Google Identity\n- Okta\n- And more\n\n## ⚙️ Configuration Options\n\n```typescript\ninterface AuthConfig {\n\tauthority: string; // OIDC provider URL\n\tclient_id: string; // Client identifier\n\tredirect_uri: string; // Callback URL\n\tpost_logout_redirect_uri?: string;\n\tresponse_type?: string; // Usually 'code'\n\tscope?: string; // Space-separated scopes\n\tautomaticSilentRenew?: boolean;\n\tsilentRequestTimeout?: number;\n\tloadUserInfo?: boolean;\n\tclockSkew?: number;\n}\n```\n\n## 🔍 Debugging\n\nEnable debug logging:\n\n```typescript\nimport { createScopedLogger } from '@atlantis-gr/svelte-auth';\n\nconst logger = createScopedLogger('Auth');\nlogger.setLevel('debug'); // Enable detailed logging\n```\n\n## 🧪 Testing\n\n```bash\n# Run type checking\nnpm run check\n\n# Build the library\nnpm run build\n\n# Run tests (if available)\nnpm test\n```\n\n## 📚 Examples\n\nSee the [sample application](../Svelte.Sample) for complete implementation examples including:\n\n- Login/logout flows\n- Protected routes\n- Token management\n- Error handling\n- UI integration patterns\n\n## 🤝 Contributing\n\nSee [CONTRIBUTING.md](../CONTRIBUTING.md) for development setup and guidelines.\n\n## 📄 License\n\nMIT License - see [LICENSE](../LICENSE) for details.\n\n## 🆘 Support\n\n- 📖 [Documentation](../README.md)\n- 🐛 [Issue Tracker](https://github.com/your-org/svelte-components/issues)\n- 💬 [Discussions](https://github.com/your-org/svelte-components/discussions)\n","readmeFilename":"README.md"}