From 578bd26cc0c774edfcf098f669c7948cc8a7ff7d Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Thu, 4 Apr 2024 11:43:37 -0400
Subject: [PATCH 01/10] orbit: db: schema: use consistent type and constraints
 for student id

In the users table the student id was being stored as an integer, but
in the registration table it was being stored as a string. Use a string
since the exact format of what a program might use as a student id is not
consistent. E.g. while UML ids are integers, we may want to use emails
for LFX students, and other institutions may have alphanumeric ids etc.

Since the registration table also puts a unique constraint on the column
(since the id is the lookup key for registration), that constraint should
also be applied to the column in the user table.

empty orbit db binary blob in tests needed updating again to reflect new
schema. The timestamp changed in the tar metadata, but as for the actual
contents, only and the schema was changed.
---
 orbit/init-db.sql |  2 +-
 test.sh           | 76 ++++++++++++++++++++++++-----------------------
 2 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index 8f798740..762a2bfd 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -4,7 +4,7 @@ CREATE TABLE users (
 	id integer primary key,
 	username string UNIQUE NOT NULL,
 	pwdhash string NOT NULL,
-	student_id integer);
+	student_id string UNIQUE);
 CREATE TABLE sessions (
         token string PRIMARY KEY,
         username string UNIQUE NOT NULL,
diff --git a/test.sh b/test.sh
index 1b6f2b27..721d3971 100755
--- a/test.sh
+++ b/test.sh
@@ -80,43 +80,45 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
-00000000: 1f8b 0800 0000 0000 0003 edda 4d4f db30  ............MO.0
-00000010: 18c0 f104 4adf a4b6 f430 e584 e6e3 9010  ....J....0......
-00000020: 4da0 c061 9ab4 0ef5 80d6 7583 b507 4e55  M..a......u...NU
-00000030: 503d 88a0 098b 5301 c7f2 51f6 7da6 1df6  P=....S...Q.}...
-00000040: 6576 5c12 7005 4cdd 3a6d 685a f4ff 49b1  ev\.p.L.:mhZ..I.
-00000050: 9de4 8965 3f71 0f56 1a84 475e b43e 3c32  ...e?q.V..G^.><2
-00000060: 1e91 1ddb 6e36 d3da 7950 db8e 9394 86d3  ....n6..yP......
-00000070: dcb6 3737 eded 1ddb 316c c7de b19b 86b0  ..77....1l......
-00000080: 1f73 50da 5845 6e18 0fe5 4ffb b16f 4ceb  .sP.XEn...O..oL.
-00000090: ffc4 fbfd 8e17 49f1 2108 476e 2436 8d65  ......I.!.Gn$6.e
-000000a0: c334 8d97 42c4 b7cc f828 dd09 5d8c 8fdc  .4..B....(..]...
-000000b0: 9d73 738e ee4d 633d fc54 a97d 338a 95ba  .ss..Mc=.T.}3...
-000000c0: 51db aa7d ae3a b55c f56b a55e 352a 5ffe  Q..}.:.\.k.^5*_.
-000000d0: e234 0000 0000 e0f7 4d9e e70b d6ca 8a79  .4......M......y
-000000e0: bd17 b947 67d2 9717 6325 43a5 ebc2 ee41  ...Gg...c%C....A
-000000f0: bbd5 6b8b 5eeb 55a7 2df4 55f1 ac5c 0ae5  ..k.^.U.-.U..\..
-00000100: b1a7 a2d0 8dbc c01f 7843 e1f9 913c 96a1  ........xC...<..
-00000110: 380f bd91 1b5e 8953 79b5 562e a968 3c94  8....^.Sy.V..h<.
-00000120: 7e94 04c4 c19e 7f2c fadd bdfd 7e5b 74df  ~......,....~[t.
-00000130: f644 b7df e9c4 3149 97be 3b92 b323 ce5d  .D....1I..;..#.]
-00000140: a52e 8270 da87 beb5 da28 e6ad dd15 d3f0  ...p.....(......
-00000150: fca1 bc54 1fcf e2bd ddc0 1d47 417a 3ed0  ...T.......GAz>.
-00000160: c31d 6ce8 56a9 5198 eb01 47b7 8a93 a78b  ..l.V.Q...G.....
-00000170: 37f9 a9a7 f951 52a9 78c2 4ad7 b97b f9d1  7....QR.x.J..{..
-00000180: 57e3 fc88 5b51 702a 7d3d ee77 077b 6f5a  W...[Qp*}=.w.{oZ
-00000190: 0787 e275 fb70 6d1a f1cb e9eb 4079 79ee  ...u.pm.....@yy.
-000001a0: c589 fd21 074b 3f9b 921e d260 43b7 f28d  ...!.K?....`C...
-000001b0: dc5c 0f38 bab5 3479 6216 2ccb 32af 4b69  .\.8..4yb.,.2.Ki
-000001c0: 0ed2 c4a4 c5c2 bdd9 4f97 c6cc d530 c79b  ........O....0..
-000001d0: be18 9eb8 eae4 e124 efaf a4db ce57 5717  .......$.....WW.
-000001e0: f2d6 0b6b d644 6edf 645a 257b f962 b2dc  ...k.Dn.dZ%{.b..
-000001f0: 2b49 b1fc 4f7f 7100 0000 0000 e091 9593  +I..O.q.........
-00000200: 82fd 3f00 0000 0000 99c6 f77f 0000 0000  ..?.............
-00000210: 00b2 8fef ff00 0000 0000 641f fb7f 0000  ..........d.....
-00000220: 0000 00b2 8fff ff03 0000 0000 907d 7cff  .............}|.
-00000230: 0700 0000 0020 fbd8 ff03 0000 0000 0000  ..... ..........
-00000240: d9f5 1df3 6b21 9400 9600 00              ....k!.....
+00000000: 1f8b 0800 0000 0000 0003 edda b14e db40  .............N.@
+00000010: 18c0 f133 8484 4424 a143 e5a1 42bd b191  ...3..D$.C..B...
+00000020: 10b1 4360 a92a 95a2 0ca8 292d 340c 4c91  ..C`.*....)-4.L.
+00000030: a35c 8305 71c0 e708 18e1 413a f03e 5587  .\..q.....A:.>U.
+00000040: be00 8fd1 b18e cb45 4005 6428 6aeb fe7f  .......E@.d(j...
+00000050: 927d 67fb b373 f7e5 3c9c ce83 b0e3 474b  .}g..s..<.....GK
+00000060: dd8e 7844 4e6c b55e 4f4a f756 e9b8 b5d1  ..xDNl.^OJ.V....
+00000070: 5eb8 f555 b756 5b71 dde5 55e1 b88e b3e2  ^..U.V[q..U.....
+00000080: 08e9 3c66 a38c a18e bc50 4a11 ffe6 bd71  ..<f.....PJ....q
+00000090: 0f5d ff47 7ddc 6afa 9192 9f06 61df 8be4  .].G}.j.....a...
+000000a0: b298 1796 255e c7f9 10c2 8ab7 c2b5 d0e9  ....%^..........
+000000b0: 78cb 5c3b b626 78bc 2596 c28b 62f9 bbc8  x.\;.&x.%...b...
+000000c0: cf5d 8a72 a6fc a57c 5112 a56f a58b b9cb  .].r...|Q..o....
+000000d0: e2d7 e2e7 dfd8 1100 0000 00ff bdb3 97b9  ................
+000000e0: 9cbd b060 9d6f 445e e740 05ea 78a8 55a8  ...`.oD^.@..x.U.
+000000f0: 4d39 bbbe dd58 6b35 646b ed4d b321 cd59  M9...Xk5dk.M.!.Y
+00000100: f9a2 900f 55cf d751 e845 fe20 68fb 5de9  ....U..Q.E. h.].
+00000110: 0791 eaa9 501e 867e df0b 4fe5 be3a 5d2c  ....P..~..O..:],
+00000120: e475 34ec aa20 1a05 c4c1 7ed0 933b 9b1b  .u4.. ....~..;..
+00000130: 5b3b 0db9 f9be 2537 779a cd38 66f4 c8c0  [;....%7w..8f...
+00000140: ebab bb23 0e3d ad8f 07e1 f819 e652 a59a  ...#.=.......R..
+00000150: cfda eb0b 96f0 83ae 3ad1 4707 f154 aded  ........:.G..T..
+00000160: 0da3 4172 dc36 cd6d d74c ad50 9d9d e806  ..Ar.6.m.L.P....
+00000170: d7d4 f267 cf33 3ff3 f324 c98f 565a c71d  ...g.3?..$..VZ..
+00000180: d6a6 9cb9 911f 7336 ce8f bc12 0df6 5560  ......s6......U`
+00000190: dafd 617b e3dd daf6 ae7c dbd8 5d1c 473c  ..a{.....|..].G<
+000001a0: d87d 13a8 4e0e fd38 b1bf e420 7b5f 974c  .}..N..8... {_.L
+000001b0: 93da 3553 cb55 6726 bac1 35b5 ecd9 332b  ..5S.Ug&..5...3+
+000001c0: 67db b675 fe34 c941 9298 6437 75a3 f7e3  g..u.4.A..d7u...
+000001d0: a171 e768 98e0 9f3e eeee 797a ef76 27ef  .q.h...>..yz.v'.
+000001e0: 1949 95ca 74d6 7e65 dfd5 9dab 0190 1499  .I..t.~e........
+000001f0: cad4 c3a1 6e52 8ce6 f2b3 a3f7 a338 dacd  ....nR.......8..
+00000200: ffd1 5714 0000 0000 003c b264 819f f93f  ..W......<.d...?
+00000210: 0000 0000 00a9 c6fc 1f00 0000 0080 f4e3  ................
+00000220: fb7f 0000 0000 00d2 8ff5 7f00 0000 0000  ................
+00000230: d28f f93f 0000 0000 00e9 c7f7 ff00 0000  ...?............
+00000240: 0000 a41f ebff 0000 0000 00a4 1ff3 7f00  ................
+00000250: 0000 0000 0000 0000 0000 0000 0000 0000  ................
+00000260: 0000 f83b fd00 e7f3 180e 00c8 0000       ...;..........
 EOF
 
 # Restore the old orbit db after testing completes

From 8b8c31ccae69172c3d6eb290f67e59cad882e927 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Thu, 4 Apr 2024 13:32:17 -0400
Subject: [PATCH 02/10] orbit: db: sessions: expiry: use real type for column

since the expiry time is a floating point value, it should be
stored as one to avoid converions back and forth to string.

Again empty orbit db binary blob needed updating.
---
 orbit/init-db.sql |  2 +-
 test.sh           | 78 +++++++++++++++++++++++------------------------
 2 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index 762a2bfd..65d30593 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -8,7 +8,7 @@ CREATE TABLE users (
 CREATE TABLE sessions (
         token string PRIMARY KEY,
         username string UNIQUE NOT NULL,
-        expiry string NOT NULL);
+        expiry real NOT NULL);
 CREATE TABLE newusers (
 	registration_id integer primary key,
 	student_id string UNIQUE NOT NULL,
diff --git a/test.sh b/test.sh
index 721d3971..93a91e43 100755
--- a/test.sh
+++ b/test.sh
@@ -80,45 +80,45 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
-00000000: 1f8b 0800 0000 0000 0003 edda b14e db40  .............N.@
-00000010: 18c0 f133 8484 4424 a143 e5a1 42bd b191  ...3..D$.C..B...
-00000020: 10b1 4360 a92a 95a2 0ca8 292d 340c 4c91  ..C`.*....)-4.L.
-00000030: a35c 8305 71c0 e708 18e1 413a f03e 5587  .\..q.....A:.>U.
-00000040: be00 8fd1 b18e cb45 4005 6428 6aeb fe7f  .......E@.d(j...
-00000050: 927d 67fb b373 f7e5 3c9c ce83 b0e3 474b  .}g..s..<.....GK
-00000060: dd8e 7844 4e6c b55e 4f4a f756 e9b8 b5d1  ..xDNl.^OJ.V....
-00000070: 5eb8 f555 b756 5b71 dde5 55e1 b88e b3e2  ^..U.V[q..U.....
-00000080: 08e9 3c66 a38c a18e bc50 4a11 ffe6 bd71  ..<f.....PJ....q
-00000090: 0f5d ff47 7ddc 6afa 9192 9f06 61df 8be4  .].G}.j.....a...
-000000a0: b298 1796 255e c7f9 10c2 8ab7 c2b5 d0e9  ....%^..........
-000000b0: 78cb 5c3b b626 78bc 2596 c28b 62f9 bbc8  x.\;.&x.%...b...
-000000c0: cf5d 8a72 a6fc a57c 5112 a56f a58b b9cb  .].r...|Q..o....
-000000d0: e2d7 e2e7 dfd8 1100 0000 00ff bdb3 97b9  ................
-000000e0: 9cbd b060 9d6f 445e e740 05ea 78a8 55a8  ...`.oD^.@..x.U.
-000000f0: 4d39 bbbe dd58 6b35 646b ed4d b321 cd59  M9...Xk5dk.M.!.Y
-00000100: f9a2 900f 55cf d751 e845 fe20 68fb 5de9  ....U..Q.E. h.].
-00000110: 0791 eaa9 501e 867e df0b 4fe5 be3a 5d2c  ....P..~..O..:],
-00000120: e475 34ec aa20 1a05 c4c1 7ed0 933b 9b1b  .u4.. ....~..;..
-00000130: 5b3b 0db9 f9be 2537 779a cd38 66f4 c8c0  [;....%7w..8f...
-00000140: ebab bb23 0e3d ad8f 07e1 f819 e652 a59a  ...#.=.......R..
-00000150: cfda eb0b 96f0 83ae 3ad1 4707 f154 aded  ........:.G..T..
-00000160: 0da3 4172 dc36 cd6d d74c ad50 9d9d e806  ..Ar.6.m.L.P....
-00000170: d7d4 f267 cf33 3ff3 f324 c98f 565a c71d  ...g.3?..$..VZ..
-00000180: d6a6 9cb9 911f 7336 ce8f bc12 0df6 5560  ......s6......U`
-00000190: dafd 617b e3dd daf6 ae7c dbd8 5d1c 473c  ..a{.....|..].G<
-000001a0: d87d 13a8 4e0e fd38 b1bf e420 7b5f 974c  .}..N..8... {_.L
-000001b0: 93da 3553 cb55 6726 bac1 35b5 ecd9 332b  ..5S.Ug&..5...3+
-000001c0: 67db b675 fe34 c941 9298 6437 75a3 f7e3  g..u.4.A..d7u...
-000001d0: a171 e768 98e0 9f3e eeee 797a ef76 27ef  .q.h...>..yz.v'.
-000001e0: 1949 95ca 74d6 7e65 dfd5 9dab 0190 1499  .I..t.~e........
-000001f0: cad4 c3a1 6e52 8ce6 f2b3 a3f7 a338 dacd  ....nR.......8..
-00000200: ffd1 5714 0000 0000 003c b264 819f f93f  ..W......<.d...?
-00000210: 0000 0000 00a9 c6fc 1f00 0000 0080 f4e3  ................
-00000220: fb7f 0000 0000 00d2 8ff5 7f00 0000 0000  ................
-00000230: d28f f93f 0000 0000 00e9 c7f7 ff00 0000  ...?............
-00000240: 0000 a41f ebff 0000 0000 00a4 1ff3 7f00  ................
-00000250: 0000 0000 0000 0000 0000 0000 0000 0000  ................
-00000260: 0000 f83b fd00 e7f3 180e 00c8 0000       ...;..........
+00000000: 1f8b 0800 0000 0000 0003 edda bf4e db40  .............N.@
+00000010: 1cc0 f133 84fc 1349 582a 0f55 a41b 1b09  ...3...IX*.U....
+00000020: 9138 043a 5495 9aa2 0ca8 292d 940c 4c91  .8.:T.....)-..L.
+00000030: a35c c102 1cea 7314 18c3 9354 799f 0e55  .\....s....Ty..U
+00000040: df80 a7e8 58c7 e510 2041 3214 b5b5 be1f  ....X... A2.....
+00000050: c9be b3fd b37d f73b 7b38 d983 a0e7 856b  .....}.;{8.....k
+00000060: fd9e 7842 b5c8 66a3 1197 cebd b2e6 d4a7  ..xB..f.........
+00000070: 6be1 3436 9d7a 7dc3 5977 3644 cda9 d51a  k.46.z}.Yw6D....
+00000080: 2f85 ac3d 65a3 8ca1 0edd 404a 11dd f3d1  /..=e.....@J....
+00000090: b859 c7ff 539f 76db 5ea8 e4e7 4170 ea86  .Y..S.v.^...Ap..
+000000a0: 725d ac08 cb12 6fa2 7c08 6145 4bfe 56e8  r]....o.|.aEK.V.
+000000b0: 62b4 a46e 6d5b 735c de12 6bc1 a450 fa29  b..nm[s\..k..P.)
+000000c0: 72cb 57a2 942a 7d2b 4d8a 0bc5 1fc5 c9f2  r.W..*}+M.......
+000000d0: 55e1 7be1 eb9f eb07 0000 0000 0831 7e95  U.{..........1~.
+000000e0: c9d8 e5b2 75b9 1dba bd13 e5ab d150 ab40  ....u........P.@
+000000f0: 9b32 bbb5 d76a eeb7 e47e f36d bb25 cd5e  .2...j...~.m.%.^
+00000100: f922 9f0b d4a1 a7c3 c00d bd81 dff5 fad2  ."..............
+00000110: f343 75a8 0279 1678 a76e 7021 8fd5 c56a  .Cu..y.x.np!...j
+00000120: 3ea7 c361 5ff9 e134 200a f6fc 43d9 d9d9  >..a_..4 ...C...
+00000130: deed b4e4 ce87 7db9 d369 b7a3 98e9 257d  ......}..i....%}
+00000140: f754 3d1c 71e6 6a3d 1a04 37d7 3087 2ad5  .T=.q.j=..7.0.*.
+00000150: 5cda de2a 5bc2 f3fb ea5c 7f39 8926 6b5d  \..*[....\.9.&k]
+00000160: 7718 0ee2 edae 696e b76e 6af9 6a76 ae13  w.....in.nj.jv..
+00000170: 1c53 cb8d cba9 dff9 29c4 f9d1 4aeb a8c3  .S......)...J...
+00000180: da94 4b77 f263 f646 f991 d7c2 c1b1 f24d  ..Kw.c.F.......M
+00000190: bb3f ee6d bf6f ee1d c877 ad83 d59b 8899  .?.m.o...w......
+000001a0: dd37 81ea fccc 8b12 1b28 f7e4 5606 d28f  .7.......(..V...
+000001b0: 75c8 34a8 5b37 b54c 7569 ae13 1c53 4b8f  u.4.[7.Lui...SK.
+000001c0: 9f5b 19db b6ad cb67 7106 e2b4 c4ab 853b  .[.....gq......;
+000001d0: 7dbf 7930 1e7c 16e6 18e7 51ff c8d5 47f7  }.y0.|....Q...G.
+000001e0: 87f9 91e7 a852 594c dbaf ed87 ba73 3dfc  .....RYL.....s=.
+000001f0: 7191 aa2c cc0e 75e2 623a 97cf 4edf 8ec2  q..,..u.b:..N...
+00000200: 74b5 f257 5f50 0000 0000 00f0 c4e2 0ffc  t..W_P..........
+00000210: ccff 0100 0000 0048 34e6 ff00 0000 0000  .......H4.......
+00000220: 241f ffff 0300 0000 0090 7c7c ff07 0000  $.........||....
+00000230: 0000 20f9 98ff 0300 0000 0090 7cfc ff0f  .. .........|...
+00000240: 0000 0000 40f2 f1fd 1f00 0000 0080 e463  ....@..........c
+00000250: fe0f 0000 0000 0000 0000 0000 0000 0000  ................
+00000260: 0000 0000 00ff a65f a15a b1c9 00c8 0000  ......._.Z......
 EOF
 
 # Restore the old orbit db after testing completes

From 3b502d46031558b2ce20d1e6b942f99064df93b3 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Thu, 4 Apr 2024 13:37:17 -0400
Subject: [PATCH 03/10] orbit: db: schema: use proper type for text in sqlite

string is not a type in sqlite - text is. If you put string, it
treats the column like an integer but also can accommodate strings
because sqlite is not strict with the column values.

binary blob in test needed updating again
---
 orbit/init-db.sql | 16 +++++-----
 test.sh           | 78 +++++++++++++++++++++++------------------------
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index 65d30593..e5af4f08 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -2,16 +2,16 @@ PRAGMA foreign_keys=OFF;
 BEGIN TRANSACTION;
 CREATE TABLE users (
 	id integer primary key,
-	username string UNIQUE NOT NULL,
-	pwdhash string NOT NULL,
-	student_id string UNIQUE);
+	username text UNIQUE NOT NULL,
+	pwdhash text NOT NULL,
+	student_id text UNIQUE);
 CREATE TABLE sessions (
-        token string PRIMARY KEY,
-        username string UNIQUE NOT NULL,
+        token text PRIMARY KEY,
+        username text UNIQUE NOT NULL,
         expiry real NOT NULL);
 CREATE TABLE newusers (
 	registration_id integer primary key,
-	student_id string UNIQUE NOT NULL,
-	username string UNIQUE NOT NULL,
-	password string NOT NULL);
+	student_id text UNIQUE NOT NULL,
+	username text UNIQUE NOT NULL,
+	password text NOT NULL);
 COMMIT;
diff --git a/test.sh b/test.sh
index 93a91e43..a3017afc 100755
--- a/test.sh
+++ b/test.sh
@@ -80,45 +80,45 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
-00000000: 1f8b 0800 0000 0000 0003 edda bf4e db40  .............N.@
-00000010: 1cc0 f133 84fc 1349 582a 0f55 a41b 1b09  ...3...IX*.U....
-00000020: 9138 043a 5495 9aa2 0ca8 292d 940c 4c91  .8.:T.....)-..L.
-00000030: a35c c102 1cea 7314 18c3 9354 799f 0e55  .\....s....Ty..U
-00000040: df80 a7e8 58c7 e510 2041 3214 b5b5 be1f  ....X... A2.....
-00000050: c9be b3fd b37d f73b 7b38 d983 a0e7 856b  .....}.;{8.....k
-00000060: fd9e 7842 b5c8 66a3 1197 cebd b2e6 d4a7  ..xB..f.........
-00000070: 6be1 3436 9d7a 7dc3 5977 3644 cda9 d51a  k.46.z}.Yw6D....
-00000080: 2f85 ac3d 65a3 8ca1 0edd 404a 11dd f3d1  /..=e.....@J....
-00000090: b859 c7ff 539f 76db 5ea8 e4e7 4170 ea86  .Y..S.v.^...Ap..
-000000a0: 725d ac08 cb12 6fa2 7c08 6145 4bfe 56e8  r]....o.|.aEK.V.
-000000b0: 62b4 a46e 6d5b 735c de12 6bc1 a450 fa29  b..nm[s\..k..P.)
-000000c0: 72cb 57a2 942a 7d2b 4d8a 0bc5 1fc5 c9f2  r.W..*}+M.......
-000000d0: 55e1 7be1 eb9f eb07 0000 0000 0831 7e95  U.{..........1~.
-000000e0: c9d8 e5b2 75b9 1dba bd13 e5ab d150 ab40  ....u........P.@
-000000f0: 9b32 bbb5 d76a eeb7 e47e f36d bb25 cd5e  .2...j...~.m.%.^
-00000100: f922 9f0b d4a1 a7c3 c00d bd81 dff5 fad2  ."..............
-00000110: f343 75a8 0279 1678 a76e 7021 8fd5 c56a  .Cu..y.x.np!...j
-00000120: 3ea7 c361 5ff9 e134 200a f6fc 43d9 d9d9  >..a_..4 ...C...
-00000130: deed b4e4 ce87 7db9 d369 b7a3 98e9 257d  ......}..i....%}
-00000140: f754 3d1c 71e6 6a3d 1a04 37d7 3087 2ad5  .T=.q.j=..7.0.*.
-00000150: 5cda de2a 5bc2 f3fb ea5c 7f39 8926 6b5d  \..*[....\.9.&k]
-00000160: 7718 0ee2 edae 696e b76e 6af9 6a76 ae13  w.....in.nj.jv..
-00000170: 1c53 cb8d cba9 dff9 29c4 f9d1 4aeb a8c3  .S......)...J...
-00000180: da94 4b77 f263 f646 f991 d7c2 c1b1 f24d  ..Kw.c.F.......M
-00000190: bb3f ee6d bf6f ee1d c877 ad83 d59b 8899  .?.m.o...w......
-000001a0: dd37 81ea fccc 8b12 1b28 f7e4 5606 d28f  .7.......(..V...
-000001b0: 75c8 34a8 5b37 b54c 7569 ae13 1c53 4b8f  u.4.[7.Lui...SK.
-000001c0: 9f5b 19db b6ad cb67 7106 e2b4 c4ab 853b  .[.....gq......;
-000001d0: 7dbf 7930 1e7c 16e6 18e7 51ff c8d5 47f7  }.y0.|....Q...G.
-000001e0: 87f9 91e7 a852 594c dbaf ed87 ba73 3dfc  .....RYL.....s=.
-000001f0: 7191 aa2c cc0e 75e2 623a 97cf 4edf 8ec2  q..,..u.b:..N...
-00000200: 74b5 f257 5f50 0000 0000 00f0 c4e2 0ffc  t..W_P..........
-00000210: ccff 0100 0000 0048 34e6 ff00 0000 0000  .......H4.......
-00000220: 241f ffff 0300 0000 0090 7c7c ff07 0000  $.........||....
-00000230: 0000 20f9 98ff 0300 0000 0090 7cfc ff0f  .. .........|...
-00000240: 0000 0000 40f2 f1fd 1f00 0000 0080 e463  ....@..........c
-00000250: fe0f 0000 0000 0000 0000 0000 0000 0000  ................
-00000260: 0000 0000 00ff a65f a15a b1c9 00c8 0000  ......._.Z......
+00000000: 1f8b 0800 0000 0000 0003 edda b14e db40  .............N.@
+00000010: 18c0 f133 8484 4484 b054 5607 a41b 1b09  ...3..D..TV.....
+00000020: 419c 266c 484d 5106 d494 9614 06a6 c828  A.&lHMQ........(
+00000030: 57b0 0087 fa2e 0a8c f028 4c55 dfa5 0f50  W........(LU...P
+00000040: f52d 983a d631 3944 5a85 3014 b5b5 fe3f  .-.:.19DZ.0....?
+00000050: c9be b3ef 6cdf f7d9 1e4e 762f 3a08 cc6a  ....l....Nv/:..j
+00000060: f740 3ca1 4a6c bd56 4b4a ef97 b2e2 5587  .@<.Jl.VKJ....U.
+00000070: 6be1 d5d6 bd6a b5ee d5ea 7551 f12a 957a  k....j....uQ.*.z
+00000080: 4dc8 ca53 0eca ea6b e347 528a f89a 0ff6  M..S...k.GR.....
+00000090: 9bd6 fe9f fab0 d30a 8c92 1f7b d1a9 6fe4  ...........{..o.
+000000a0: 4bb1 241c 47bc 8af3 2184 132f 857b 5d67  K.$.G...!../.{]g
+000000b0: e325 736f db79 c4e9 1db1 1a5d 174b 3f44  .%so.y.....].K?D
+000000c0: 7ee1 4694 0aa5 afa5 ebc5 85c5 6f8b 9f17  ~.F.........o...
+000000d0: 6e8a df8b 5ffe 6020 0000 0000 f09b cb7a  n..._.` .......z
+000000e0: 2ee7 2e2f 3b57 1bc6 3f38 51a1 1af4 b58a  .../;W..?8Q.....
+000000f0: b42d e737 dbcd c66e 53ee 365e b79a d2ee  .-.7...nS.6^....
+00000100: 952f 0af9 481d 06da 44be 097a 6127 e8ca  ./..H...D..za'..
+00000110: 2034 ea50 45f2 2c0a 4efd e842 1eab 8b95   4.PE.,.N..B....
+00000120: 425e 9b7e 5785 66d8 c1a8 7323 f7b6 b776  B^.~W.f...s#...v
+00000130: f69a 72fb ddae dcde 6bb5 e21e c313 86fe  ..r.....k.......
+00000140: a99a d47e e66b 3de8 45a3 e36d 4379 2d9f  ...~.k=.E..mCy-.
+00000150: 7537 971d 1184 5d75 ae3f 9dc4 d3b6 8edf  u7....]u.?......
+00000160: 37bd 64bb 6307 daa9 da5a 616d fe51 0778  7.d.c....Zam.Q.x
+00000170: b696 bf7c 9eb9 cdcc 5c92 19ad b48e 43d5  ...|....\.....C.
+00000180: b69c 1bcb 8cdd 1b67 468e 98de b10a 6f47  .......gF.....oG
+00000190: fdbe bdf5 b6d1 de97 6f9a fb2b 77ed 5302  ........o..+w.S.
+000001a0: b7dd d4f9 5910 a733 52fe c9bd e8b3 0f05  ....Y..3R.......
+000001b0: 6307 d3a9 da5a 6e6d ee51 0778 b696 bd7c  c....Znm.Q.x...|
+000001c0: e6e4 5cd7 75ae f249 f449 4a92 d5cc 58dc  ..\.u..I.IJ...X.
+000001d0: 778f c3c4 2760 eafd 1d74 8f7c 7d34 7e7b  w...'`...t.|}4~{
+000001e0: 273e 39e5 f26c d6dd 7027 0532 bae9 4991  '>9..l..p'.2..I.
+000001f0: 29cf 4cef ea25 c570 2e3f 3f7c 1b8a c3d5  ).L..%.p.??|....
+00000200: d25f 7d21 0100 0000 00c0 134b 3ef0 33ff  ._}!.......K>.3.
+00000210: 0700 0000 0020 d598 ff03 0000 0000 907e  ..... .........~
+00000220: fcff 0f00 0000 0040 faf1 fd1f 0000 0000  .......@........
+00000230: 80f4 63fe 0f00 0000 0040 faf1 ff3f 0000  ..c......@...?..
+00000240: 0000 00e9 c7f7 7f00 0000 0000 d28f f93f  ...............?
+00000250: 0000 0000 0000 0000 0000 0000 0000 0000  ................
+00000260: 0000 00fc 9b7e 02a1 8c2e aa00 c800 00    .....~.........
 EOF
 
 # Restore the old orbit db after testing completes

From bbbf38640ecc392c8d56a33cd01dfd187f458779 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Thu, 4 Apr 2024 13:44:03 -0400
Subject: [PATCH 04/10] orbit: db: use strict tables in sqlite

sqlite databases do not enforce strict types for columns by default
instead it is possible to insert any sort of value into any column.
Using the keyword "strict" after each table forces sqlite to error
if it cannot losslessly convert a provided value into the type that
a column specifies.
---
 orbit/init-db.sql |  6 ++--
 test.sh           | 77 ++++++++++++++++++++++++-----------------------
 2 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index e5af4f08..e1792b2e 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -4,14 +4,14 @@ CREATE TABLE users (
 	id integer primary key,
 	username text UNIQUE NOT NULL,
 	pwdhash text NOT NULL,
-	student_id text UNIQUE);
+	student_id text UNIQUE) STRICT;
 CREATE TABLE sessions (
         token text PRIMARY KEY,
         username text UNIQUE NOT NULL,
-        expiry real NOT NULL);
+        expiry real NOT NULL) STRICT;
 CREATE TABLE newusers (
 	registration_id integer primary key,
 	student_id text UNIQUE NOT NULL,
 	username text UNIQUE NOT NULL,
-	password text NOT NULL);
+	password text NOT NULL) STRICT;
 COMMIT;
diff --git a/test.sh b/test.sh
index a3017afc..da92863b 100755
--- a/test.sh
+++ b/test.sh
@@ -81,44 +81,45 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
 00000000: 1f8b 0800 0000 0000 0003 edda b14e db40  .............N.@
-00000010: 18c0 f133 8484 4484 b054 5607 a41b 1b09  ...3..D..TV.....
-00000020: 419c 266c 484d 5106 d494 9614 06a6 c828  A.&lHMQ........(
-00000030: 57b0 0087 fa2e 0a8c f028 4c55 dfa5 0f50  W........(LU...P
-00000040: f52d 983a d631 3944 5a85 3014 b5b5 fe3f  .-.:.19DZ.0....?
-00000050: c9be b3ef 6cdf f7d9 1e4e 762f 3a08 cc6a  ....l....Nv/:..j
-00000060: f740 3ca1 4a6c bd56 4b4a ef97 b2e2 5587  .@<.Jl.VKJ....U.
-00000070: 6be1 d5d6 bd6a b5ee d5ea 7551 f12a 957a  k....j....uQ.*.z
-00000080: 4dc8 ca53 0eca ea6b e347 528a f89a 0ff6  M..S...k.GR.....
-00000090: 9bd6 fe9f fab0 d30a 8c92 1f7b d1a9 6fe4  ...........{..o.
-000000a0: 4bb1 241c 47bc 8af3 2184 132f 857b 5d67  K.$.G...!../.{]g
-000000b0: e325 736f db79 c4e9 1db1 1a5d 174b 3f44  .%so.y.....].K?D
-000000c0: 7ee1 4694 0aa5 afa5 ebc5 85c5 6f8b 9f17  ~.F.........o...
-000000d0: 6e8a df8b 5ffe 6020 0000 0000 f09b cb7a  n..._.` .......z
-000000e0: 2ee7 2e2f 3b57 1bc6 3f38 51a1 1af4 b58a  .../;W..?8Q.....
-000000f0: b42d e737 dbcd c66e 53ee 365e b79a d2ee  .-.7...nS.6^....
-00000100: 952f 0af9 481d 06da 44be 097a 6127 e8ca  ./..H...D..za'..
-00000110: 2034 ea50 45f2 2c0a 4efd e842 1eab 8b95   4.PE.,.N..B....
-00000120: 425e 9b7e 5785 66d8 c1a8 7323 f7b6 b776  B^.~W.f...s#...v
-00000130: f69a 72fb ddae dcde 6bb5 e21e c313 86fe  ..r.....k.......
-00000140: a99a d47e e66b 3de8 45a3 e36d 4379 2d9f  ...~.k=.E..mCy-.
-00000150: 7537 971d 1184 5d75 ae3f 9dc4 d3b6 8edf  u7....]u.?......
-00000160: 37bd 64bb 6307 daa9 da5a 616d fe51 0778  7.d.c....Zam.Q.x
-00000170: b696 bf7c 9eb9 cdcc 5c92 19ad b48e 43d5  ...|....\.....C.
-00000180: b69c 1bcb 8cdd 1b67 468e 98de b10a 6f47  .......gF.....oG
-00000190: fdbe bdf5 b6d1 de97 6f9a fb2b 77ed 5302  ........o..+w.S.
-000001a0: b7dd d4f9 5910 a733 52fe c9bd e8b3 0f05  ....Y..3R.......
-000001b0: 6307 d3a9 da5a 6e6d ee51 0778 b696 bd7c  c....Znm.Q.x...|
-000001c0: e6e4 5cd7 75ae f249 f449 4a92 d5cc 58dc  ..\.u..I.IJ...X.
-000001d0: 778f c3c4 2760 eafd 1d74 8f7c 7d34 7e7b  w...'`...t.|}4~{
-000001e0: 273e 39e5 f26c d6dd 7027 0532 bae9 4991  '>9..l..p'.2..I.
-000001f0: 29cf 4cef ea25 c570 2e3f 3f7c 1b8a c3d5  ).L..%.p.??|....
-00000200: d25f 7d21 0100 0000 00c0 134b 3ef0 33ff  ._}!.......K>.3.
-00000210: 0700 0000 0020 d598 ff03 0000 0000 907e  ..... .........~
-00000220: fcff 0f00 0000 0040 faf1 fd1f 0000 0000  .......@........
-00000230: 80f4 63fe 0f00 0000 0040 faf1 ff3f 0000  ..c......@...?..
-00000240: 0000 00e9 c7f7 7f00 0000 0000 d28f f93f  ...............?
-00000250: 0000 0000 0000 0000 0000 0000 0000 0000  ................
-00000260: 0000 00fc 9b7e 02a1 8c2e aa00 c800 00    .....~.........
+00000010: 18c0 f133 0909 8908 41ea e0a5 4837 1609  ...3....A...H7..
+00000020: 419c 12a6 562a 4519 1029 2d21 0c4c 9151  A...V*E..)-!.L.Q
+00000030: ae60 9138 d477 1130 c273 7429 efc3 d29d  .`.8.w.0.st)....
+00000040: f7e8 54d5 311c 8256 210c 456d ddff 4fb2  ..T.1..V!.Em..O.
+00000050: bf73 eeec dc7d 3e0f 27bb 1fed 0566 b1b3  .s...}>.'....f..
+00000060: 279e 5025 b6b2 bc9c 44ef a758 f1aa c3bd  '.P%....D..X....
+00000070: f096 57bc 6ab5 e6d5 6a2b a2e2 552a 7190  ..W.j...j+..U*q.
+00000080: 95a7 ec94 35d0 c68f a414 f17f 3ed8 6e5c  ....5.......>.n\
+00000090: fd3f 6a7b ab11 1825 3ff6 a39e 6fe4 4b31  .?j{...%?...o.K1
+000000a0: 2b1c 47bc 89f3 2184 136f c53b 4d33 f196  +.G...!..o.;M3..
+000000b0: bd73 ec3c e2f2 8e58 8c2e 4ae5 6fa2 307d  .s.<...X..J.o.0}
+000000c0: 25ca 99f2 65f9 a2f4 7de6 ebcc 97e9 abd2  %...e...}.......
+000000d0: 65e9 f36f 1c08 0000 0080 ffdb d9ab 7cde  e..o..........|.
+000000e0: 9d9b 73ce 378c bfd7 55a1 3a1e 6815 691b  ..s.7...U.:.h.i.
+000000f0: a7d6 9af5 d556 5db6 56df 36ea d2fe 2a5f  .....V].V.6...*_
+00000100: 140b 91da 0fb4 897c 13f4 c376 d091 4168  .......|...v..Ah
+00000110: d4be 8ae4 5114 f4fc e854 1eaa d385 6241  ....Q....T....bA
+00000120: 9b41 4785 66d8 c0a8 1323 7736 d7b7 76ea  .AG.f....#w6..v.
+00000130: 72f3 7d4b 6eee 341a 718b e105 43bf a746  r.}Kn.4.q...C..F
+00000140: d51f f95a 1ff7 a39b f36d c5bc dc6e 35d7  ...Z.....m...n5.
+00000150: d75a 4b85 9cbb 36e7 8820 eca8 13fd a91b  .ZK...6.. ......
+00000160: 2fd4 dafe c0f4 93e3 b6ed 6fbb 6a4b c5a5  /.........o.jK..
+00000170: a947 9de0 d952 e14c 66af 13f4 2c49 9056  .G...R.Lf...,I.V
+00000180: 5ac7 23d6 364e de4b 90fd 354e 90bc 61fa  Z.#.6N.K..5N..a.
+00000190: 872a bcee fc87 e6fa bbd5 e6ae dca8 ef2e  .*..............
+000001a0: dcd6 8f19 bf6d a64e 8e82 38ab 91f2 bbbf  .....m.N..8.....
+000001b0: 2621 f7d0 986c 9fda 555b ca2f 4d3e ea04  &!...l..U[./M>..
+000001c0: cf96 7267 cf9d bceb bace b99b 2421 c94c  ..rg........$!.L
+000001d0: b29b b837 fcdb c931 723e 8cbd dbc7 9d03  ...7...1r>......
+000001e0: 5f1f dcbf d923 e791 4dc0 7c26 e7be 7647  _....#..M.|&..vG
+000001f0: 8de7 660a 2421 3b3f 31be a997 84e1 5a7e  ..f.$!;?1.....Z~
+00000200: 6af8 8894 86bb d93f fa94 0200 0000 0080  j......?........
+00000210: 2796 bce0 67fd 0f00 0000 0040 aab1 fe07  '...g......@....
+00000220: 0000 0000 20fd f8fe 1f00 0000 0080 f4e3  .... ...........
+00000230: fd3f 0000 0000 00e9 c7fa 1f00 0000 0080  .?..............
+00000240: f4e3 fb7f 0000 0000 00d2 8ff7 ff00 0000  ................
+00000250: 0000 a41f eb7f 0000 0000 0000 0000 0000  ................
+00000260: 0000 0000 0000 0000 00f8 3bfd 00af 11e8  ..........;.....
+00000270: e900 c800 00                             .....
 EOF
 
 # Restore the old orbit db after testing completes

From b4418deb665765b187b67d6fec725fa4a9928b1b Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 21 Apr 2024 21:20:19 -0400
Subject: [PATCH 05/10] orbit: db: registration: introduce new combination
 query

This query returns the credentials for a given student ID
while simultaenously deleting the entry for them so that only
one db call is needed to register a user. If no user is found
that matches the credentials, nothing is deleted and this case
can still be detected by the empty return.
---
 orbit/db.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/orbit/db.py b/orbit/db.py
index c23f08ae..14b26e0b 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -151,3 +151,11 @@ def reg_getby_stuid(sid): return _get(REG_GETBY_STUID, sid)
 WHERE registration_id = ?;
 """.strip()
 def reg_delby_regid(rid): return _set(REG_DELBY_REGID, rid)
+
+
+REG_GETDEL_BY_STUID = """
+DELETE FROM newusers
+WHERE student_id = ?
+RETURNING username, password;
+"""
+def reg_get_and_del_by_stuid(sid): return _set(REG_GETDEL_BY_STUID, sid)

From 80ec0b90a2f12df54a9f5880157d1c2f3b85c1ca Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 21 Apr 2024 21:22:58 -0400
Subject: [PATCH 06/10] orbit: radius: registration: use new helper

This simplifies the code nicely, and makes it faster since
only one call to the db is needed.
---
 orbit/radius.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/orbit/radius.py b/orbit/radius.py
index 785c8428..f2d152f8 100644
--- a/orbit/radius.py
+++ b/orbit/radius.py
@@ -461,11 +461,10 @@ def form_respond():
     if not (student_id := rocket.body_args_query('student_id')):
         rocket.msg('you must provide a student id')
         return form_respond()
-    if not (registration_data := db.reg_getby_stuid(student_id)[0]):
+    if not (registration_data := db.reg_get_and_del_by_stuid(student_id)[0]):
         rocket.msg('no such student')
         return form_respond()
-    (regid, username, password) = registration_data
-    db.reg_delby_regid(regid)
+    (username, password) = registration_data
     rocket.msg('welcome to the classroom')
     return rocket.respond((register_response % {
         'username': username,

From 5f9e81a338991ef8f3c1073778ba1e012daecaaf Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 21 Apr 2024 21:23:53 -0400
Subject: [PATCH 07/10] orbit: db: remove unused registration queries

now that the combined query exists, it fully supplants
the two prior single purpose querries.
---
 orbit/db.py | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index 14b26e0b..24fa792f 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -138,21 +138,6 @@ def usr_getby_username(usn): return _get(USR_GETBY_USERNAME, usn)
 def reg_ins(tpl): return _set(REG_INS, tpl)
 
 
-REG_GETBY_STUID = """
-SELECT registration_id, username, password
-FROM newusers
-WHERE student_id = ?;
-""".strip()
-def reg_getby_stuid(sid): return _get(REG_GETBY_STUID, sid)
-
-
-REG_DELBY_REGID = """
-DELETE FROM newusers
-WHERE registration_id = ?;
-""".strip()
-def reg_delby_regid(rid): return _set(REG_DELBY_REGID, rid)
-
-
 REG_GETDEL_BY_STUID = """
 DELETE FROM newusers
 WHERE student_id = ?

From 1a270ec6f0e3d31cd599794347c0b646fbdba537 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Sun, 21 Apr 2024 21:31:36 -0400
Subject: [PATCH 08/10] orbit: db: schema: remove unused registration id

The primary key was always really the student id and now
that we have the combo query to fetch and delete entries
there is no longer any need to track this id explicitly.
---
 orbit/init-db.sql |  1 -
 test.sh           | 79 +++++++++++++++++++++++------------------------
 2 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index e1792b2e..ca9199d9 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -10,7 +10,6 @@ CREATE TABLE sessions (
         username text UNIQUE NOT NULL,
         expiry real NOT NULL) STRICT;
 CREATE TABLE newusers (
-	registration_id integer primary key,
 	student_id text UNIQUE NOT NULL,
 	username text UNIQUE NOT NULL,
 	password text NOT NULL) STRICT;
diff --git a/test.sh b/test.sh
index da92863b..90529058 100755
--- a/test.sh
+++ b/test.sh
@@ -80,46 +80,45 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
-00000000: 1f8b 0800 0000 0000 0003 edda b14e db40  .............N.@
-00000010: 18c0 f133 0909 8908 41ea e0a5 4837 1609  ...3....A...H7..
-00000020: 419c 12a6 562a 4519 1029 2d21 0c4c 9151  A...V*E..)-!.L.Q
-00000030: ae60 9138 d477 1130 c273 7429 efc3 d29d  .`.8.w.0.st)....
-00000040: f7e8 54d5 311c 8256 210c 456d ddff 4fb2  ..T.1..V!.Em..O.
-00000050: bf73 eeec dc7d 3e0f 27bb 1fed 0566 b1b3  .s...}>.'....f..
-00000060: 279e 5025 b6b2 bc9c 44ef a758 f1aa c3bd  '.P%....D..X....
-00000070: f096 57bc 6ab5 e6d5 6a2b a2e2 552a 7190  ..W.j...j+..U*q.
-00000080: 95a7 ec94 35d0 c68f a414 f17f 3ed8 6e5c  ....5.......>.n\
-00000090: fd3f 6a7b ab11 1825 3ff6 a39e 6fe4 4b31  .?j{...%?...o.K1
-000000a0: 2b1c 47bc 89f3 2184 136f c53b 4d33 f196  +.G...!..o.;M3..
-000000b0: bd73 ec3c e2f2 8e58 8c2e 4ae5 6fa2 307d  .s.<...X..J.o.0}
-000000c0: 25ca 99f2 65f9 a2f4 7de6 ebcc 97e9 abd2  %...e...}.......
-000000d0: 65e9 f36f 1c08 0000 0080 ffdb d9ab 7cde  e..o..........|.
-000000e0: 9d9b 73ce 378c bfd7 55a1 3a1e 6815 691b  ..s.7...U.:.h.i.
-000000f0: a7d6 9af5 d556 5db6 56df 36ea d2fe 2a5f  .....V].V.6...*_
-00000100: 140b 91da 0fb4 897c 13f4 c376 d091 4168  .......|...v..Ah
-00000110: d4be 8ae4 5114 f4fc e854 1eaa d385 6241  ....Q....T....bA
-00000120: 9b41 4785 66d8 c0a8 1323 7736 d7b7 76ea  .AG.f....#w6..v.
-00000130: 72f3 7d4b 6eee 341a 718b e105 43bf a746  r.}Kn.4.q...C..F
-00000140: d51f f95a 1ff7 a39b f36d c5bc dc6e 35d7  ...Z.....m...n5.
-00000150: d75a 4b85 9cbb 36e7 8820 eca8 13fd a91b  .ZK...6.. ......
-00000160: 2fd4 dafe c0f4 93e3 b6ed 6fbb 6a4b c5a5  /.........o.jK..
-00000170: a947 9de0 d952 e14c 66af 13f4 2c49 9056  .G...R.Lf...,I.V
-00000180: 5ac7 23d6 364e de4b 90fd 354e 90bc 61fa  Z.#.6N.K..5N..a.
-00000190: 872a bcee fc87 e6fa bbd5 e6ae dca8 ef2e  .*..............
-000001a0: dcd6 8f19 bf6d a64e 8e82 38ab 91f2 bbbf  .....m.N..8.....
-000001b0: 2621 f7d0 986c 9fda 555b ca2f 4d3e ea04  &!...l..U[./M>..
-000001c0: cf96 7267 cf9d bceb bace b99b 2421 c94c  ..rg........$!.L
-000001d0: b29b b837 fcdb c931 723e 8cbd dbc7 9d03  ...7...1r>......
-000001e0: 5f1f dcbf d923 e791 4dc0 7c26 e7be 7647  _....#..M.|&..vG
-000001f0: 8de7 660a 2421 3b3f 31be a997 84e1 5a7e  ..f.$!;?1.....Z~
-00000200: 6af8 8894 86bb d93f fa94 0200 0000 0080  j......?........
-00000210: 2796 bce0 67fd 0f00 0000 0040 aab1 fe07  '...g......@....
-00000220: 0000 0000 20fd f8fe 1f00 0000 0080 f4e3  .... ...........
-00000230: fd3f 0000 0000 00e9 c7fa 1f00 0000 0080  .?..............
-00000240: f4e3 fb7f 0000 0000 00d2 8ff7 ff00 0000  ................
-00000250: 0000 a41f eb7f 0000 0000 0000 0000 0000  ................
-00000260: 0000 0000 0000 0000 00f8 3bfd 00af 11e8  ..........;.....
-00000270: e900 c800 00                             .....
+00000000: 1f8b 0800 0000 0000 0003 edda c14e db30  .............N.0
+00000010: 18c0 7187 9696 560a 459a b45c 86e4 e390  ..q...V.E..\....
+00000020: 104d dac2 6dd2 58d5 035a c746 690f 9caa  .M..m.X..Z.Fi...
+00000030: 54f5 4604 4d59 920a 384d e539 7619 efc3  T.F.MY..8M.9v...
+00000040: 654f b3d3 b434 c388 6e82 f6b0 6a5b f4ff  eO...4..n...j[..
+00000050: 49b1 9dd8 69fd d9c9 c172 8641 cf8b b6fa  I...i....r.A....
+00000060: 3db1 4076 6ca7 564b 72e7 97dc 762a 9354  =.@vl.VKr...v*.T
+00000070: 38b5 1da7 52d9 aed8 5547 d88e 6dd7 aa42  8...R...UG..m..B
+00000080: da8b ec94 360a 2337 9052 c4ff f968 bb59  ....6.#7.R...h.Y
+00000090: f5ff a9c3 83a6 1729 f97e 180c dc48 56c5  .......).~...HV.
+000000a0: 9a30 0cf1 321e 0f21 8cf8 28de 6b9a 898f  .0..2..!..(.k...
+000000b0: ecbd 7363 8e9f 37c4 5670 6d96 be89 8299  ..sc..7.Vpm.....
+000000c0: 11a5 4ce9 a674 6d7e 5ffd bafa c5cc 9837  ..L..tm~_......7
+000000d0: e6e7 3f18 0800 0000 00cc 367e 9acf 5beb  ..?.......6~..[.
+000000e0: ebc6 f853 e4f6 4e95 afce 47a1 0a42 9daf  ...S..N...G..B..
+000000f0: d45b 8ddd 7643 b677 5f35 1b52 5f95 cf8b  .[..vC.w_5.R_...
+00000100: 8530 1af5 951f 75bd be8c d445 243b fb7b  .0....u....E$;.{
+00000110: 079d 86dc 7fdb 96fb 9d66 73b3 5898 34f5  .........fs.X.4.
+00000120: dd81 7aa8 fecc 0dc3 f361 707b bfae d890  ..z......ap{....
+00000130: 87ed d65e bd5d 2ee4 acfa ba21 3cbf af2e  ...^.].....!<...
+00000140: c28f a7f1 42ad eb8e a261 72de d53d e956  ....B....ar..=.V
+00000150: 74a9 585e 99eb 0647 970a 6399 4d42 bf7a  t.X^...G..c.MB.z
+00000160: 9284 1eaa 30f4 867e a8f3 e5a9 d0f5 d538  ....0..~.......8
+00000170: 7479 2b1a 9e28 ff67 e7df b5f6 deec b68e  ty+..(.g........
+00000180: e4eb c6d1 e65d fd8c f875 3375 71e6 0597  .....]...u3uq...
+00000190: 3250 eee9 ef83 907b 2c26 dda7 6e45 97f2  2P.....{,&..nE..
+000001a0: e5e5 b96e 7074 2937 7e66 e42d cb32 aeac  ...npt)7~f.-.2..
+000001b0: 6410 9291 4992 a5a9 f0ef a63d 9e6e cf8f  d...I......=.n..
+000001c0: d407 15c8 b3c0 1bb8 71cf 4fd4 e53c b37d  ........q.O..<.}
+000001d0: de3f 76c3 e3e9 c9de 7ce8 39d2 03b0 91c9  .?v.....|.9.....
+000001e0: 592f ac87 e2b9 7d04 922c bbb1 34bb a993  Y/....}..,..4...
+000001f0: 6493 b5fc cae4 e137 27c9 da5f 7dff 0000  d......7'.._}...
+00000200: 0000 00c0 8225 1bfc acff 0100 0000 0048  .....%.........H
+00000210: 35d6 ff00 0000 0000 a41f dfff 0300 0000  5...............
+00000220: 0090 7eec ff03 0000 0000 907e acff 0100  ..~........~....
+00000230: 0000 0048 3fbe ff07 0000 0000 20fd d8ff  ...H?....... ...
+00000240: 0700 0000 0020 fd58 ff03 0000 0000 0000  ..... .X........
+00000250: 0000 0000 0000 0000 0000 0000 c0bf e907  ................
+00000260: 0823 875f 00c8 0000                      .#._....
 EOF
 
 # Restore the old orbit db after testing completes

From 8237f7e12dcfb2b634830eed20e1589d07498f1a Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Wed, 24 Apr 2024 14:55:41 -0400
Subject: [PATCH 09/10] orbit: db/hyperspace: remove references to orbit user
 id

This field isn't really used for anything. Its value is
managed by sqlite, and it only exists to get printed as
part of the user info... but that is just printing all fields
its not like it was actually there for any reason. Just cargo
cult. There is a rowid column provided automatically by sqlite
that it can fully handle behind the scenes, so why include this
column explicitly.
---
 orbit/db.py         | 4 ++--
 orbit/hyperspace.py | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/orbit/db.py b/orbit/db.py
index 24fa792f..ab5a6475 100644
--- a/orbit/db.py
+++ b/orbit/db.py
@@ -115,14 +115,14 @@ def usr_setpwdhash_username(usr): return _set(USR_SETPWDHASH_USERNAME, usr)
 
 
 USR_GET = """
-SELECT id, username, pwdhash, student_id
+SELECT username, pwdhash, student_id
 FROM users;
 """.strip()
 def usr_get(): return _get(USR_GET)
 
 
 USR_GETBY_USERNAME = """
-SELECT id, username, pwdhash, student_id
+SELECT username, pwdhash, student_id
 FROM users
 WHERE username = ?;
 """.strip()
diff --git a/orbit/hyperspace.py b/orbit/hyperspace.py
index f4706648..bb0a6dd1 100755
--- a/orbit/hyperspace.py
+++ b/orbit/hyperspace.py
@@ -30,7 +30,6 @@ def nou(u):
 
 
 USR_FMT = """
-Orbit ID        : {}
 Username        : {}
 Hashed Password : {}
 Student ID      : {}

From a5a4deb1b6a67593c46db9bac427beaef95c86e4 Mon Sep 17 00:00:00 2001
From: charliemirabile <46761267+charliemirabile@users.noreply.github.com>
Date: Wed, 24 Apr 2024 14:57:58 -0400
Subject: [PATCH 10/10] orbit: db: schema: remove unused orbit user id field

as of previous commit this no longer is used for anything so we
can remove it from the schema.

binary blob needed updating as always.
---
 orbit/init-db.sql |  1 -
 test.sh           | 75 +++++++++++++++++++++++------------------------
 2 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/orbit/init-db.sql b/orbit/init-db.sql
index ca9199d9..c1ea03e7 100644
--- a/orbit/init-db.sql
+++ b/orbit/init-db.sql
@@ -1,7 +1,6 @@
 PRAGMA foreign_keys=OFF;
 BEGIN TRANSACTION;
 CREATE TABLE users (
-	id integer primary key,
 	username text UNIQUE NOT NULL,
 	pwdhash text NOT NULL,
 	student_id text UNIQUE) STRICT;
diff --git a/test.sh b/test.sh
index 90529058..314fcacc 100755
--- a/test.sh
+++ b/test.sh
@@ -81,44 +81,43 @@ ${DOCKER} volume export singularity_orbit-db > test/orbit_orig.tar
 # Import an empty orbit db with no users or sessions
 xxd -r <<- 'EOF' | gunzip | ${DOCKER} volume import singularity_orbit-db -
 00000000: 1f8b 0800 0000 0000 0003 edda c14e db30  .............N.0
-00000010: 18c0 7187 9696 560a 459a b45c 86e4 e390  ..q...V.E..\....
-00000020: 104d dac2 6dd2 58d5 035a c746 690f 9caa  .M..m.X..Z.Fi...
-00000030: 54f5 4604 4d59 920a 384d e539 7619 efc3  T.F.MY..8M.9v...
-00000040: 654f b3d3 b434 c388 6e82 f6b0 6a5b f4ff  eO...4..n...j[..
-00000050: 49b1 9dd8 69fd d9c9 c172 8641 cf8b b6fa  I...i....r.A....
-00000060: 3db1 4076 6ca7 564b 72e7 97dc 762a 9354  =.@vl.VKr...v*.T
-00000070: 38b5 1da7 52d9 aed8 5547 d88e 6dd7 aa42  8...R...UG..m..B
-00000080: da8b ec94 360a 2337 9052 c4ff f968 bb59  ....6.#7.R...h.Y
-00000090: f5ff a9c3 83a6 1729 f97e 180c dc48 56c5  .......).~...HV.
-000000a0: 9a30 0cf1 321e 0f21 8cf8 28de 6b9a 898f  .0..2..!..(.k...
-000000b0: ecbd 7363 8e9f 37c4 5670 6d96 be89 8299  ..sc..7.Vpm.....
-000000c0: 11a5 4ce9 a674 6d7e 5ffd bafa c5cc 9837  ..L..tm~_......7
-000000d0: e6e7 3f18 0800 0000 00cc 367e 9acf 5beb  ..?.......6~..[.
-000000e0: ebc6 f853 e4f6 4e95 afce 47a1 0a42 9daf  ...S..N...G..B..
-000000f0: d45b 8ddd 7643 b677 5f35 1b52 5f95 cf8b  .[..vC.w_5.R_...
-00000100: 8530 1af5 951f 75bd be8c d445 243b fb7b  .0....u....E$;.{
-00000110: 079d 86dc 7fdb 96fb 9d66 73b3 5898 34f5  .........fs.X.4.
-00000120: dd81 7aa8 fecc 0dc3 f361 707b bfae d890  ..z......ap{....
-00000130: 87ed d65e bd5d 2ee4 acfa ba21 3cbf af2e  ...^.].....!<...
-00000140: c28f a7f1 42ad eb8e a261 72de d53d e956  ....B....ar..=.V
-00000150: 74a9 585e 99eb 0647 970a 6399 4d42 bf7a  t.X^...G..c.MB.z
-00000160: 9284 1eaa 30f4 867e a8f3 e5a9 d0f5 d538  ....0..~.......8
-00000170: 7479 2b1a 9e28 ff67 e7df b5f6 deec b68e  ty+..(.g........
-00000180: e4eb c6d1 e65d fd8c f875 3375 71e6 0597  .....]...u3uq...
-00000190: 3250 eee9 ef83 907b 2c26 dda7 6e45 97f2  2P.....{,&..nE..
-000001a0: e5e5 b96e 7074 2937 7e66 e42d cb32 aeac  ...npt)7~f.-.2..
-000001b0: 6410 9291 4992 a5a9 f0ef a63d 9e6e cf8f  d...I......=.n..
-000001c0: d407 15c8 b3c0 1bb8 71cf 4fd4 e53c b37d  ........q.O..<.}
-000001d0: de3f 76c3 e3e9 c9de 7ce8 39d2 03b0 91c9  .?v.....|.9.....
-000001e0: 592f ac87 e2b9 7d04 922c bbb1 34bb a993  Y/....}..,..4...
-000001f0: 6493 b5fc cae4 e137 27c9 da5f 7dff 0000  d......7'.._}...
-00000200: 0000 00c0 8225 1bfc acff 0100 0000 0048  .....%.........H
-00000210: 35d6 ff00 0000 0000 a41f dfff 0300 0000  5...............
-00000220: 0090 7eec ff03 0000 0000 907e acff 0100  ..~........~....
-00000230: 0000 0048 3fbe ff07 0000 0000 20fd d8ff  ...H?....... ...
-00000240: 0700 0000 0020 fd58 ff03 0000 0000 0000  ..... .X........
-00000250: 0000 0000 0000 0000 0000 0000 c0bf e907  ................
-00000260: 0823 875f 00c8 0000                      .#._....
+00000010: 18c0 7107 4a4b 2b85 224d 5a2e 20f9 3824  ..q.JK+."MZ. .8$
+00000020: 4493 8c72 9b34 56f5 80d6 b151 ca81 5395  D..r.4V....Q..S.
+00000030: aa9e 8806 0d8b 5395 9da6 ee51 7887 5df6  ......S....Qx.].
+00000040: 0e7b 8d5d f602 3b2e cd30 a29b 4a91 36b4  .{.]..;..0..J.6.
+00000050: 2dfa ffa4 d84e 6cb7 feec e460 2551 dc0b  -....Nl....`%Q..
+00000060: 93ad 7e4f dc23 37b5 b3bd 9de5 de4f b9eb  ..~O.#7......O..
+00000070: f993 5478 db3b 9eef d7fd ba5b 17ae e7ba  ..Tx.;.....[....
+00000080: 754f 48f7 3e07 650c 7512 c452 8af4 3f6f  uOH.>.e.u..R..?o
+00000090: 6d37 affe 3f75 78d0 0a13 255f 47f1 5990  m7..?ux...%_G.Y.
+000000a0: c8c7 6255 5896 789a ce87 1056 7a54 6e34  ..bUX.x....VzTn4
+000000b0: 5d4c 8fc2 8d73 eb0e 3f6f 89ad f8d2 ae7e  ]L...s..?o.....~
+000000c0: 1365 7b4d 54d7 aa9f ab97 2bce cad7 954f  .e{MT.....+....O
+000000d0: f69a fdc5 fef8 0703 0100 0000 80df 307e  ..............0~
+000000e0: 582a 39eb ebd6 f87d 12f4 4ed5 408d 865a  X*9....}..N.@..Z
+000000f0: c5da e4cb 8d76 73b7 d394 9ddd 67ad a634  .....vs.....g..4
+00000100: 57e5 a34a 5927 c3be 1a24 ddb0 2f13 7591  W..JY'...$../.u.
+00000110: c8a3 fdbd 83a3 a6dc 7fd9 91fb 47ad d666  ............G..f
+00000120: a53c 693a 08ce d4ac faf3 40eb 5114 5ff5  .<i:......@.Q._.
+00000130: 3715 1bf2 b0d3 de6b 746a e5a2 d358 b744  7......ktj...X.D
+00000140: 38e8 ab0b fdf6 34dd c175 8361 1265 e75d  8.....4..u.a.e.]
+00000150: 3392 ae6f 4a95 daf2 9d3a 78a6 541e cb42  3..oJ....:x.T..B
+00000160: 16fa 8707 59e8 5a69 1d46 036d f2a5 a9d0  ....Y.Zi.F.m....
+00000170: cdd5 3474 7925 89de a8c1 8fc1 bf6a efbd  ..4ty%.......j..
+00000180: d86d 1fcb e7cd e3cd ebfa 39f1 9b66 eae2  .m........9..f..
+00000190: 3c8c dfc9 5805 a7bf 4e42 f1b6 98cc 98ba  <...X...NB......
+000001a0: be29 956a 4b77 eae0 9952 71bc 6895 1cc7  .).jKw...Rq.h...
+000001b0: b1c6 2a9b 846c 66b2 6461 2afc eb65 9fbb  ..*..lf.da*..e..
+000001c0: a8a3 fe49 a04f a6d7 7473 d6ed 62e2 dc58  ...I.O..ts..b..X
+000001d0: 2c3a 4f9c 59c3 be5a e92c 2b6c 2ccc 6fea  ,:O.Y..Z.,+l,.o.
+000001e0: 65d9 642f bf3c b9c7 ed49 b2fa 571f 3300  e.d/.<...I..W.3.
+000001f0: 0000 0000 70cf b217 fcec ff01 0000 0000  ....p...........
+00000200: c835 f6ff 0000 0000 00e4 1fdf ff03 0000  .5..............
+00000210: 0000 907f bcff 0700 0000 0020 ffd8 ff03  ........... ....
+00000220: 0000 0000 907f 7cff 0f00 0000 0040 fef1  ......|......@..
+00000230: fe1f 0000 0000 80fc 63ff 0f00 0000 0000  ........c.......
+00000240: 0000 0000 0000 0000 0000 0000 0000 ffa6  ................
+00000250: ef58 8985 d900 c800 00                   .X.......
 EOF
 
 # Restore the old orbit db after testing completes
