{"id":18919443,"url":"https://github.com/allenan/magic-admin-elixir","last_synced_at":"2026-03-09T01:32:02.401Z","repository":{"id":45499904,"uuid":"414651428","full_name":"allenan/magic-admin-elixir","owner":"allenan","description":"Magic admin Elixir SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.","archived":false,"fork":false,"pushed_at":"2025-09-18T18:51:42.000Z","size":51,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-29T23:14:18.148Z","etag":null,"topics":["authentication","elixir","identity","passwordless"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allenan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2021-10-07T15:14:38.000Z","updated_at":"2025-09-18T18:51:45.000Z","dependencies_parsed_at":"2025-04-15T12:49:25.792Z","dependency_job_id":null,"html_url":"https://github.com/allenan/magic-admin-elixir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allenan/magic-admin-elixir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fmagic-admin-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fmagic-admin-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fmagic-admin-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fmagic-admin-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allenan","download_url":"https://codeload.github.com/allenan/magic-admin-elixir/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenan%2Fmagic-admin-elixir/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30279777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T20:45:49.896Z","status":"ssl_error","status_checked_at":"2026-03-08T20:45:49.525Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["authentication","elixir","identity","passwordless"],"created_at":"2024-11-08T10:37:53.140Z","updated_at":"2026-03-09T01:32:02.367Z","avatar_url":"https://github.com/allenan.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magic Admin Elixir SDK\n\nThe Magic Admin Elixir SDK provides convenient ways for developers to interact with\nMagic API endpoints and an array of utilities to handle DID Token.\n\nAdditional documentation can be found at [https://hexdocs.pm/magic_admin](https://hexdocs.pm/magic_admin).\n\n## Installation\n\nThe package can be installed by adding `magic_admin` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:magic_admin, \"~\u003e 0.8.0\"}\n  ]\nend\n```\n\n## Configuration\n\nTo make API calls, it is necessary to configure your Magic secret key.\n\n```elixir\nuse Mix.Config\n\nconfig :magic_admin, secret_key: System.get_env(\"MAGIC_SECRET\")\n# OR\nconfig :magic_admin, secret_key: \"sk_live_XXXXXXXXXXX\"\n```\n\n## Usage\n\n### Tokens\n\n#### Validate Tokens\n\nThe `Token.validate/1` function returns `:ok` if the token is valid, or an error tuple\nwith a message describing why the token is invalid.\n\n```elixir\n:ok = Magic.Token.validate(did_token)\n{:error, {:did_token_error, message}} = Magic.Token.validate(invalid_did_token)\n```\n\nThe `Token.validate!/1` function returns `true` if the token is valid, or raises a\n`DIDTokenError` with a message describing why the token is invalid.\n\n```elixir\ntrue = Magic.Token.validate!(did_token)\n```\n\n#### Decode Tokens\n\nThe `Token.decode/1` function returns a map of `proof`, `claim` and `message`, or an error\ntuple if it is malformed. `claim` is the parsed map of claims made by the decoded\ntoken. `proof` is the secp256k1 signature over a hash of `message` which is the JSON\nencoded version of `claim`.\n\n```elixir\n{:ok, %{proof: proof, claim: claim, message: message}} = Magic.Token.decode(did_token)\n{:error, {:did_token_error, message}} = Magic.Token.decode(invalid_did_token)\n```\n\nThe `Token.decode!/1` function returns a map of `proof`, `claim` and `message`, or raises\na `DIDTokenError` if it is malformed.\n\n```elixir\n%{proof: proof, claim: claim, message: message} = Magic.Token.decode!(did_token)\n```\n\n#### Get Token Attributes\n\nThe `Token` module also includes a couple of utility functions for accessing the issuer\nand public address attributes of a token.\n\n```elixir\nissuer = Magic.Token.get_issuer(did_token)\naddress = Magic.Token.get_public_address(did_token)\n```\n\n### Users\n\n#### Get User Metadata\n\nMetadata for a user can be retrieved by supplying issuer, public key, or the full DID Token:\n\n```elixir\nMagic.User.get_metadata_by_issuer(issuer)\nMagic.User.get_metadata_by_public_address(public_address)\nMagic.User.get_metadata_by_token(did_token)\n# =\u003e {:ok, %{email: \"fake@example.com\", issuer: \"did:ethr:0x00000000000000000000000000000\", public_address: \"0x00000000000000000000000000000000\"}}\n ```\n\n#### Log Out a User\n\nLogs a user out of all Magic SDK sessions by the supplied issuer, public address, or the full DID Token:\n\n```elixir\nMagic.User.logout_by_issuer(issuer)\nMagic.User.logout_by_public_address(public_address)\nMagic.User.logout_by_token(did_token)\n ```\n\n## Attribution\n\nThis Elixir library is based on the official Ruby implementation: https://github.com/magiclabs/magic-admin-ruby\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenan%2Fmagic-admin-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallenan%2Fmagic-admin-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenan%2Fmagic-admin-elixir/lists"}