{"id":18450201,"url":"https://github.com/nuid/sdk-ruby","last_synced_at":"2026-04-25T12:36:06.989Z","repository":{"id":56885881,"uuid":"333971106","full_name":"NuID/sdk-ruby","owner":"NuID","description":"Ruby Gem for interacting with NuID APIs","archived":false,"fork":false,"pushed_at":"2021-02-11T22:09:55.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T23:10:03.454Z","etag":null,"topics":["auth","authentication","nuid","rails","ruby","zero-knowledge"],"latest_commit_sha":null,"homepage":"https://portal.nuid.io/docs","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NuID.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-28T22:18:51.000Z","updated_at":"2021-06-27T02:36:15.000Z","dependencies_parsed_at":"2022-08-20T13:50:56.318Z","dependency_job_id":null,"html_url":"https://github.com/NuID/sdk-ruby","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fsdk-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fsdk-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fsdk-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NuID%2Fsdk-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NuID","download_url":"https://codeload.github.com/NuID/sdk-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167445,"owners_count":21223506,"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":["auth","authentication","nuid","rails","ruby","zero-knowledge"],"created_at":"2024-11-06T07:23:57.511Z","updated_at":"2026-04-25T12:36:06.955Z","avatar_url":"https://github.com/NuID.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"right\"\u003e\u003ca href=\"https://nuid.io\"\u003e\u003cimg src=\"https://nuid.io/svg/logo.svg\" width=\"20%\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n# NuID SDK for Ruby\n\n[![](https://img.shields.io/gem/v/nuid-sdk?color=red\u0026logo=rubygems\u0026style=for-the-badge)](https://rubygems.org/gems/nuid-sdk)\n[![](https://img.shields.io/badge/docs-v0.2.0-blue?style=for-the-badge\u0026logo=read-the-docs)](https://rubydoc.info/gems/nuid-sdk)\n[![](https://img.shields.io/badge/docs-platform-purple?style=for-the-badge\u0026logo=read-the-docs)](https://portal.nuid.io/docs)\n\nThis repo provides a Ruby Gem for interacting with NuID APIs within Ruby\napplications.\n\nRead the latest [gem\ndocs](https://rubydoc.info/gems/nuid-sdk/) or\ncheckout the [platform docs](https://portal.nuid.io/docs) for API docs, guides,\nvideo tutorials, and more.\n\n## Install\n\nFrom [rubygems](https://rubygems.org/gems/nuid-sdk):\n\n```sh\ngem install nuid-sdk -v \"0.2.0\"\n```\n\nOr with bundler:\n\n```ruby\n# Gemfile\ngem \"nuid-sdk\", \"~\u003e 0.2\"\n```\n\n## Usage\n\nExample rails auth controller.\n\nFor a more detailed example visit the [Integrating with\nNuID](https://portal.nuid.io/docs/guides/integrating-with-nuid) guide and the\naccompanying [examples repo](https://github.com/NuID/examples).\nA ruby-specific code example is coming soon.\n\n``` ruby\n# config/application.rb\nconfig.x.nuid.auth_api_key = ENV['NUID_API_KEY']\n```\n\n``` ruby\nrequire \"nuid/sdk/api/auth\"\n\nclass ApplicationController \u003c ActionController::API\n  def nuid_api\n    @nuid_api ||= ::NuID::SDK::API::Auth.new(Rails.configuration.x.nuid.auth_api_key)\n  end\n\n  def render_error(error, status)\n    render(json: {errors: [error]}, status: status)\n  end\nend\n```\n\n```ruby\nclass UsersController \u003c ApplicationController\n  NUID_API = ::NuID::SDK::API::Auth.new(ENV[\"NUID_API_KEY\"])\n\n  # The registration form should send the verified credential to be\n  # recorded in the NuID Auth API. The response to that interaction\n  # will provide a `nu/id` key in the response which should be stored\n  # with the newly created user record.\n  #\n  # The \"verified credential\" is generated by your client application\n  # using `Zk.verifiableFromSecret(password)` from the `@nuid/zk` npm\n  # package.\n  def register\n    credential_res = nuid_api.credential_create(params[:credential])\n    unless credential_res.code == 201\n      return render_error(\"Unable to create the credential\", :bad_request)\n    end\n\n    user = User.create!({\n      email: params[:email].strip.downcase,\n      first_name: params[:firstName],\n      last_name: params[:lastName],\n      nuid: credential_res.parsed_response[\"nu/id\"]\n    })\n\n    render(json: { user: user }, status: :created)\n  rescue =\u003e exception\n    render_error(exception.message, 500)\n  end\nend\n```\n\n``` ruby\nclass SessionsController \u003c ApplicationController\n  NUID_API = ::NuID::SDK::API::Auth.new(ENV[\"NUID_API_KEY\"])\n\n  # Get a challenge from the Auth API. The client form should request\n  # a challenge as the first of two phases to login. Once a succesful\n  # challenge has been fetched, return it to the client so a proof\n  # can be generated from the challenge claims and the user's password.\n  def login_challenge\n    user = User.where(email: params[:email].strip.downcase).first\n    return render_error(\"User not found\", :unauthorized) unless user\n\n    credential_res = nuid_api.credential_get(user.nuid)\n    unless credential_res.code == 200\n      return render_error(\"Credential not found\", :unauthorized)\n    end\n\n    credential = credential_res.parsed_response[\"nuid/credential\"]\n    challenge_res = nuid_api.challenge_get(credential)\n    unless challenge_res.code == 201\n      return render_error(\"Cannot create a challenge\", 500)\n    end\n\n    challenge_jwt = challenge_res.parsed_response[\"nuid.credential.challenge/jwt\"]\n    render(json: { challengeJwt: challenge_jwt }, status: :ok)\n  rescue =\u003e exception\n    render_error(exception.message, 500)\n  end\n\n  # Verify is the second part of the login process. The params\n  # provided here include the user identification param (email or\n  # username), the unaltered challenge_jwt retrieved in phase 1 of login\n  # (see #login_challenge above), and the proof that was generated from\n  # the challenge_jwt claims and the user secret.\n  #\n  # The \"proof\" is generated by your client application using\n  # `Zk.proofFromSecretAndChallenge(password, challenge_jwt)` from the\n  # `@nuid/zk` npm package.\n  def login_verify\n    user = User.where(email: params[:email].strip.downcase).first\n    return render_error(\"User not found\", :unauthorized) unless user\n\n    challenge_res = nuid_api.challenge_verify(params[:challengeJwt], params[:proof])\n    unless challenge_res.code == 200\n      return render_error(\"Verification failed\", :unauthorized)\n    end\n\n    render(json: { user: user }, status: :ok)\n  rescue =\u003e exception\n    render_error(exception.message, 500)\n  end\nend\n```\n\n## Development\n\nYou'll want to download docker to run the tests, as we depend on the\n`@nuid/cli` npm package to provide a CLI you can shell out to\nin the tests for generating zk crypto. After checking out the repo, run\n`bin/setup` to install dependencies and create the docker environment. Then, run\n`make test` to run the tests inside the running container. You can also run\n`bin/console` for an interactive prompt that will allow you to experiment, but\nyou'll probably want to run that in the container (use `make shell` to get a\nprompt in the container).\n\n`make clean` will stop and destroy the container and image. `make build run`\nwill rebuild the image and run the container.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/NuID/sdk-ruby.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuid%2Fsdk-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuid%2Fsdk-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuid%2Fsdk-ruby/lists"}