Skip to content

Commit

Permalink
rename: gotrue to auth (#820)
Browse files Browse the repository at this point in the history
Renames GoTrue to Auth.

`GoTrueClient` and `GoTrueAdminApi` still remain the main classes, but
they're re-exported as `AuthClient` and `AuthAdminApi`.
  • Loading branch information
hf authored Dec 13, 2023
1 parent 016ee66 commit 9f13e7e
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 34 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ jobs:
npm ci
npm run build
- name: Create a release
- name: Create a release for @supabase/auth-js
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create a release for @supabase/gotrue-js
run: |
for f in package.json package-lock.json
do
sed -i '' 's|\(["/]\)auth-js|\1gotrue-js|g' "$f"
done
npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# `gotrue-js`
# `auth-js`

An isomorphic JavaScript client library for the [GoTrue](https://github.com/supabase/gotrue) API.
An isomorphic JavaScript client library for the [Supabase Auth](https://github.com/supabase/auth) API.

## Docs

- Using `gotrue-js`: https://supabase.com/docs/reference/javascript/auth-signup
- TypeDoc: https://supabase.github.io/gotrue-js/v2
- Using `auth-js`: https://supabase.com/docs/reference/javascript/auth-signup
- TypeDoc: https://supabase.github.io/auth-js/v2

## Quick start

Install

```bash
npm install --save @supabase/gotrue-js
npm install --save @supabase/auth-js
```

Usage

```js
import { GoTrueClient } from '@supabase/gotrue-js'
import { AuthClient } from '@supabase/auth-js'

const GOTRUE_URL = 'http://localhost:9999'

const auth = new GoTrueClient({ url: GOTRUE_URL })
const auth = new AuthClient({ url: GOTRUE_URL })
```

- `signUp()`: https://supabase.io/docs/reference/javascript/auth-signup
Expand All @@ -31,14 +31,14 @@ const auth = new GoTrueClient({ url: GOTRUE_URL })

### Custom `fetch` implementation

`gotrue-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests, but an alternative `fetch` implementation can be provided as an option. This is most useful in environments where `cross-fetch` is not compatible, for instance Cloudflare Workers:
`auth-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests, but an alternative `fetch` implementation can be provided as an option. This is most useful in environments where `cross-fetch` is not compatible, for instance Cloudflare Workers:

```js
import { GoTrueClient } from '@supabase/gotrue-js'
import { AuthClient } from '@supabase/auth-js'

const GOTRUE_URL = 'http://localhost:9999'
const AUTH_URL = 'http://localhost:9999'

const auth = new GoTrueClient({ url: GOTRUE_URL, fetch: fetch })
const auth = new AuthClient({ url: AUTH_URL, fetch: fetch })
```

## Sponsors
Expand Down
8 changes: 4 additions & 4 deletions example/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@supabase/gotrue-js": "file:../..",
"@supabase/auth-js": "file:../..",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
Expand Down
4 changes: 2 additions & 2 deletions example/react/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useEffect, useRef, useState } from 'react'
import { GoTrueClient } from '@supabase/gotrue-js'
import { AuthClient } from '@supabase/auth-js'
import './tailwind.output.css'

const supabaseURL = process.env.REACT_APP_SUPABASE_URL
const supabaseAnon = process.env.REACT_APP_SUPABASE_ANON_KEY

const auth = new GoTrueClient({
const auth = new AuthClient({
url: `${supabaseURL}/auth/v1`,
headers: {
accept: 'json',
Expand Down
6 changes: 3 additions & 3 deletions infra/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3'
services:
gotrue: # Signup enabled, autoconfirm off
image: supabase/gotrue:latest
image: supabase/auth:v2.129.0
ports:
- '9999:9999'
environment:
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
- db
restart: on-failure
autoconfirm: # Signup enabled, autoconfirm on
image: supabase/gotrue:latest
image: supabase/auth:v2.129.0
ports:
- '9998:9998'
environment:
Expand Down Expand Up @@ -71,7 +71,7 @@ services:
- db
restart: on-failure
disabled: # Signup disabled
image: supabase/gotrue:latest
image: supabase/auth:v2.129.0
ports:
- '9997:9997'
environment:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@supabase/gotrue-js",
"name": "@supabase/auth-js",
"version": "0.0.0",
"description": "Isomorphic GoTrue client",
"description": "Official client library for Supabase Auth",
"keywords": [
"gotrue",
"auth",
"supabase",
"auth",
"authentication"
],
"homepage": "https://github.com/supabase/gotrue-js",
"bugs": "https://github.com/supabase/gotrue-js/issues",
"homepage": "https://github.com/supabase/auth-js",
"bugs": "https://github.com/supabase/auth-js/issues",
"license": "MIT",
"author": "Supabase",
"files": [
Expand All @@ -19,7 +19,7 @@
"main": "dist/main/index.js",
"module": "dist/module/index.js",
"types": "dist/module/index.d.ts",
"repository": "supabase/gotrue-js",
"repository": "supabase/auth-js",
"scripts": {
"clean": "rimraf dist docs",
"coverage": "echo \"run npm test\"",
Expand Down
5 changes: 5 additions & 0 deletions src/AuthAdminApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import GoTrueAdminApi from './GoTrueAdminApi'

const AuthAdminApi = GoTrueAdminApi

export default AuthAdminApi
5 changes: 5 additions & 0 deletions src/AuthClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import GoTrueClient from './GoTrueClient'

const AuthClient = GoTrueClient

export default AuthClient
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import GoTrueAdminApi from './GoTrueAdminApi'
import GoTrueClient from './GoTrueClient'
export { GoTrueAdminApi, GoTrueClient }
import AuthAdminApi from './AuthAdminApi'
import AuthClient from './AuthClient'
export { GoTrueAdminApi, GoTrueClient, AuthAdminApi, AuthClient }
export * from './lib/types'
export * from './lib/errors'
export {
Expand Down
4 changes: 2 additions & 2 deletions test/GoTrueApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ describe('GoTrueAdminApi', () => {
test('signOut() with an invalid access token', async () => {
const { error } = await serviceRoleApiClient.signOut('this-is-a-bad-token')

expect(error?.message).toMatch(/^Invalid token/)
expect(error?.message).toMatch(/^invalid JWT/)
})
})
})
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('GoTrueAdminApi', () => {
})

expect(user).toBeNull()
expect(error?.message).toEqual('Invalid phone number format')
expect(error?.message).toEqual('Invalid phone number format (E.164 required)')
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/GoTrueClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('GoTrueClient', () => {
expect(data.session).toBeNull()
expect(data.user).toBeNull()

expect(error?.message).toEqual('Error sending confirmation sms: Missing Twilio account SID')
expect(error?.message).toEqual('Error sending confirmation sms: missing Twilio account SID')
})

test('signUp() with phone', async () => {
Expand Down

0 comments on commit 9f13e7e

Please sign in to comment.