Skip to content

Commit e3e3847

Browse files
committed
start-oauth@1.3.0
1 parent b9fa89b commit e3e3847

File tree

20 files changed

+5247
-138
lines changed

20 files changed

+5247
-138
lines changed

.github/workflows/codeql.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CodeQL Analysis
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
jobs:
8+
analyze:
9+
name: Analyze Code
10+
runs-on: ubuntu-latest
11+
permissions:
12+
security-events: write
13+
packages: read
14+
actions: read
15+
contents: read
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
language: [javascript-typescript]
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
fetch-depth: 0
24+
- uses: pnpm/action-setup@v4
25+
with:
26+
version: latest
27+
- uses: actions/setup-node@v5
28+
with:
29+
node-version: 22
30+
cache: pnpm
31+
- run: pnpm install --frozen-lockfile
32+
if: steps.setup-node.outputs.cache-hit != 'true'
33+
- uses: github/codeql-action/init@v3
34+
with:
35+
languages: ${{ matrix.language }}
36+
build-mode: none
37+
queries: +security-and-quality
38+
- uses: github/codeql-action/analyze@v3
39+
with:
40+
category: /language:javascript-typescript
41+
output: ./codeql-results
42+
upload: true
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: codeql-results
46+
path: ./codeql-results

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
node_modules
2-
package-lock.json
3-
pnpm-lock.yaml

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Reporting Issues
2+
3+
If you find a bug or have an idea for improvement, please [open an issue](https://github.com/thomasbuilds/start-oauth/issues) on GitHub. Provide as much detail as possible, including steps to reproduce the issue if applicable.
4+
5+
## Adding Providers
6+
7+
To add support for a new OAuth provider
8+
9+
1. Duplicate an existing provider file (e.g. [`src/providers/google.ts`](src/providers/google.ts))
10+
2. Update the endpoints, configuration options, and any provider-specific links
11+
3. Ensure your implementation aligns with the structure and flow of existing providers
12+
4. Submit a pull request with your changes
13+
14+
## Pull Requests
15+
16+
Before submitting a pull request
17+
18+
- Ensure your code adheres to the project's coding style (`npm run format`)
19+
- Test your changes thoroughly to avoid breaking existing functionality
20+
- Update documentation if your contribution affects usage or configuration

README.md

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,71 @@
1-
[![Banner](https://assets.solidjs.com/banner?background=tiles&project=oauth)](https://github.com/solidjs)
2-
31
<div align="center">
42

3+
[![Banner](https://assets.solidjs.com/banner?background=tiles&type=Start&project=oauth)](https://github.com/solidjs/solid-start)
4+
55
[![Version](https://img.shields.io/npm/v/start-oauth.svg?style=for-the-badge&color=blue&logo=npm)](https://www.npmjs.com/package/start-oauth)
66
[![Downloads](https://img.shields.io/npm/dm/start-oauth.svg?style=for-the-badge&color=green&logo=npm)](https://www.npmjs.com/package/start-oauth)
77
[![Stars](https://img.shields.io/github/stars/thomasbuilds/start-oauth.svg?style=for-the-badge&color=yellow&logo=github)](https://github.com/thomasbuilds/start-oauth)
88
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=for-the-badge&logo=prettier&logoColor=white)](https://github.com/prettier/prettier)
99

1010
</div>
1111

12-
Lightweight and secure OAuth 2.1 for [SolidStart](https://github.com/solidjs/solid-start)access the `name`, `email`, and `image` of authenticated users.
12+
**Lightweight and Secure OAuth2 for [SolidStart](https://start.solidjs.com)**Access the `name`, `email`, and when available `image` of authenticated users.
1313
For extended usage, the `provider` name and access `token` are included in the `oauth` object.
1414

15-
**Supported Providers:** Amazon, Discord, GitHub, Google, LinkedIn, Microsoft, Spotify, and Yahoo
15+
**Supported Providers:** Amazon, Discord, GitHub, Google, LinkedIn, Microsoft, Spotify, X, and Yahoo
1616

1717
## Installation
1818

19-
```bash
20-
# using npm
21-
npm install start-oauth
22-
```
23-
24-
```bash
25-
# using pnpm
26-
pnpm add start-oauth
27-
```
19+
Add `start-oauth` as a dependency in your **SolidStart** app
2820

2921
```bash
30-
# using bun
31-
bun add start-oauth
22+
# use preferred package manager
23+
npm add start-oauth
3224
```
3325

3426
## Configuration
3527

3628
Create a catch-all API route at `routes/api/oauth/[...oauth].ts`
3729

3830
```ts
31+
import OAuth from "start-oauth";
3932
import { redirect } from "@solidjs/router";
40-
import OAuth, { type Configuration } from "start-oauth";
4133

42-
const config: Configuration = {
43-
password: process.env.SESSION_SECRET,
34+
export const GET = OAuth({
35+
password: process.env.PASSWORD!, // openssl rand -hex 32
4436
discord: {
45-
id: process.env.DISCORD_ID,
46-
secret: process.env.DISCORD_SECRET,
37+
id: process.env.DISCORD_ID!,
38+
secret: process.env.DISCORD_SECRET!
4739
},
4840
google: {
49-
id: process.env.GOOGLE_ID,
50-
secret: process.env.GOOGLE_SECRET,
41+
id: process.env.GOOGLE_ID!,
42+
secret: process.env.GOOGLE_SECRET!
5143
},
5244
async handler({ name, email, image, oauth }, redirectTo) {
53-
// implement your logic (e.g. database call, session creation)
54-
const session = await getSession();
55-
await session.update({ name, email, image });
45+
// add your logic (e.g. database call, session creation)
46+
// const session = await getSession();
47+
// await session.update({ name, email, image });
5648

57-
// then redirect user
5849
return redirect(
5950
// only allow internal redirects
6051
redirectTo?.startsWith("/") && !redirectTo.startsWith("//")
6152
? redirectTo
62-
: "/default"
53+
: "/defaultPage"
6354
);
64-
},
65-
};
66-
67-
export const GET = OAuth(config);
55+
}
56+
});
6857
```
6958

7059
In your OAuth provider's dashboard, set the redirect URIs
7160

72-
- **Production**: `https://your-domain.com/api/oauth/[provider]`
7361
- **Development**: `http://localhost:3000/api/oauth/[provider]`
62+
- **Production**: `https://your-domain.com/api/oauth/[provider]`
7463

7564
## Usage
7665

7766
```tsx
78-
// for example routes/login.tsx
79-
import useOAuthLogin from "start-oauth/client";
67+
// for example in routes/login.tsx
68+
import { useOAuthLogin } from "start-oauth";
8069

8170
export default function Login() {
8271
const login = useOAuthLogin();
@@ -103,17 +92,17 @@ See `start-oauth` in action with the SolidStart [with-auth](https://github.com/s
10392

10493
```bash
10594
# using npm
106-
npm create solid -- --s --t with-auth
95+
npm create solid@latest -- -s -t with-auth
10796
```
10897

10998
```bash
11099
# using pnpm
111-
pnpm create solid --s --t with-auth
100+
pnpm create solid@latest -s -t with-auth
112101
```
113102

114103
```bash
115104
# using bun
116-
bun create solid --s --t with-auth
105+
bun create solid@latest --s --t with-auth
117106
```
118107

119108
## Security Features
@@ -122,7 +111,3 @@ bun create solid --s --t with-auth
122111
- AES-256-GCM encryption for state parameters to prevent tampering
123112
- Timeout-protected HTTP requests to avoid hanging connections
124113
- Strict validation of fallback URLs to prevent open redirects
125-
126-
## Contributing
127-
128-
Contributions are welcome! To add a new provider, duplicate an existing [provider](src/providers/google.ts), update the configuration links, and submit a pull request!

package.json

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
11
{
22
"name": "start-oauth",
3-
"version": "1.2.6",
4-
"description": "Lightweight and secure OAuth2 for SolidStart",
3+
"version": "1.3.0",
4+
"description": "Lightweight and Secure OAuth2 for SolidStart",
5+
"keywords": [
6+
"api",
7+
"oauth2",
8+
"crypto",
9+
"solidjs",
10+
"solid-router",
11+
"solidstart"
12+
],
513
"homepage": "https://github.com/thomasbuilds/start-oauth#readme",
14+
"bugs": {
15+
"url": "https://github.com/thomasbuilds/start-oauth/issues"
16+
},
617
"repository": {
718
"type": "git",
819
"url": "git+https://github.com/thomasbuilds/start-oauth.git"
920
},
10-
"bugs": {
11-
"url": "https://github.com/thomasbuilds/start-oauth/issues"
12-
},
21+
"license": "MIT",
22+
"author": "thomasbuilds",
23+
"sideEffects": false,
1324
"type": "module",
14-
"types": "src/index.ts",
15-
"exports": {
16-
".": "./src/index.ts",
17-
"./client": "./src/client.ts"
18-
},
25+
"main": "src/index.ts",
1926
"files": [
2027
"src"
2128
],
22-
"author": "thomasbuilds",
23-
"keywords": [
24-
"api",
25-
"oauth2",
26-
"solidstart",
27-
"crypto"
28-
],
29-
"license": "MIT",
30-
"sideEffects": false,
29+
"scripts": {
30+
"format": "prettier --write . --trailing-comma none"
31+
},
32+
"devDependencies": {
33+
"@types/node": "^24.3.1",
34+
"prettier": "^3.6.2"
35+
},
3136
"peerDependencies": {
3237
"@solidjs/router": "^0.15.3",
3338
"@solidjs/start": "^1.1.7"
3439
},
35-
"devDependencies": {
36-
"@types/node": "^24.3.0"
37-
},
3840
"engines": {
3941
"node": ">=22"
4042
}

0 commit comments

Comments
 (0)