sveltekit-auth-example 1.0.14 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/package.json +10 -10
- package/src/routes/+layout.server.ts +2 -1
- package/src/routes/+layout.svelte +2 -2
- package/src/routes/api/v1/user/+server.ts +3 -3
- package/src/routes/auth/[slug]/+server.ts +2 -2
- package/src/routes/auth/forgot/+server.ts +2 -2
- package/src/routes/auth/google/+server.ts +2 -2
- package/src/routes/auth/reset/+server.ts +1 -1
- package/src/routes/register/+page.server.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
# Backlog
|
|
2
|
-
*
|
|
2
|
+
* Add username and Avatar icon to menu bar
|
|
3
|
+
* [Possible Bug] Getting HTTP 401 on https://play.google.com/log?format=json&hasfast=true&authuser=0 from google-auth-library. As I didn't explicitly request logging, it could be that Safari is preventing Google from further invading our privacy. Will require some investigation. The site works regardless.
|
|
3
4
|
* Consider not setting defaultUser in loginSession as it would simplify +layout.svelte.
|
|
4
5
|
* Refactor $env/dynamic/private and public
|
|
5
6
|
* Add password complexity checking on /register and /profile pages (only checks for length currently despite what the pages say)
|
|
6
7
|
|
|
8
|
+
# 1.0.18
|
|
9
|
+
* Bump dependencies
|
|
10
|
+
|
|
11
|
+
# 1.0.17
|
|
12
|
+
* Bump dependencies
|
|
13
|
+
|
|
14
|
+
# 1.0.16
|
|
15
|
+
* [Bug] Fixed LayoutServerLoad typing
|
|
16
|
+
|
|
17
|
+
# 1.0.15
|
|
18
|
+
* [Bug] Replaced use of Action type in +server.ts files (only works for +page.server.ts)
|
|
19
|
+
|
|
7
20
|
# 1.0.14
|
|
8
21
|
* Refactor routing to be folder, not file-based - https://github.com/sveltejs/kit/discussions/5774 (file system router). More info: https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3294867
|
|
9
22
|
* Move bootstrap SCSS import to JavaScript in +layout.svelte
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveltekit-auth-example",
|
|
3
3
|
"description": "SvelteKit Authentication Example",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.18",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Nate Stuyvesant",
|
|
7
7
|
"license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": "~18.8.0",
|
|
37
|
-
"npm": "^8.
|
|
37
|
+
"npm": "^8.19.1"
|
|
38
38
|
},
|
|
39
39
|
"type": "module",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"cookie": "^0.5.0",
|
|
42
|
-
"dotenv": "^16.0.
|
|
43
|
-
"google-auth-library": "^8.
|
|
42
|
+
"dotenv": "^16.0.2",
|
|
43
|
+
"google-auth-library": "^8.5.1",
|
|
44
44
|
"jsonwebtoken": "^8.5.1",
|
|
45
45
|
"pg": "^8.8.0"
|
|
46
46
|
},
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@types/google.accounts": "0.0.2",
|
|
53
53
|
"@types/jsonwebtoken": "^8.5.9",
|
|
54
54
|
"@types/pg": "^8.6.5",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
56
|
-
"@typescript-eslint/parser": "^5.
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
|
56
|
+
"@typescript-eslint/parser": "^5.36.1",
|
|
57
57
|
"bootstrap": "^5.2.0",
|
|
58
58
|
"bootstrap-icons": "^1.9.1",
|
|
59
59
|
"eslint": "^8.23.0",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
62
62
|
"prettier": "^2.7.1",
|
|
63
63
|
"prettier-plugin-svelte": "^2.7.0",
|
|
64
|
-
"sass": "^1.54.
|
|
65
|
-
"svelte": "^3.
|
|
66
|
-
"svelte-check": "^2.
|
|
64
|
+
"sass": "^1.54.8",
|
|
65
|
+
"svelte": "^3.50.0",
|
|
66
|
+
"svelte-check": "^2.9.0",
|
|
67
67
|
"svelte-preprocess": "^4.10.7",
|
|
68
68
|
"tslib": "^2.4.0",
|
|
69
69
|
"typescript": "^4.7.4",
|
|
70
|
-
"vite": "^3.0
|
|
70
|
+
"vite": "^3.1.0"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LayoutServerLoad } from './$types'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const load: LayoutServerLoad = (event) => {
|
|
4
|
+
const locals = event.locals
|
|
4
5
|
const { user }: { user: User } = locals // locals.user set by hooks.ts/handle(), undefined if not logged in
|
|
5
6
|
return {
|
|
6
7
|
user
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte'
|
|
3
|
-
import type {
|
|
3
|
+
import type { LayoutServerData } from './$types'
|
|
4
4
|
import { goto } from '$app/navigation'
|
|
5
5
|
import { page } from '$app/stores'
|
|
6
6
|
import { loginSession, toast } from '../stores'
|
|
7
7
|
import useAuth from '$lib/auth'
|
|
8
8
|
import 'bootstrap/scss/bootstrap.scss' // preferred way to load Bootstrap SCSS for hot module reloading
|
|
9
9
|
|
|
10
|
-
export let data:
|
|
10
|
+
export let data: LayoutServerData
|
|
11
11
|
|
|
12
12
|
// If returning from different website, runs once (as it's an SPA) to restore user session if session cookie is still valid
|
|
13
13
|
const { user } = data
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { error, json
|
|
2
|
-
import type {
|
|
1
|
+
import { error, json} from '@sveltejs/kit'
|
|
2
|
+
import type { RequestHandler } from './$types'
|
|
3
3
|
import { query } from '../../../_db'
|
|
4
4
|
|
|
5
|
-
export const PUT:
|
|
5
|
+
export const PUT: RequestHandler = async event => {
|
|
6
6
|
const { user } = event.locals
|
|
7
7
|
|
|
8
8
|
if (!user)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { error, json } from '@sveltejs/kit'
|
|
2
|
-
import type {
|
|
2
|
+
import type { RequestHandler } from './$types'
|
|
3
3
|
import { query } from '../../_db'
|
|
4
4
|
|
|
5
|
-
export const POST:
|
|
5
|
+
export const POST: RequestHandler = async (event) => {
|
|
6
6
|
const { slug } = event.params
|
|
7
7
|
|
|
8
8
|
let result
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestHandler } from './$types'
|
|
2
2
|
import type { Secret } from 'jsonwebtoken'
|
|
3
3
|
import jwt from 'jsonwebtoken'
|
|
4
4
|
import dotenv from 'dotenv'
|
|
@@ -9,7 +9,7 @@ dotenv.config()
|
|
|
9
9
|
const DOMAIN = process.env.DOMAIN
|
|
10
10
|
const JWT_SECRET = process.env.JWT_SECRET
|
|
11
11
|
|
|
12
|
-
export const POST:
|
|
12
|
+
export const POST: RequestHandler = async event => {
|
|
13
13
|
const body = await event.request.json()
|
|
14
14
|
const sql = `SELECT id as "userId" FROM users WHERE email = $1 LIMIT 1;`
|
|
15
15
|
const { rows } = await query(sql, [body.email])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@sveltejs/kit'
|
|
2
|
-
import type {
|
|
2
|
+
import type { RequestHandler } from './$types'
|
|
3
3
|
import { OAuth2Client } from 'google-auth-library'
|
|
4
4
|
import { query } from '../../_db';
|
|
5
5
|
import { config } from '$lib/config'
|
|
@@ -42,7 +42,7 @@ async function upsertGoogleUser(user: Partial<User>): Promise<UserSession> {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// Returns local user if Google user authenticated (and authorized our app)
|
|
45
|
-
export const POST:
|
|
45
|
+
export const POST: RequestHandler = async event => {
|
|
46
46
|
try {
|
|
47
47
|
const { token } = await event.request.json()
|
|
48
48
|
const user = await getGoogleUserFromJWT(token)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { json as json$1 } from '@sveltejs/kit';
|
|
2
2
|
import dotenv from 'dotenv'
|
|
3
|
-
import type { RequestHandler } from '
|
|
3
|
+
import type { RequestHandler } from './$types'
|
|
4
4
|
import type { JwtPayload } from 'jsonwebtoken'
|
|
5
5
|
import jwt from 'jsonwebtoken'
|
|
6
6
|
import { query } from '../../_db'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { redirect } from '@sveltejs/kit'
|
|
1
|
+
import { redirect } from '@sveltejs/kit'
|
|
2
2
|
import type { PageServerLoad } from './$types'
|
|
3
3
|
|
|
4
4
|
export const load: PageServerLoad = ({ locals }) => {
|
|
5
5
|
const { user } = locals
|
|
6
6
|
if (user) { // Redirect to home if user is logged in already
|
|
7
|
-
throw redirect(302, '/')
|
|
7
|
+
throw redirect(302, '/')
|
|
8
8
|
}
|
|
9
9
|
return {}
|
|
10
10
|
}
|