sveltekit-auth-example 1.0.52 → 1.0.53
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 +4 -0
- package/package.json +13 -13
- package/src/service-worker.ts +53 -59
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
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.53
|
|
5
|
+
* Fix service-worker.ts typing
|
|
6
|
+
* Bump pg, sveltekit, svelte, vite, tslib and other devDependencies
|
|
7
|
+
|
|
4
8
|
# 1.0.52
|
|
5
9
|
* Bump @sveltejs/kit, svelte, vite, vitest, pg, adapter-node, google-auth-library, eslint, sass, @typescript*, typescript, prettier, eslint-config-prettier, prettier-plugin-svelte, svelte-check
|
|
6
10
|
|
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.53",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Nate Stuyvesant",
|
|
7
7
|
"license": "https://github.com/nstuyvesant/sveltekit-auth-example/blob/master/LICENSE",
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": "^18.16.0",
|
|
36
|
-
"npm": "^9.6.
|
|
36
|
+
"npm": "^9.6.7"
|
|
37
37
|
},
|
|
38
38
|
"type": "module",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@sendgrid/mail": "^7.7.0",
|
|
41
|
-
"pg": "^8.
|
|
41
|
+
"pg": "^8.11.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@sveltejs/adapter-node": "^1.2.4",
|
|
45
|
-
"@sveltejs/kit": "^1.
|
|
45
|
+
"@sveltejs/kit": "^1.19.0",
|
|
46
46
|
"@types/bootstrap": "5.2.6",
|
|
47
47
|
"@types/google.accounts": "^0.0.7",
|
|
48
48
|
"@types/jsonwebtoken": "^9.0.2",
|
|
49
|
-
"@types/pg": "^8.
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
51
|
-
"@typescript-eslint/parser": "^5.59.
|
|
49
|
+
"@types/pg": "^8.10.1",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
51
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
52
52
|
"bootstrap": "^5.2.3",
|
|
53
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.41.0",
|
|
54
54
|
"eslint-config-prettier": "^8.8.0",
|
|
55
55
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
56
56
|
"google-auth-library": "^8.8.0",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"prettier": "^2.8.8",
|
|
59
59
|
"prettier-plugin-svelte": "^2.10.0",
|
|
60
60
|
"sass": "^1.62.1",
|
|
61
|
-
"svelte": "^3.
|
|
62
|
-
"svelte-check": "^3.
|
|
63
|
-
"tslib": "^2.5.
|
|
61
|
+
"svelte": "^3.59.1",
|
|
62
|
+
"svelte-check": "^3.4.3",
|
|
63
|
+
"tslib": "^2.5.2",
|
|
64
64
|
"typescript": "^5.0.4",
|
|
65
|
-
"vite": "^4.3.
|
|
66
|
-
"vitest": "^0.
|
|
65
|
+
"vite": "^4.3.9",
|
|
66
|
+
"vitest": "^0.31.1"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/service-worker.ts
CHANGED
|
@@ -1,74 +1,68 @@
|
|
|
1
|
+
/// <reference types="@sveltejs/kit" />
|
|
2
|
+
/// <reference no-default-lib="true"/>
|
|
3
|
+
/// <reference lib="esnext" />
|
|
1
4
|
/// <reference lib="webworker" />
|
|
5
|
+
|
|
2
6
|
import { build, files, version } from '$service-worker'
|
|
3
7
|
|
|
4
|
-
const
|
|
5
|
-
const cacheName = `cache${version}`
|
|
6
|
-
const toCache = build.concat(files)
|
|
7
|
-
const staticAssets = new Set(toCache)
|
|
8
|
+
const sw = self as unknown as ServiceWorkerGlobalScope
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
event.waitUntil(
|
|
12
|
-
caches
|
|
13
|
-
.open(cacheName)
|
|
14
|
-
.then(cache => cache.addAll(toCache))
|
|
15
|
-
.then(() => {
|
|
16
|
-
worker.skipWaiting()
|
|
17
|
-
})
|
|
18
|
-
.catch(error => console.error(error))
|
|
19
|
-
)
|
|
20
|
-
})
|
|
10
|
+
// Create a unique cache name for this deployment
|
|
11
|
+
const CACHE = `cache-${version}`
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
13
|
+
const ASSETS = [
|
|
14
|
+
...build, // the app itself
|
|
15
|
+
...files // everything in `static`
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
sw.addEventListener('install', (event) => {
|
|
19
|
+
// Create a new cache and add all files to it
|
|
20
|
+
async function addFilesToCache() {
|
|
21
|
+
const cache = await caches.open(CACHE)
|
|
22
|
+
await cache.addAll(ASSETS)
|
|
23
|
+
}
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const cache = await caches.open(`offline${version}`)
|
|
25
|
+
event.waitUntil(addFilesToCache())
|
|
26
|
+
})
|
|
38
27
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (response) return response
|
|
46
|
-
throw err
|
|
28
|
+
sw.addEventListener('activate', (event) => {
|
|
29
|
+
// Remove previous cached data from disk
|
|
30
|
+
async function deleteOldCaches() {
|
|
31
|
+
for (const key of await caches.keys()) {
|
|
32
|
+
if (key !== CACHE) await caches.delete(key)
|
|
33
|
+
}
|
|
47
34
|
}
|
|
48
|
-
}
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
event.waitUntil(deleteOldCaches())
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
sw.addEventListener('fetch', (event) => {
|
|
40
|
+
// ignore POST requests etc
|
|
41
|
+
if (event.request.method !== 'GET') return
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
async function respond() {
|
|
44
|
+
const url = new URL(event.request.url)
|
|
45
|
+
const cache = await caches.open(CACHE)
|
|
55
46
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const skipBecauseUncached = event.request.cache === 'only-if-cached' && !isStaticAsset
|
|
47
|
+
// `build`/`files` can always be served from the cache
|
|
48
|
+
if (ASSETS.includes(url.pathname)) {
|
|
49
|
+
return cache.match(url.pathname)
|
|
50
|
+
}
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// if your application has other URLs with data that will never change,
|
|
67
|
-
// set this variable to true for them and they will only be fetched once.
|
|
68
|
-
const cachedAsset = isStaticAsset && (await caches.match(event.request))
|
|
52
|
+
// for everything else, try the network first, but
|
|
53
|
+
// fall back to the cache if we're offline
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(event.request)
|
|
69
56
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
if (response.status === 200) {
|
|
58
|
+
cache.put(event.request, response.clone())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return response
|
|
62
|
+
} catch {
|
|
63
|
+
return cache.match(event.request)
|
|
64
|
+
}
|
|
73
65
|
}
|
|
66
|
+
|
|
67
|
+
event.respondWith(respond() as PromiseLike<Response>)
|
|
74
68
|
})
|