{"_id":"@aethex.os/passport","_rev":"2-7deb0eb6eb3de711b321964e101e75f0","name":"@aethex.os/passport","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aethex.os/passport","version":"1.0.0","keywords":["oauth","federation","auth","identity","passport","social-login","github","discord","google","multi-provider","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","_id":"@aethex.os/passport@1.0.0","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"homepage":"https://aethex.dev","bugs":{"url":"https://github.com/AeThex-Corporation/AeThex-OS/issues"},"dist":{"shasum":"b8949e7f62351666ad377c266990c71bfd6f0408","tarball":"https://registry.npmjs.org/@aethex.os/passport/-/passport-1.0.0.tgz","fileCount":18,"integrity":"sha512-2KNbQe+eiWCfXDoJwFlnpyRtJ/m/m00N2ayh85mnJCj9IQmtizrEn+hCCiXXpw8Rc3KwDkJvAuZUKF86j26TTw==","signatures":[{"sig":"MEUCIBnWEzXN9MjledWbn9iL9Ufx+TXG1EQEGj2GUN+1Aq6fAiEAjQTVb1QWA1kL/Rcm4HuIDQRYJkGkWzv5aQGaDqFnkmA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25524},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"b094d5c032765a30612c2348ce0356d3a50d9feb","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"repository":{"url":"git+https://github.com/AeThex-Corporation/AeThex-OS.git","type":"git","directory":"packages/aethex-passport"},"_npmVersion":"11.12.1","description":"OAuth federation for multi-provider auth — link GitHub, Discord, Google, and more to a single unified user identity","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/passport_1.0.0_1777934421724_0.9185317802879875","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aethex.os/passport","version":"1.0.1","description":"OAuth federation for multi-provider auth — link GitHub, Discord, Google, and more to a single unified user identity","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch"},"keywords":["oauth","federation","auth","identity","passport","social-login","github","discord","google","multi-provider","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-passport"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"_id":"@aethex.os/passport@1.0.1","gitHead":"6c77abd6440deb925777f64998d4c67a398236e0","_nodeVersion":"22.22.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-DuBcGyA7gIN2qREt6A2u2vUWMmAMiAq260pH3DKY+PnbK0wKgKx0Lx3zcWTaRv7zChMrhQxVf/7YCCl5tVE2UA==","shasum":"4beb1ae83966cd44f0a80cc33fc03b9bd6a16e51","tarball":"https://registry.npmjs.org/@aethex.os/passport/-/passport-1.0.1.tgz","fileCount":18,"unpackedSize":25586,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC7qTY7RNfBTA1H7qt6vZtxhB62Sm6I19UgMUFQjZbQdwIhAMQqOM6XkB9j9jMce5o06nY5fW3lo0LanoDWyk7RT67w"}]},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"directories":{},"maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/passport_1.0.1_1783400210113_0.5380391543589942"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-04T22:40:21.632Z","modified":"2026-07-07T04:56:50.363Z","1.0.0":"2026-05-04T22:40:21.859Z","1.0.1":"2026-07-07T04:56:50.252Z"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","keywords":["oauth","federation","auth","identity","passport","social-login","github","discord","google","multi-provider","aethex"],"repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-passport"},"description":"OAuth federation for multi-provider auth — link GitHub, Discord, Google, and more to a single unified user identity","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"readme":"# @aethex.os/passport\n\nOAuth federation for multi-provider auth — let users log in with GitHub, Discord, Google, Roblox, or any provider, and link them all to a single unified identity. Storage-adapter pattern means it works with any database.\n\n## Install\n\n```bash\nnpm install @aethex.os/passport\n```\n\n## Concept\n\nInstead of one user per OAuth provider, `@aethex.os/passport` maintains a **Foundation Passport** — one canonical user record that can have multiple OAuth providers attached to it. Log in with Discord, later link GitHub, they're the same user.\n\n## Setup with Supabase\n\n```ts\nimport { createClient } from \"@supabase/supabase-js\";\nimport { createPassportManager, createSupabasePassportAdapter } from \"@aethex.os/passport\";\n\nconst supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE!);\n\nconst passport = createPassportManager({\n  storage: createSupabasePassportAdapter(supabase),\n});\n```\n\n**Required Supabase tables:**\n\n```sql\ncreate table user_profiles (\n  id uuid primary key default gen_random_uuid(),\n  email text unique not null,\n  username text unique not null,\n  full_name text,\n  avatar_url text,\n  created_at timestamptz default now()\n);\n\ncreate table provider_identities (\n  user_id uuid references user_profiles(id),\n  provider text not null,\n  provider_user_id text not null,\n  email text,\n  username text,\n  avatar_url text,\n  linked_at timestamptz default now(),\n  primary key (user_id, provider)\n);\n```\n\n## Login / sign-up (federation)\n\n```ts\n// In your Discord/GitHub/Google OAuth callback\nconst result = await passport.federateOAuthUser(\"discord\", {\n  id: discordUser.id,\n  email: discordUser.email,\n  username: discordUser.username,\n  name: discordUser.global_name,\n  avatar: `https://cdn.discordapp.com/avatars/${discordUser.id}/${discordUser.avatar}.webp`,\n});\n\nconsole.log(result.userId);      // Foundation Passport ID\nconsole.log(result.isNewUser);   // true if just signed up\n```\n\n## Link an additional provider\n\n```ts\n// User is already logged in, now linking GitHub to their account\nawait passport.linkProvider(currentUserId, \"github\", {\n  id: githubUser.id,\n  email: githubUser.email,\n  username: githubUser.login,\n  avatar: githubUser.avatar_url,\n});\n```\n\n## Unlink a provider\n\n```ts\n// Prevents unlinking the last auth method\nawait passport.unlinkProvider(userId, \"github\");\n```\n\n## List linked providers\n\n```ts\nconst providers = await passport.getLinkedProviders(userId);\n// [\"discord\", \"github\"]\n```\n\n## Custom storage adapter\n\nWorks with any database by implementing the `PassportStorageAdapter` interface:\n\n```ts\nimport type { PassportStorageAdapter } from \"@aethex.os/passport\";\n\nconst myAdapter: PassportStorageAdapter = {\n  findIdentity: async (provider, providerUserId) => { /* ... */ },\n  createUser:   async (data) => { /* return new userId */ },\n  linkProvider: async (userId, provider, providerUserId, data) => { /* ... */ },\n  findUserByEmail: async (email) => { /* return userId or null */ },\n  listUserProviders: async (userId) => { /* return provider[] */ },\n  unlinkProvider: async (userId, provider) => { /* ... */ },\n};\n\nconst passport = createPassportManager({ storage: myAdapter });\n```\n\n## Testing with in-memory adapter\n\n```ts\nimport { createPassportManager, createMemoryPassportAdapter } from \"@aethex.os/passport\";\n\nconst passport = createPassportManager({ storage: createMemoryPassportAdapter() });\n```\n\n## API\n\n| Method | Description |\n|--------|-------------|\n| `passport.federateOAuthUser(provider, user)` | Login or sign-up via any OAuth provider |\n| `passport.linkProvider(userId, provider, user)` | Link an additional provider to an existing user |\n| `passport.unlinkProvider(userId, provider)` | Unlink a provider (guards against unlinking the last one) |\n| `passport.getLinkedProviders(userId)` | List all providers linked to a user |\n\n---\n\nPart of the [`@aethex.os`](https://www.npmjs.com/search?q=%40aethex.os) toolkit.\n","readmeFilename":"README.md"}