cursedauth 0.7.0 β†’ 0.9.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userSessions.core.js","sourceRoot":"","sources":["../src/userSessions.core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,aAAa,GAEb,MAAM,qBAAqB,CAAC;AAC7B,oFAAoF;AACpF,mFAAmF;AACnF,qFAAqF;AACrF,oFAAoF;AACpF,gFAAgF;AAChF,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;mEAUuC,CAAC;AAiNpE;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAEpG;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACzC,IAAiB,EACjB,OAAoC;IAEpC,4EAA4E;IAC5E,6EAA6E;IAC7E,MAAM,WAAW,GAAG,OAAO,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C5B,CAAC;QAED,mBAAmB,CAAC,MAAM,EAAE,GAAG;YAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,OAAO,EAAE,CAAC;gBACb,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACF,CAAC;QAED,aAAa;QAEb,aAAa,CAAC,GAAG,EAAE,IAAI;YACtB,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YACrE,OAAO,GAAG,IAAI,MAAM,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QAChD,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -1,205 +1,23 @@
1
- import { type PlaceLookup } from "./clientDescription";
2
- export interface UserSessionStoreOptions {
3
- /** Per-app cookie name, e.g. "hobbies_session" β€” never shared across apps. */
4
- cookieName: string;
1
+ import { Database } from "bun:sqlite";
2
+ import { type SessionRows, type UserSessionStore, type UserSessionStoreCoreOptions } from "./userSessions.core";
3
+ export { createUserSessionStoreOver, SESSIONS_DDL, type SessionRecord, type SessionRow, type SessionRows, type SignedIn, type SignInOptions, type SlotOccupant, type UserSessionStore, type UserSessionStoreCoreOptions, } from "./userSessions.core";
4
+ export interface UserSessionStoreOptions extends UserSessionStoreCoreOptions {
5
5
  dbPath: string;
6
- sessionSecret: string;
7
- sessionTtlSeconds: number;
8
- /**
9
- * Where an address is, for the `place` stamped on a new session row.
10
- *
11
- * πŸ”΄ There is NO default here, and that is the one deliberate behaviour
12
- * change this module carries out of the previous generation. It used to
13
- * default to a machine-wide 375MB IP→city snapshot kept outside any repo;
14
- * this generation has two roots and nothing else, so a library may not
15
- * reach for a file it did not put there. Unset, the row records whatever
16
- * the edge headers said (`cf-ipcity` and friends) β€” which is what every
17
- * request behind Cloudflare already carries β€” or nothing.
18
- *
19
- * Pass a lookup to restore city-from-address; `null` and unset are the
20
- * same thing and both are safe in a test.
21
- */
22
- placeLookup?: PlaceLookup | null;
23
- now?: () => number;
24
6
  }
25
7
  /**
26
- * One live session, as anything outside this module may see it.
8
+ * The `sessions` table on `bun:sqlite`, in the shape the store reads it.
27
9
  *
28
- * Deliberately without the row id β€” see the header. Times are ms epoch so the
29
- * shape survives a JSON hop between two satellites without a date parser at
30
- * each end.
10
+ * Exported so a Bun-hosted app that already owns a `Database` can build the store over it
11
+ * β€” and so `sessionRows.sameShape.test.ts` can drive this implementation and the D1 one
12
+ * through exactly the same scenarios.
13
+ *
14
+ * πŸ”΄ The schema is still built as a three-column `CREATE` plus five `ALTER`s rather than
15
+ * from `SESSIONS_DDL`, deliberately. Every deployed satellite already has this table with
16
+ * live sessions in it, and a one-statement `CREATE TABLE IF NOT EXISTS` would silently do
17
+ * nothing to those files β€” leaving the store reading five columns that are not there. The
18
+ * `ALTER` sequence is the migration; `SESSIONS_DDL` is the same schema stated for a host
19
+ * that starts empty, and the sameShape spec is what proves the two agree.
31
20
  */
32
- export interface SessionRecord {
33
- /** Stable public name for this session: `sha256(id)`, first 24 hex chars.
34
- * What a revoke-one call names, and the only id that crosses the wire. */
35
- handle: string;
36
- userId: string;
37
- createdAt: number;
38
- /** Last request this session made, throttled to the minute β€” see `TOUCH`. */
39
- lastSeenAt: number;
40
- expiresAt: number;
41
- /** The user-agent verbatim, bounded, never parsed here. `""` for a session
42
- * minted before this column existed, or by a client that sent none. */
43
- userAgent: string;
44
- /** Best-effort client address, or `""`. Never used to authorize anything. */
45
- ip: string;
46
- /**
47
- * Where the address was, when the session was created β€” `"Austin, Texas,
48
- * US"`, or `""`.
49
- *
50
- * Stamped at sign-in and never refreshed, deliberately: the row answers
51
- * "where was I when I signed in on this thing", and a value that moved with
52
- * the session's later requests would make an old row disagree with the alert
53
- * that was mailed about it. Added 2026-08-25 with the same owner ask that
54
- * put the city in the security alerts.
55
- */
56
- place: string;
57
- /** Is this the session the request asking the question is holding? Only ever
58
- * true when `list` was given that request β€” "you are on this one" is the
59
- * difference between signing someone else out and signing yourself out. */
60
- current: boolean;
61
- }
62
- /** Who is signed in at one slot of this browser. */
63
- export interface SlotOccupant {
64
- slot: number;
65
- userId: string;
66
- }
67
- /** How a new session differs from the store's defaults. */
68
- export interface SignInOptions {
69
- /**
70
- * Which slot to put it in. Defaults to the slot the request names β€” which
71
- * for every existing caller is 0, the bare cookie name.
72
- */
73
- slot?: number;
74
- /**
75
- * Lifetime for THIS session, overriding the store's default.
76
- *
77
- * This is what "remember me" buys, and it is a property of the session
78
- * rather than of the store because the two answers have to coexist: the
79
- * owner's own browser keeps a month-long session while a shared machine
80
- * gets the short default. The row's `expires_at`, the cookie's embedded
81
- * expiry and the cookie's `Max-Age` are all derived from this one number,
82
- * so they cannot disagree.
83
- */
84
- ttlSeconds?: number;
85
- }
86
- /** A minted session and everything the caller needs to install it. */
87
- export interface SignedIn {
88
- /** The `Set-Cookie` header value, already slot- and lifetime-correct. */
89
- cookie: string;
90
- /** Where it landed β€” the caller has to tell the browser, via `?authuser=`. */
91
- slot: number;
92
- expiresAt: number;
93
- }
94
- export interface UserSessionStore {
95
- /** The cookie name this store was built with (for tests and smokes). */
96
- cookieName: string;
97
- /**
98
- * Mint a session for a user; returns the cookie VALUE.
99
- *
100
- * `req` is optional and every caller that has one should pass it: it is what
101
- * stamps the device and address onto the row, and a session that cannot say
102
- * where it came from is one the owner cannot recognise on the list. Omitting
103
- * it is legal (a CLI-minted session, a test) and lands as `""`, never as a
104
- * guess.
105
- */
106
- create(userId: string, req?: Request, options?: SignInOptions): string;
107
- /**
108
- * Mint a session AND the `Set-Cookie` that installs it, together.
109
- *
110
- * πŸ”΄ Prefer this over `create` + `sessionCookie` for anything slot- or
111
- * lifetime-aware. Those two are separate calls that each have to be told the
112
- * same slot and the same TTL, and the failure when they are not told the
113
- * same thing is silent: a session minted into slot 2 with a cookie written
114
- * to slot 0 evicts the account the person was already using and signs them
115
- * in as somebody else in the tab they did not touch.
116
- */
117
- signIn(userId: string, req: Request, options?: SignInOptions): SignedIn;
118
- /** Which slot this request is acting as. Never throws; garbage means 0. */
119
- slotOf(req: Request): number;
120
- /**
121
- * The account id this request's PAGE believes it is acting as, or null when
122
- * it did not say. Only ever compared against the resolved user β€” never a
123
- * credential, never a selector. See {@link ACCOUNT_USER_HEADER}.
124
- */
125
- expectedUserOf(req: Request): string | null;
126
- /** The user id this request's cookie proves, or null. */
127
- userIdOf(req: Request): string | null;
128
- /**
129
- * Every slot of this browser that holds a live session, slot order.
130
- *
131
- * This is the account switcher's whole data source, and the reason it can
132
- * offer a one-click swap with no password: an account with a live session
133
- * here is one this browser has already proved it may act as.
134
- */
135
- signedInSlots(req: Request): SlotOccupant[];
136
- /**
137
- * The slot already holding `userId` in this browser, or null.
138
- *
139
- * πŸ”΄ Signing in as somebody who is already signed in must REUSE their slot,
140
- * never take a second one. Otherwise every re-hop of an app that is already
141
- * open burns a slot, and five visits leave no room for the second account
142
- * the feature exists to hold.
143
- */
144
- slotForUser(req: Request, userId: string): number | null;
145
- /**
146
- * Where a NEW account should go: their existing slot, else the lowest empty
147
- * one, else null when all {@link MAX_ACCOUNT_SLOTS} are taken.
148
- *
149
- * Null is a real answer the caller must render, not an error β€” "sign out of
150
- * one of these first" is the only honest response, and silently evicting
151
- * somebody's session to make room is the thing that must not happen.
152
- */
153
- slotToAdd(req: Request, userId: string): number | null;
154
- /** End the session this request carries, in the slot it names. */
155
- revoke(req: Request): void;
156
- /**
157
- * End the session at ONE named slot of this browser; true if there was one.
158
- *
159
- * Distinct from `revoke` because the switcher acts on a slot the request is
160
- * NOT on β€” "remove that other account" is a button pressed from this tab
161
- * about a different tab's session.
162
- */
163
- revokeAt(req: Request, slot: number): boolean;
164
- /**
165
- * End EVERY slot's session in this browser; returns the slots that held one.
166
- *
167
- * The shared-machine exit. Distinct from `revokeAllForUser`, which ends one
168
- * account everywhere, where this ends every account in one place.
169
- */
170
- revokeEverySlot(req: Request): number[];
171
- /** End every session of a user (delete / temp password). */
172
- revokeAllForUser(userId: string): void;
173
- /** End every OTHER session of a user (their own password change). */
174
- revokeOthersForUser(userId: string, req: Request): void;
175
- /**
176
- * Every live session of one user, newest first.
177
- *
178
- * Expired rows are never returned β€” the sweep is opportunistic, so the query
179
- * filters rather than trusting the table to be clean.
180
- */
181
- listForUser(userId: string, req?: Request): SessionRecord[];
182
- /**
183
- * End ONE session, named by its handle, and say whether it existed.
184
- *
185
- * πŸ”΄ The user id is REQUIRED and is part of the match, not a courtesy. A
186
- * handle is shown on a screen and travels between apps; scoping the delete
187
- * to the account it was listed under means a stray, stale or guessed handle
188
- * can only ever end a session of the person it was already about.
189
- */
190
- revokeByHandle(userId: string, handle: string): boolean;
191
- /**
192
- * `Set-Cookie` for a fresh value, TLS-aware.
193
- *
194
- * `Max-Age` is read out of the VALUE's own embedded expiry rather than from
195
- * the store's default, so a remember-me session's cookie outlives the
196
- * default the same way its row does. A value that cannot be read falls back
197
- * to the store default β€” a cookie slightly too short is a re-login, where
198
- * one too long is a dead cookie sent on every request forever.
199
- */
200
- sessionCookie(value: string, req: Request, slot?: number): string;
201
- /** `Set-Cookie` that ends the browser's copy, for one slot. */
202
- clearedCookie(req: Request, slot?: number): string;
203
- }
21
+ export declare function createSqliteSessionRows(db: Database): SessionRows;
204
22
  export declare function createUserSessionStore(options: UserSessionStoreOptions): UserSessionStore;
205
23
  //# sourceMappingURL=userSessions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"userSessions.d.ts","sourceRoot":"","sources":["../src/userSessions.ts"],"names":[],"mappings":"AA8EA,OAAO,EAKN,KAAK,WAAW,EAChB,MAAM,qBAAqB,CAAC;AAW7B,MAAM,WAAW,uBAAuB;IACvC,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aA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