sveltekit-auth-example 1.0.25 → 1.0.27

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 CHANGED
@@ -1,6 +1,13 @@
1
1
  # Backlog
2
2
  * Add password complexity checking on /register and /profile pages (only checks for length currently despite what the pages say)
3
3
 
4
+ # 1.0.27
5
+ * Update dependencies
6
+
7
+ # 1.0.26
8
+ * On the client, track whether the login session has expired and if so, clear $loginSession
9
+ * Update dependencies
10
+
4
11
  # 1.0.25
5
12
  * Bump dependencies
6
13
  * Simplify Sign In With Google
package/README.md CHANGED
@@ -31,8 +31,8 @@ The forgot password / password reset functionality uses a JWT and [**SendInBlue*
31
31
 
32
32
  ## Prerequisites
33
33
  - PostgreSQL 14.5 or higher
34
- - Node.js 18.9.0 or higher
35
- - npm 8.19.1 or higher
34
+ - Node.js 18.10.0 or higher
35
+ - npm 8.19.2 or higher
36
36
  - Google API client
37
37
  - SendInBlue account (only used for emailing password reset link - the sample can run without it but forgot password will not work)
38
38
 
package/db_create.sql CHANGED
@@ -158,7 +158,8 @@ SELECT json_build_object(
158
158
  'email', users.email,
159
159
  'firstName', users.first_name,
160
160
  'lastName', users.last_name,
161
- 'phone', users.phone
161
+ 'phone', users.phone,
162
+ 'expires', sessions.expires
162
163
  ) AS user
163
164
  FROM sessions
164
165
  INNER JOIN users ON sessions.user_id = users.id
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.25",
4
+ "version": "1.0.27",
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.9.1",
35
+ "node": "~18.10.0",
36
36
  "npm": "^8.19.2"
37
37
  },
38
38
  "type": "module",
@@ -42,26 +42,26 @@
42
42
  "devDependencies": {
43
43
  "@sveltejs/adapter-node": "latest",
44
44
  "@sveltejs/kit": "latest",
45
- "@types/bootstrap": "5.2.4",
45
+ "@types/bootstrap": "5.2.5",
46
46
  "@types/google.accounts": "0.0.2",
47
47
  "@types/jsonwebtoken": "^8.5.9",
48
48
  "@types/pg": "^8.6.5",
49
- "@typescript-eslint/eslint-plugin": "^5.38.0",
50
- "@typescript-eslint/parser": "^5.38.0",
51
- "bootstrap": "^5.2.1",
52
- "eslint": "^8.24.0",
49
+ "@typescript-eslint/eslint-plugin": "^5.39.0",
50
+ "@typescript-eslint/parser": "^5.39.0",
51
+ "bootstrap": "^5.2.2",
52
+ "eslint": "^8.25.0",
53
53
  "eslint-config-prettier": "^8.5.0",
54
54
  "eslint-plugin-svelte3": "^4.0.0",
55
55
  "google-auth-library": "^8.5.2",
56
56
  "jsonwebtoken": "^8.5.1",
57
57
  "prettier": "^2.7.1",
58
- "prettier-plugin-svelte": "^2.7.0",
58
+ "prettier-plugin-svelte": "^2.7.1",
59
59
  "sass": "^1.55.0",
60
60
  "svelte": "^3.50.1",
61
- "svelte-check": "^2.9.0",
61
+ "svelte-check": "^2.9.1",
62
62
  "svelte-preprocess": "^4.10.7",
63
63
  "tslib": "^2.4.0",
64
- "typescript": "^4.8.3",
65
- "vite": "^3.1.3"
64
+ "typescript": "^4.8.4",
65
+ "vite": "^3.1.6"
66
66
  }
67
67
  }
package/src/app.d.ts CHANGED
@@ -91,6 +91,7 @@ interface SendInBlueRequest extends RequestInit {
91
91
 
92
92
  interface UserProperties {
93
93
  id: number
94
+ expires?: string // ISO-8601 datetime
94
95
  role: 'student' | 'teacher' | 'admin'
95
96
  password?: string
96
97
  firstName?: string
@@ -99,7 +100,7 @@ interface UserProperties {
99
100
  phone?: string
100
101
  }
101
102
 
102
- type User = UserProperties | undefined
103
+ type User = UserProperties | undefined | null
103
104
 
104
105
  interface UserSession {
105
106
  id: string,
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte'
3
3
  import type { LayoutServerData } from './$types'
4
- import { goto } from '$app/navigation'
4
+ import { goto, beforeNavigate } from '$app/navigation'
5
5
  import { page } from '$app/stores'
6
6
  import { loginSession, toast } from '../stores'
7
7
  import { PUBLIC_GOOGLE_CLIENT_ID } from '$env/static/public'
@@ -15,6 +15,15 @@
15
15
 
16
16
  let Toast: any
17
17
 
18
+ beforeNavigate( () => {
19
+ let expirationDate = $loginSession?.expires ? new Date($loginSession.expires) : undefined
20
+
21
+ if (expirationDate && expirationDate < new Date()) {
22
+ console.log('Login session expired.')
23
+ $loginSession = null
24
+ }
25
+ })
26
+
18
27
  onMount(async () => {
19
28
  await import('bootstrap/js/dist/collapse') // lots of ways to load Bootstrap but prefer this approach to avoid SSR issues
20
29
  await import('bootstrap/js/dist/dropdown')