sveltekit-auth-example 1.0.30 → 1.0.32

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,16 @@
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.32
5
+ * Remove window from reference to google.accounts
6
+ * Add apple-touch-icon.png
7
+ * Update dependencies
8
+ * Remove dead code
9
+
10
+ # 1.0.31
11
+ * Cleanup
12
+ * Update SvelteKit
13
+
4
14
  # 1.0.30
5
15
  * Fixed bug where opening /login or /register would fail to render Sign in With Google button (onMount in +layout.svelte loads after children's onMount)
6
16
  * Fix bad path for favicon
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.30",
4
+ "version": "1.0.32",
5
5
  "private": false,
6
6
  "author": "Nate Stuyvesant",
7
7
  "license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "engines": {
35
35
  "node": "~18.11.0",
36
- "npm": "^8.19.2"
36
+ "npm": "^8.19.3"
37
37
  },
38
38
  "type": "module",
39
39
  "dependencies": {
@@ -56,7 +56,7 @@
56
56
  "jsonwebtoken": "^8.5.1",
57
57
  "prettier": "^2.7.1",
58
58
  "prettier-plugin-svelte": "^2.8.0",
59
- "sass": "^1.55.0",
59
+ "sass": "^1.56.0",
60
60
  "svelte": "^3.52.0",
61
61
  "svelte-check": "^2.9.2",
62
62
  "svelte-preprocess": "^4.10.7",
package/src/app.d.ts CHANGED
@@ -40,19 +40,6 @@ interface Credentials {
40
40
  password: string
41
41
  }
42
42
 
43
- interface GoogleCredentialResponse {
44
- credential: string
45
- select_by:
46
- | 'auto'
47
- | 'user'
48
- | 'user_1tap'
49
- | 'user_2tap'
50
- | 'btn'
51
- | 'btn_confirm'
52
- | 'btn_add_session'
53
- | 'btn_confirm_add_session'
54
- }
55
-
56
43
  interface MessageAddressee {
57
44
  email: string
58
45
  name?: string
package/src/lib/google.ts CHANGED
@@ -1,9 +1,7 @@
1
- import type { Page } from '@sveltejs/kit'
2
1
  import { page } from '$app/stores'
3
2
  import { goto } from '$app/navigation'
4
3
  import { PUBLIC_GOOGLE_CLIENT_ID } from '$env/static/public'
5
4
  import { googleInitialized, loginSession } from '../stores'
6
- import type { Readable } from 'svelte/store'
7
5
 
8
6
  export function renderGoogleButton() {
9
7
  const btn = document.getElementById('googleButton')
@@ -24,7 +22,7 @@ export function initializeGoogleAccounts() {
24
22
  })
25
23
 
26
24
  if (!initialized) {
27
- window.google.accounts.id.initialize({
25
+ google.accounts.id.initialize({
28
26
  client_id: PUBLIC_GOOGLE_CLIENT_ID,
29
27
  callback: googleCallback
30
28
  })
@@ -35,27 +35,6 @@
35
35
  if (!$loginSession) google.accounts.id.prompt()
36
36
  })
37
37
 
38
- async function googleCallback(response: google.accounts.id.CredentialResponse) {
39
- const res = await fetch('/auth/google', {
40
- method: 'POST',
41
- headers: {
42
- 'Content-Type': 'application/json'
43
- },
44
- body: JSON.stringify({ token: response.credential })
45
- })
46
-
47
- if (res.ok) {
48
- const fromEndpoint = await res.json()
49
- loginSession.set(fromEndpoint.user) // update loginSession store
50
- const { role } = fromEndpoint.user
51
- const referrer = $page.url.searchParams.get('referrer')
52
- if (referrer) return goto(referrer)
53
- if (role === 'teacher') return goto('/teachers')
54
- if (role === 'admin') return goto('/admin')
55
- if (location.pathname === '/login') goto('/') // logged in so go home
56
- }
57
- }
58
-
59
38
  async function logout() {
60
39
  // Request server delete httpOnly cookie called loginSession
61
40
  const url = '/auth/logout'
Binary file