sveltekit-auth-example 1.0.39 → 1.0.40
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/.eslintignore +13 -0
- package/README.md +3 -4
- package/package.json +9 -9
- package/src/app.d.ts +0 -9
- package/src/routes/+layout.svelte +0 -1
- package/src/routes/register/+page.svelte +0 -1
- package/svelte.config.js +2 -2
- package/.env-sample +0 -6
package/.eslintignore
ADDED
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# SvelteKit Authentication and Authorization Example
|
|
2
2
|
|
|
3
3
|
This is an example of how to register, authenticate, and update users and limit their access to
|
|
4
|
-
areas of the website by role (admin, teacher, student).
|
|
5
|
-
maintain compatibility with the latest release and leverage new APIs.
|
|
4
|
+
areas of the website by role (admin, teacher, student). It includes profile management and password resets via SendGrid.
|
|
6
5
|
|
|
7
6
|
It's a Single Page App (SPA) built with SvelteKit and a PostgreSQL database back-end. Code is TypeScript and the website is styled using Bootstrap. PostgreSQL functions handle password hashing and UUID generation for the session ID. Unlike most authentication examples, this SPA does not use callbacks that redirect back to the site (causing the website to be reloaded with a visual flash).
|
|
8
7
|
|
|
@@ -31,8 +30,8 @@ The forgot password / password reset functionality uses a JWT and [**SendGrid**]
|
|
|
31
30
|
|
|
32
31
|
## Prerequisites
|
|
33
32
|
- PostgreSQL 14.5 or higher
|
|
34
|
-
- Node.js 18.
|
|
35
|
-
- npm 9.
|
|
33
|
+
- Node.js 18.12.1 or higher
|
|
34
|
+
- npm 9.2.0 or higher
|
|
36
35
|
- Google API client
|
|
37
36
|
- Twilio SendGrid account (only used for emailing password reset link - the sample can run without it but forgot password will not work)
|
|
38
37
|
|
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.40",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Nate Stuyvesant",
|
|
7
7
|
"license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"format": "prettier --write ."
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=18.
|
|
35
|
+
"node": ">=18.12.1",
|
|
36
36
|
"npm": "^9.2.0"
|
|
37
37
|
},
|
|
38
38
|
"type": "module",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"pg": "^8.8.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@sveltejs/adapter-node": "
|
|
45
|
-
"@sveltejs/kit": "
|
|
44
|
+
"@sveltejs/adapter-node": "^1.0.0",
|
|
45
|
+
"@sveltejs/kit": "^1.0.0",
|
|
46
46
|
"@types/bootstrap": "5.2.6",
|
|
47
47
|
"@types/google.accounts": "0.0.4",
|
|
48
48
|
"@types/jsonwebtoken": "^8.5.9",
|
|
49
49
|
"@types/pg": "^8.6.5",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^5.46.
|
|
51
|
-
"@typescript-eslint/parser": "^5.46.
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
51
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
52
52
|
"bootstrap": "^5.2.3",
|
|
53
53
|
"eslint": "^8.29.0",
|
|
54
54
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"prettier": "^2.8.1",
|
|
59
59
|
"prettier-plugin-svelte": "^2.9.0",
|
|
60
60
|
"sass": "^1.56.2",
|
|
61
|
-
"svelte": "^3.
|
|
61
|
+
"svelte": "^3.55.0",
|
|
62
62
|
"svelte-check": "^2.10.2",
|
|
63
|
-
"svelte-preprocess": "^5.0.0",
|
|
64
63
|
"tslib": "^2.4.1",
|
|
65
64
|
"typescript": "^4.9.4",
|
|
66
|
-
"vite": "^4.0.
|
|
65
|
+
"vite": "^4.0.1",
|
|
66
|
+
"vitest": "^0.25.3"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/app.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
|
-
/// <reference types="bootstrap" />
|
|
4
|
-
/// <reference types="google.accounts" />
|
|
5
|
-
|
|
6
3
|
// See https://kit.svelte.dev/docs/types#app
|
|
7
4
|
// for information about these interfaces
|
|
8
5
|
// and what to do when importing types
|
|
@@ -55,9 +52,3 @@ interface UserSession {
|
|
|
55
52
|
id: string,
|
|
56
53
|
user: User
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
interface Window {
|
|
60
|
-
google?: any
|
|
61
|
-
grecaptcha: any
|
|
62
|
-
bootstrap: Bootstrap
|
|
63
|
-
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { onMount } from 'svelte'
|
|
3
3
|
import type { LayoutServerData } from './$types'
|
|
4
4
|
import { goto, beforeNavigate } from '$app/navigation'
|
|
5
|
-
import { page } from '$app/stores'
|
|
6
5
|
import { loginSession, toast } from '../stores'
|
|
7
6
|
import { initializeGoogleAccounts } from '$lib/google'
|
|
8
7
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte'
|
|
3
3
|
import { goto } from '$app/navigation'
|
|
4
|
-
import { page } from '$app/stores'
|
|
5
4
|
import { loginSession } from '../../stores'
|
|
6
5
|
import { focusOnFirstError } from '$lib/focus'
|
|
7
6
|
import { initializeGoogleAccounts, renderGoogleButton } from '$lib/google'
|
package/svelte.config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import adapter from '@sveltejs/adapter-node'
|
|
2
|
-
import
|
|
2
|
+
import { vitePreprocess } from '@sveltejs/kit/vite';
|
|
3
3
|
|
|
4
4
|
const production = process.env.NODE_ENV === 'production'
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ if (!production) baseCsp.push('ws://localhost:3000')
|
|
|
15
15
|
|
|
16
16
|
/** @type {import('@sveltejs/kit').Config} */
|
|
17
17
|
const config = {
|
|
18
|
-
preprocess:
|
|
18
|
+
preprocess: vitePreprocess(),
|
|
19
19
|
|
|
20
20
|
kit: {
|
|
21
21
|
adapter: adapter({
|
package/.env-sample
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
DATABASE_URL=postgres://REPLACE_WITH_USER:REPLACE_WITH_PASSWORD@localhost:5432/auth
|
|
2
|
-
DOMAIN=http://localhost:3000
|
|
3
|
-
JWT_SECRET=replace_with_your_own
|
|
4
|
-
SENDGRID_KEY=replace_with_your_own
|
|
5
|
-
SENDGRID_SENDER=replace_with_your_own
|
|
6
|
-
PUBLIC_GOOGLE_CLIENT_ID=REPLACE_WITH_YOUR_OWN
|