Skip to content

Commit 44baaed

Browse files
authored
refactor: sessions (daedalus-developers#5)
Added UA Parsing and geolocation vendor by default is set
1 parent 2dadebf commit 44baaed

File tree

21 files changed

+465
-374
lines changed

21 files changed

+465
-374
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ STORAGE_SECRET_KEY=secretkey
1818
STORAGE_URL=customdomain or .r2
1919
STORAGE_ENDPOINT=https://your url.r2.cloudflarestorage.com # do not include /bucketname
2020
STORAGE_BUCKET=bucketname
21+
IP_LOCATION_API_KEY=

migrations/0000_absent_strong_guy.sql renamed to migrations/0000_neat_queen_noir.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ CREATE TABLE IF NOT EXISTS "password_reset_token" (
1414
CONSTRAINT "password_reset_token_token_hash_unique" UNIQUE("token_hash")
1515
);
1616
--> statement-breakpoint
17+
CREATE TABLE IF NOT EXISTS "session_details" (
18+
"id" text PRIMARY KEY NOT NULL,
19+
"session_id" text NOT NULL,
20+
"user_agent" text NOT NULL,
21+
"country" text,
22+
"state_province" text,
23+
"city" text,
24+
"latitude" text,
25+
"longitude" text,
26+
"ip_address" text,
27+
"isp" text,
28+
"time_zone" text
29+
);
30+
--> statement-breakpoint
1731
CREATE TABLE IF NOT EXISTS "session" (
1832
"id" text PRIMARY KEY NOT NULL,
1933
"user_id" text NOT NULL,
@@ -71,6 +85,12 @@ EXCEPTION
7185
WHEN duplicate_object THEN null;
7286
END $$;
7387
--> statement-breakpoint
88+
DO $$ BEGIN
89+
ALTER TABLE "session_details" ADD CONSTRAINT "session_details_session_id_session_id_fk" FOREIGN KEY ("session_id") REFERENCES "session"("id") ON DELETE cascade ON UPDATE no action;
90+
EXCEPTION
91+
WHEN duplicate_object THEN null;
92+
END $$;
93+
--> statement-breakpoint
7494
DO $$ BEGIN
7595
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action;
7696
EXCEPTION

migrations/meta/0000_snapshot.json

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "35064190-956d-40a0-a93d-a46ac05477ff",
2+
"id": "95338313-bb57-4942-903f-3503ffec0541",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "5",
55
"dialect": "pg",
@@ -120,6 +120,96 @@
120120
}
121121
}
122122
},
123+
"session_details": {
124+
"name": "session_details",
125+
"schema": "",
126+
"columns": {
127+
"id": {
128+
"name": "id",
129+
"type": "text",
130+
"primaryKey": true,
131+
"notNull": true
132+
},
133+
"session_id": {
134+
"name": "session_id",
135+
"type": "text",
136+
"primaryKey": false,
137+
"notNull": true
138+
},
139+
"user_agent": {
140+
"name": "user_agent",
141+
"type": "text",
142+
"primaryKey": false,
143+
"notNull": true
144+
},
145+
"country": {
146+
"name": "country",
147+
"type": "text",
148+
"primaryKey": false,
149+
"notNull": false
150+
},
151+
"state_province": {
152+
"name": "state_province",
153+
"type": "text",
154+
"primaryKey": false,
155+
"notNull": false
156+
},
157+
"city": {
158+
"name": "city",
159+
"type": "text",
160+
"primaryKey": false,
161+
"notNull": false
162+
},
163+
"latitude": {
164+
"name": "latitude",
165+
"type": "text",
166+
"primaryKey": false,
167+
"notNull": false
168+
},
169+
"longitude": {
170+
"name": "longitude",
171+
"type": "text",
172+
"primaryKey": false,
173+
"notNull": false
174+
},
175+
"ip_address": {
176+
"name": "ip_address",
177+
"type": "text",
178+
"primaryKey": false,
179+
"notNull": false
180+
},
181+
"isp": {
182+
"name": "isp",
183+
"type": "text",
184+
"primaryKey": false,
185+
"notNull": false
186+
},
187+
"time_zone": {
188+
"name": "time_zone",
189+
"type": "text",
190+
"primaryKey": false,
191+
"notNull": false
192+
}
193+
},
194+
"indexes": {},
195+
"foreignKeys": {
196+
"session_details_session_id_session_id_fk": {
197+
"name": "session_details_session_id_session_id_fk",
198+
"tableFrom": "session_details",
199+
"tableTo": "session",
200+
"columnsFrom": [
201+
"session_id"
202+
],
203+
"columnsTo": [
204+
"id"
205+
],
206+
"onDelete": "cascade",
207+
"onUpdate": "no action"
208+
}
209+
},
210+
"compositePrimaryKeys": {},
211+
"uniqueConstraints": {}
212+
},
123213
"session": {
124214
"name": "session",
125215
"schema": "",

migrations/meta/_journal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{
66
"idx": 0,
77
"version": "5",
8-
"when": 1711633355505,
9-
"tag": "0000_absent_strong_guy",
8+
"when": 1711899804575,
9+
"tag": "0000_neat_queen_noir",
1010
"breakpoints": true
1111
}
1212
]

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
"zod2md": "npx zod2md --entry src/lib/types/index.ts --title FormSchemas --output docs/schemas.md"
2828
},
2929
"devDependencies": {
30-
"@playwright/test": "^1.28.1",
30+
"@playwright/test": "^1.42.1",
3131
"@svelte-put/copy": "^3.0.0",
3232
"@svelte-put/qr": "^1.0.5",
3333
"@sveltejs/adapter-auto": "^3.2.0",
3434
"@sveltejs/adapter-node": "^5.0.1",
3535
"@sveltejs/kit": "^2.5.5",
36-
"@sveltejs/vite-plugin-svelte": "^3.0.0",
36+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
3737
"@tailwindcss/forms": "^0.5.7",
3838
"@tailwindcss/typography": "^0.5.12",
3939
"@types/eslint": "^8.56.6",
@@ -44,21 +44,21 @@
4444
"autoprefixer": "^10.4.19",
4545
"dotenv": "^16.4.5",
4646
"drizzle-kit": "^0.20.14",
47-
"eslint": "^8.56.0",
47+
"eslint": "^8.57.0",
4848
"eslint-config-prettier": "^9.1.0",
49-
"eslint-plugin-svelte": "^2.36.0-next.4",
49+
"eslint-plugin-svelte": "2.36.0-next.13",
5050
"postcss": "^8.4.38",
51-
"postcss-load-config": "^5.0.2",
52-
"prettier": "^3.1.1",
53-
"prettier-plugin-svelte": "^3.1.2",
51+
"postcss-load-config": "^5.0.3",
52+
"prettier": "^3.2.5",
53+
"prettier-plugin-svelte": "^3.2.2",
5454
"prettier-plugin-tailwindcss": "^0.5.13",
5555
"svelte": "^4.2.12",
5656
"svelte-check": "^3.6.8",
5757
"sveltekit-flash-message": "^2.4.4",
5858
"sveltekit-rate-limiter": "^0.5.1",
5959
"sveltekit-view-transition": "^0.5.3",
6060
"tailwindcss": "^3.4.3",
61-
"tslib": "^2.4.1",
61+
"tslib": "^2.6.2",
6262
"tsx": "^4.7.1",
6363
"typescript": "^5.4.3",
6464
"vite": "^5.2.7",

0 commit comments

Comments
 (0)