InfraForge — Ruby SDK

Official Ruby client for InfraForge.

Install

gem install infraforge

Or add to Gemfile:

gem "infraforge"

Quickstart

require "infraforge"

c = InfraForge::Client.new(
  url: "https://infraforge.example.com",
  project_slug: "my-app",
  api_key: "if_xxxxx",
)

# Sign in (stores session in memory)
c.(email: "alice@example.com", password: "secret")

# Run a SQL query — RLS enforced via JWT
rows = c.query("SELECT id, title FROM posts WHERE author_id = current_user_id()")
rows.each { |r| puts r["title"] }

# Parameterized
rows = c.query("SELECT * FROM posts WHERE id = $1", [42])

# Sign up (admin may need to approve)
res = c.(email: "alice@example.com", password: "secret", name: "Alice")
puts "pending approval" if res[:pending]

# Reset password
c.request_password_reset("alice@example.com")

# Sign out
c.sign_out

Social login (browser flow)

url = c.(provider: "google", redirect_to: "https://app.example.com/callback")
# Redirect user to `url`. After auth, they land at redirect_to#token=<jwt>.
# Extract the fragment in JS, POST to your Ruby service, then:
c.set_token(jwt)

Errors

begin
  c.(email: "a@b.com", password: "wrong")
rescue InfraForge::AuthError => e
  if e.pending
    puts "pending admin approval"
  else
    puts "login failed: #{e.message}"
  end
end

License

MIT