{"id":13522782,"url":"https://github.com/JitPackJoyride/lucia-adapter-edgedb","last_synced_at":"2025-03-31T23:32:23.839Z","repository":{"id":193685512,"uuid":"689311484","full_name":"JitPackJoyride/lucia-adapter-edgedb","owner":"JitPackJoyride","description":"Lucia adapter for EdgeDB","archived":true,"fork":false,"pushed_at":"2023-10-09T06:39:28.000Z","size":99,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T19:52:58.363Z","etag":null,"topics":["adapter","edgedb","lucia","lucia-auth"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@jitpackjoyride/lucia-adapter-edgedb","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JitPackJoyride.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-09T12:12:43.000Z","updated_at":"2024-11-15T00:28:35.000Z","dependencies_parsed_at":"2024-11-02T07:30:43.314Z","dependency_job_id":"5643436d-382f-4c9c-b1c7-0ceb01211713","html_url":"https://github.com/JitPackJoyride/lucia-adapter-edgedb","commit_stats":null,"previous_names":["jitpackjoyride/lucia-adapter-edgedb"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JitPackJoyride%2Flucia-adapter-edgedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JitPackJoyride%2Flucia-adapter-edgedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JitPackJoyride%2Flucia-adapter-edgedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JitPackJoyride%2Flucia-adapter-edgedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JitPackJoyride","download_url":"https://codeload.github.com/JitPackJoyride/lucia-adapter-edgedb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246558108,"owners_count":20796696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter","edgedb","lucia","lucia-auth"],"created_at":"2024-08-01T06:00:52.285Z","updated_at":"2025-03-31T23:32:18.830Z","avatar_url":"https://github.com/JitPackJoyride.png","language":"TypeScript","funding_links":[],"categories":["Integrations"],"sub_categories":[],"readme":"# `@jitpackjoyride/lucia-adapter-edgedb`\n\n[EdgeDB](https://www.edgedb.com/) adapter for Lucia v2.\n\n**[Lucia documentation](https://lucia-auth.com)**\n\n**[Changelog](https://github.com/JitPackJoyride/lucia-adapter-edgedb/blob/main/CHANGELOG.md)**\n\n## Installation\n\n```\nbun add @jitpackjoyride/lucia-adapter-edgedb (recommended)\nnpm install @jitpackjoyride/lucia-adapter-edgedb\npnpm add @jitpackjoyride/lucia-adapter-edgedb\nyarn add @jitpackjoyride/lucia-adapter-edgedb\n```\n\n## Usage\n\nDo the usual EdgeDB setup, such as `edgedb project init`. Then, add this to your schema in `dbschema/default.esdl`:\n\n```esdl\nmodule default {\n\ttype User {\n\t\tlink auth_keys := .\u003cuser[is UserKey];\n\t\tlink auth_sessions := .\u003cuser[is UserSession];\n\n\t\t# put your own fields here\n\t}\n\n\ttype UserKey {\n\t\t# key_id is the combination of providerKeyId and providerUserId\n\t\t# providerKeyId is your own custom id for the provider such as \"google\", \"github\", \"email\", etc.\n\t\t# providerUserId is the id returned by the provider such as \"1234567890\" for google\n\t\trequired key_id: str {\n\t\t\tconstraint exclusive {\n\t\t\t\terrmessage := \"UserKey: key_id violates exclusivity constraint\"\n\t\t\t}\n\t\t}\n  \t\trequired user: User {\n\t\t\ton target delete delete source;\n\t\t}\n\t\thashed_password: str;\n\n\t\tindex on (.key_id);\n\t\tindex on (.user);\n\t}\n\n\ttype UserSession {\n  \t\trequired user: User {\n\t\t\ton target delete delete source;\n\t\t}\n  \t\trequired active_expires: int64;\n  \t\trequired idle_expires: int64;\n\n\t\tindex on (.user);\n\t}\n}\n```\n\nRun the following commands to create a migration and generate the typescript types:\n\n```bash\nedgedb migration create\nedgedb migrate\nbunx @edgedb/generate edgeql-js\n```\n\n(If you're using npm, you can use `npx @edgedb/generate edgeql-js`)\n\nThen, add this to `src/app.d.ts`:\n\n```typescript\n// src/app.d.ts\nimport e, { $infer } from \"../dbschema/edgeql-js\";\nconst userSelectQuery = e.select(e.User, () =\u003e ({\n  ...e.User[\"*\"],\n}));\ntype UserInDb = $infer\u003ctypeof userSelectQuery\u003e[number];\ntype User = Omit\u003cUserInDb, \"id\"\u003e;\n\nconst sessionSelectQuery = e.select(e.UserSession, () =\u003e ({\n  ...e.UserSession[\"*\"],\n}));\ntype SessionInDb = $infer\u003ctypeof sessionSelectQuery\u003e[number];\ntype Session = Omit\u003cSessionInDb, \"id\" | \"active_expires\" | \"idle_expires\"\u003e;\n\n/// \u003creference types=\"lucia\" /\u003e\ndeclare namespace Lucia {\n  type Auth = import(\"./auth/lucia\").Auth;\n  // NOTE: Keep this in sync with the database schema of User\n  type DatabaseUserAttributes = User;\n  // NOTE: Keep this in sync with the database schema of UserSession\n  type DatabaseSessionAttributes = Session;\n}\n```\n\nWhen you're initialising the EdgeDB client, you need to do something like this:\n\n```typescript\n// src/edgedb.ts\nimport * as edgedb from \"edgedb\";\n\nconst client = edgedb.createClient().withConfig({\n  allow_user_specified_id: true,\n});\n\nexport default client;\n```\n\nNote the `allow_user_specified_id` option. This is required for allowing the `id` field to be set by the user or by Lucia. Read the [Gotchas](#using-authsetuser-or-authsetsession) section for more information.\n\n## Gotchas\n\n### Using `auth.setUser` or `auth.setSession`\n\nWhen calling either `auth.setUser` or `auth.setSession`, it is highly recommended to generate your own random uuid for the `id` field. You can do this with `uuidv4` from `uuid` or `crypto.randomUUID` from `crypto`.\n\nExample:\n\n```typescript\nauth.setUser({\n  userId: crypto.randomUUID(),\n  // ... other fields\n});\n```\n\nThis is because Lucia's default id generator is random strings, but EdgeDB uses uuids. If you don't pass your own uuid, then the id will be a random string, which will make it hard to query the database.\n\n## Testing\n\nNot yet implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJitPackJoyride%2Flucia-adapter-edgedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJitPackJoyride%2Flucia-adapter-edgedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJitPackJoyride%2Flucia-adapter-edgedb/lists"}