sveltekit-auth-example 2.0.2 → 2.0.3
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 +1 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +6 -1
- package/{.eslintrc.cjs → eslint.config.js} +1 -2
- package/package.json +3 -3
- package/prettier.config.mjs +2 -0
- package/src/lib/google.ts +2 -2
- package/src/routes/api/v1/user/+server.ts +1 -1
- package/src/routes/auth/[slug]/+server.ts +1 -1
- package/src/routes/auth/forgot/+server.ts +1 -1
- package/src/routes/auth/google/+server.ts +1 -1
- package/src/routes/auth/reset/+server.ts +1 -1
- package/src/routes/auth/reset/[token]/+page.ts +1 -1
- package/src/service-worker.ts +3 -3
- package/vite.config.ts +11 -0
- package/.prettierignore +0 -14
- package/vite.config.js +0 -16
package/.eslintignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
- Add password complexity checking on /register and /profile pages (only checks for length currently despite what the pages say)
|
|
4
4
|
|
|
5
|
+
# 2.0.3
|
|
6
|
+
- Move to eslint's new eslint.config.js
|
|
7
|
+
- Convert vite.config to TypeScript
|
|
8
|
+
|
|
5
9
|
# 2.0.2
|
|
6
|
-
|
|
10
|
+
|
|
11
|
+
- Fix prettier
|
|
7
12
|
|
|
8
13
|
# 2.0.1
|
|
9
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
root: true,
|
|
3
3
|
parser: '@typescript-eslint/parser',
|
|
4
4
|
extends: [
|
|
@@ -9,7 +9,6 @@ module.exports = {
|
|
|
9
9
|
],
|
|
10
10
|
plugins: ['@typescript-eslint'],
|
|
11
11
|
ignorePatterns: ['*.cjs'],
|
|
12
|
-
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
|
|
13
12
|
parserOptions: {
|
|
14
13
|
sourceType: 'module',
|
|
15
14
|
ecmaVersion: 2020,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveltekit-auth-example",
|
|
3
3
|
"description": "SvelteKit Authentication Example",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"author": "Nate Stuyvesant",
|
|
6
6
|
"license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
|
|
7
7
|
"repository": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"preview": "vite preview",
|
|
28
28
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
29
29
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
30
|
-
"lint": "prettier --check . && eslint .",
|
|
31
|
-
"format": "prettier --write ."
|
|
30
|
+
"lint": "prettier --check . && eslint . --ignore-path ./.eslintignore",
|
|
31
|
+
"format": "prettier --write . --ignore-path ./.eslintignore"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": "^18.19.0"
|
package/prettier.config.mjs
CHANGED
package/src/lib/google.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function renderGoogleButton() {
|
|
|
17
17
|
|
|
18
18
|
export function initializeGoogleAccounts() {
|
|
19
19
|
let initialized = false
|
|
20
|
-
const unsubscribe = googleInitialized.subscribe(
|
|
20
|
+
const unsubscribe = googleInitialized.subscribe(value => {
|
|
21
21
|
initialized = value
|
|
22
22
|
})
|
|
23
23
|
|
|
@@ -46,7 +46,7 @@ export function initializeGoogleAccounts() {
|
|
|
46
46
|
const { role } = fromEndpoint.user
|
|
47
47
|
|
|
48
48
|
let referrer
|
|
49
|
-
const unsubscribe = page.subscribe(
|
|
49
|
+
const unsubscribe = page.subscribe(p => {
|
|
50
50
|
referrer = p.url.searchParams.get('referrer')
|
|
51
51
|
})
|
|
52
52
|
unsubscribe()
|
|
@@ -2,7 +2,7 @@ import { error, json } from '@sveltejs/kit'
|
|
|
2
2
|
import type { RequestHandler } from './$types'
|
|
3
3
|
import { query } from '$lib/server/db'
|
|
4
4
|
|
|
5
|
-
export const PUT: RequestHandler = async
|
|
5
|
+
export const PUT: RequestHandler = async event => {
|
|
6
6
|
const { user } = event.locals
|
|
7
7
|
|
|
8
8
|
if (!user) error(401, 'Unauthorized - must be logged-in.')
|
|
@@ -2,7 +2,7 @@ import { error, json } from '@sveltejs/kit'
|
|
|
2
2
|
import type { RequestHandler } from './$types'
|
|
3
3
|
import { query } from '$lib/server/db'
|
|
4
4
|
|
|
5
|
-
export const POST: RequestHandler = async
|
|
5
|
+
export const POST: RequestHandler = async event => {
|
|
6
6
|
const { cookies } = event
|
|
7
7
|
const { slug } = event.params
|
|
8
8
|
|
|
@@ -6,7 +6,7 @@ import { JWT_SECRET, DOMAIN, SENDGRID_SENDER } from '$env/static/private'
|
|
|
6
6
|
import { query } from '$lib/server/db'
|
|
7
7
|
import { sendMessage } from '$lib/server/sendgrid'
|
|
8
8
|
|
|
9
|
-
export const POST: RequestHandler = async
|
|
9
|
+
export const POST: RequestHandler = async event => {
|
|
10
10
|
const body = await event.request.json()
|
|
11
11
|
const sql = `SELECT id as "userId" FROM users WHERE email = $1 LIMIT 1;`
|
|
12
12
|
const { rows } = await query(sql, [body.email])
|
|
@@ -41,7 +41,7 @@ async function upsertGoogleUser(user: Partial<User>): Promise<UserSession> {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Returns local user if Google user authenticated (and authorized our app)
|
|
44
|
-
export const POST: RequestHandler = async
|
|
44
|
+
export const POST: RequestHandler = async event => {
|
|
45
45
|
const { cookies } = event
|
|
46
46
|
|
|
47
47
|
try {
|
|
@@ -5,7 +5,7 @@ import jwt from 'jsonwebtoken'
|
|
|
5
5
|
import { JWT_SECRET } from '$env/static/private'
|
|
6
6
|
import { query } from '$lib/server/db'
|
|
7
7
|
|
|
8
|
-
export const PUT: RequestHandler = async
|
|
8
|
+
export const PUT: RequestHandler = async event => {
|
|
9
9
|
const body = await event.request.json()
|
|
10
10
|
const { token, password } = body
|
|
11
11
|
|
package/src/service-worker.ts
CHANGED
|
@@ -15,7 +15,7 @@ const ASSETS = [
|
|
|
15
15
|
...files // everything in `static`
|
|
16
16
|
]
|
|
17
17
|
|
|
18
|
-
sw.addEventListener('install',
|
|
18
|
+
sw.addEventListener('install', event => {
|
|
19
19
|
// Create a new cache and add all files to it
|
|
20
20
|
async function addFilesToCache() {
|
|
21
21
|
const cache = await caches.open(CACHE)
|
|
@@ -25,7 +25,7 @@ sw.addEventListener('install', (event) => {
|
|
|
25
25
|
event.waitUntil(addFilesToCache())
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
sw.addEventListener('activate',
|
|
28
|
+
sw.addEventListener('activate', event => {
|
|
29
29
|
// Remove previous cached data from disk
|
|
30
30
|
async function deleteOldCaches() {
|
|
31
31
|
for (const key of await caches.keys()) {
|
|
@@ -36,7 +36,7 @@ sw.addEventListener('activate', (event) => {
|
|
|
36
36
|
event.waitUntil(deleteOldCaches())
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
sw.addEventListener('fetch',
|
|
39
|
+
sw.addEventListener('fetch', event => {
|
|
40
40
|
// ignore POST requests etc
|
|
41
41
|
if (event.request.method !== 'GET') return
|
|
42
42
|
|
package/vite.config.ts
ADDED
package/.prettierignore
DELETED
package/vite.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { sveltekit } from '@sveltejs/kit/vite'
|
|
2
|
-
|
|
3
|
-
/** @type {import('vite').UserConfig} */
|
|
4
|
-
const config = {
|
|
5
|
-
plugins: [sveltekit()],
|
|
6
|
-
serviceWorker: {
|
|
7
|
-
files: (filepath) => !/\.DS_Store/.test(filepath)
|
|
8
|
-
},
|
|
9
|
-
server: {
|
|
10
|
-
host: 'localhost',
|
|
11
|
-
port: 3000,
|
|
12
|
-
open: 'http://localhost:3000'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default config
|