cursedauth 0.9.0 → 0.9.2

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.
Files changed (72) hide show
  1. package/dist/_bunOnly.d.ts +2 -0
  2. package/dist/_bunOnly.d.ts.map +1 -0
  3. package/dist/_bunOnly.js +11 -0
  4. package/dist/_bunOnly.js.map +1 -0
  5. package/dist/account/AccountMenu.d.ts +2 -2
  6. package/dist/account/AccountMenu.d.ts.map +1 -1
  7. package/dist/account/AccountMenu.js +8 -8
  8. package/dist/account/AccountMenu.js.map +1 -1
  9. package/dist/account/AccountNotice.d.ts +1 -1
  10. package/dist/account/AccountNotice.d.ts.map +1 -1
  11. package/dist/account/AccountNotice.js +3 -3
  12. package/dist/account/AccountNotice.js.map +1 -1
  13. package/dist/account/accountNotice.state.d.ts +1 -1
  14. package/dist/account/accountNotice.state.d.ts.map +1 -1
  15. package/dist/account/accountNotice.state.js +2 -2
  16. package/dist/account/accountNotice.state.js.map +1 -1
  17. package/dist/accountSlot.client.d.ts +1 -1
  18. package/dist/accountSlot.client.d.ts.map +1 -1
  19. package/dist/accountSlot.client.js +1 -1
  20. package/dist/accountSlot.client.js.map +1 -1
  21. package/dist/auth.d.ts +1 -1
  22. package/dist/auth.d.ts.map +1 -1
  23. package/dist/auth.js +3 -3
  24. package/dist/auth.js.map +1 -1
  25. package/dist/auth.server.js +1 -1
  26. package/dist/auth.server.js.map +1 -1
  27. package/dist/contentCensus.d.ts +1 -1
  28. package/dist/contentCensus.d.ts.map +1 -1
  29. package/dist/contentCensus.js +13 -0
  30. package/dist/contentCensus.js.map +1 -1
  31. package/dist/d1Stores.d.ts +4 -4
  32. package/dist/d1Stores.d.ts.map +1 -1
  33. package/dist/d1Stores.js +3 -3
  34. package/dist/d1Stores.js.map +1 -1
  35. package/dist/index.d.ts +8 -8
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +7 -7
  38. package/dist/index.js.map +1 -1
  39. package/dist/ssoAutoSignIn.js +2 -2
  40. package/dist/ssoAutoSignIn.js.map +1 -1
  41. package/dist/ssoConsumer.server.d.ts +3 -3
  42. package/dist/ssoConsumer.server.d.ts.map +1 -1
  43. package/dist/ssoConsumer.server.js +6 -6
  44. package/dist/ssoConsumer.server.js.map +1 -1
  45. package/dist/ssoTestHarness.d.ts +1 -1
  46. package/dist/ssoTestHarness.d.ts.map +1 -1
  47. package/dist/ssoTestHarness.js +2 -2
  48. package/dist/ssoTestHarness.js.map +1 -1
  49. package/dist/userSessions.core.d.ts +1 -1
  50. package/dist/userSessions.core.d.ts.map +1 -1
  51. package/dist/userSessions.core.js +4 -4
  52. package/dist/userSessions.core.js.map +1 -1
  53. package/dist/userSessions.d.ts +2 -2
  54. package/dist/userSessions.d.ts.map +1 -1
  55. package/dist/userSessions.js +2 -2
  56. package/dist/userSessions.js.map +1 -1
  57. package/package.json +4 -4
  58. package/src/_bunOnly.ts +13 -0
  59. package/src/account/AccountMenu.tsx +8 -8
  60. package/src/account/AccountNotice.tsx +5 -5
  61. package/src/account/accountNotice.state.ts +3 -3
  62. package/src/accountSlot.client.ts +1 -1
  63. package/src/auth.server.ts +1 -1
  64. package/src/auth.ts +3 -3
  65. package/src/contentCensus.ts +18 -1
  66. package/src/d1Stores.ts +4 -4
  67. package/src/index.ts +8 -8
  68. package/src/ssoAutoSignIn.ts +2 -2
  69. package/src/ssoConsumer.server.ts +7 -7
  70. package/src/ssoTestHarness.ts +2 -2
  71. package/src/userSessions.core.ts +4 -4
  72. package/src/userSessions.ts +2 -2
@@ -4,7 +4,7 @@
4
4
  // `auth.ts`. This file is separate for one reason: the server must not pull React into
5
5
  // its bundle. Change them together; they are one boundary.
6
6
  import type { Context, MiddlewareHandler, Next } from "hono";
7
- import { isProductionRuntime } from "./runtimeMode";
7
+ import { isProductionRuntime } from "./runtimeMode.js";
8
8
 
9
9
  export interface SessionClaims {
10
10
  userId: string;
package/src/auth.ts CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  useRef,
43
43
  useState,
44
44
  } from "react";
45
- import { isProductionRuntime } from "./runtimeMode";
45
+ import { isProductionRuntime } from "./runtimeMode.js";
46
46
  import {
47
47
  clearSsoAutoState,
48
48
  decideSsoAutoSignIn,
@@ -51,7 +51,7 @@ import {
51
51
  ssoSignedOutHere,
52
52
  startSsoSignIn,
53
53
  startSsoSignOut,
54
- } from "./ssoAutoSignIn";
54
+ } from "./ssoAutoSignIn.js";
55
55
 
56
56
  // Re-exported through THIS subpath on purpose: `cursedauth/auth`
57
57
  // is already the one client-side auth import every satellite has, and a second
@@ -75,7 +75,7 @@ export {
75
75
  takeSsoError,
76
76
  useSsoAutoSignIn,
77
77
  useSsoErrorNotice,
78
- } from "./ssoAutoSignIn";
78
+ } from "./ssoAutoSignIn.js";
79
79
 
80
80
  export interface SatelliteUser {
81
81
  id: string;
@@ -21,7 +21,7 @@
21
21
  * @see `ssoConsumer.server.ts` for the route, and `sso.ts` for the ticket.
22
22
  */
23
23
  import type { Database } from "bun:sqlite";
24
- import type { ContentCensus, ContentCensusUser } from "./sso";
24
+ import type { ContentCensus, ContentCensusUser } from "./sso.js";
25
25
 
26
26
  /** One kind of thing an app keeps per account. */
27
27
  export interface CensusCounter {
@@ -47,6 +47,10 @@ const tableExists = (db: Database, table: string): boolean =>
47
47
  (db.query("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) ?? null) !==
48
48
  null;
49
49
 
50
+ // `table` has already passed IDENTIFIER, which is what makes interpolating it safe.
51
+ const columnExists = (db: Database, table: string, column: string): boolean =>
52
+ (db.query(`PRAGMA table_info(${table})`).all() as { name: string }[]).some((c) => c.name === column);
53
+
50
54
  /**
51
55
  * Build a `contentCensus` implementation from a list of tables.
52
56
  *
@@ -69,6 +73,19 @@ export function countingCensus(
69
73
  if (counter.column !== undefined && !IDENTIFIER.test(counter.column)) {
70
74
  throw new Error(`census counter "${counter.kind}": ${counter.column} is not a column name`);
71
75
  }
76
+ // 🔴 A table that EXISTS without the per-user column is the same typo, and until
77
+ // 0.9.2 it surfaced only as `no such column: user_id` in a log line, on every
78
+ // census call, for as long as the app ran. Measured 2026-09-19/22: collections and
79
+ // music both did exactly that — single-owner libraries handed to a per-user
80
+ // counter — and the owner's share dialog was shown nothing. An app whose rows
81
+ // belong to no account wants `sharedCensus`; say so at boot.
82
+ const column = counter.column ?? "user_id";
83
+ if (tableExists(db, counter.table) && !columnExists(db, counter.table, column)) {
84
+ throw new Error(
85
+ `census counter "${counter.kind}": table ${counter.table} has no ${column} column. ` +
86
+ "If this app's rows belong to no individual account, use sharedCensus instead.",
87
+ );
88
+ }
72
89
  }
73
90
 
74
91
  return (userIds) => {
package/src/d1Stores.ts CHANGED
@@ -57,11 +57,11 @@ import {
57
57
  type RawSsoUserRow,
58
58
  type SsoUserRow,
59
59
  type SsoUserStore,
60
- } from "./ssoUsers";
61
- import type { SessionRow, SessionRows } from "./userSessions.core";
60
+ } from "./ssoUsers.js";
61
+ import type { SessionRow, SessionRows } from "./userSessions.core.js";
62
62
 
63
- export { SESSIONS_DDL } from "./userSessions.core";
64
- export { SSO_USERS_DDL } from "./ssoUsers";
63
+ export { SESSIONS_DDL } from "./userSessions.core.js";
64
+ export { SSO_USERS_DDL } from "./ssoUsers.js";
65
65
 
66
66
  /**
67
67
  * The slice of a D1 handle these stores use.
package/src/index.ts CHANGED
@@ -30,7 +30,7 @@ export {
30
30
  type SsoConsumer,
31
31
  type SsoConsumerOptions,
32
32
  type SsoUser,
33
- } from "./ssoConsumer.server";
33
+ } from "./ssoConsumer.server.js";
34
34
  export {
35
35
  createSqliteSessionRows,
36
36
  createUserSessionStore,
@@ -45,7 +45,7 @@ export {
45
45
  type UserSessionStore,
46
46
  type UserSessionStoreCoreOptions,
47
47
  type UserSessionStoreOptions,
48
- } from "./userSessions";
48
+ } from "./userSessions.js";
49
49
  /*
50
50
  * The `sso_users` seam. 🔴 `cursedauth/d1-stores` is deliberately NOT re-exported from
51
51
  * this barrel: it has no reason to be here (a Worker cannot import this file at all —
@@ -59,7 +59,7 @@ export {
59
59
  SSO_USERS_DDL,
60
60
  type SsoUserRow,
61
61
  type SsoUserStore,
62
- } from "./ssoUsers";
62
+ } from "./ssoUsers.js";
63
63
  export {
64
64
  DEFAULT_GATE_PATH,
65
65
  type GatedMountPlan,
@@ -67,14 +67,14 @@ export {
67
67
  type Mounter,
68
68
  mountGatedApp,
69
69
  type SessionGate,
70
- } from "./mountGatedApp";
71
- export { type CensusCounter, countingCensus, sharedCensus } from "./contentCensus";
70
+ } from "./mountGatedApp.js";
71
+ export { type CensusCounter, countingCensus, sharedCensus } from "./contentCensus.js";
72
72
  export {
73
73
  LOCAL_AUTH_URL,
74
74
  STAGE_IDENTITY_ENV,
75
75
  stageIdentityIsLocal,
76
- } from "./stageIdentity";
77
- export type { ContentCensus, ContentCensusUser } from "./sso";
76
+ } from "./stageIdentity.js";
77
+ export type { ContentCensus, ContentCensusUser } from "./sso.js";
78
78
  /*
79
79
  * The bearer-token half of the boundary. `getSessionClaims` was the only piece this
80
80
  * barrel published until 2026-09-15, because the four apps graduated before `roms`
@@ -98,4 +98,4 @@ export {
98
98
  SESSION_CLAIMS_KEY,
99
99
  type SessionClaims,
100
100
  type SessionVerifier,
101
- } from "./auth.server";
101
+ } from "./auth.server.js";
@@ -52,8 +52,8 @@
52
52
  * from `ssoConsumer.server.ts`: that module pulls in `bun:sqlite` and hono,
53
53
  * and this one runs in a browser. `ssoAutoSignIn.test.ts` pins them equal. */
54
54
  import { useEffect, useRef, useState } from "react";
55
- import { currentAccountSlot } from "./accountSlot.client";
56
- import { ACCOUNT_SLOT_PARAM } from "./accountSlots";
55
+ import { currentAccountSlot } from "./accountSlot.client.js";
56
+ import { ACCOUNT_SLOT_PARAM } from "./accountSlots.js";
57
57
 
58
58
  export const SSO_START_PATH = "/api/auth/sso/start";
59
59
  /**
@@ -31,10 +31,10 @@ import type { KeyObject } from "node:crypto";
31
31
  import { createPublicKey } from "node:crypto";
32
32
  import type { Database } from "bun:sqlite";
33
33
  import type { Context, Hono, MiddlewareHandler, Next } from "hono";
34
- import { stageIdentityIsLocal } from "./stageIdentity";
35
- import { SESSION_CLAIMS_KEY, type SessionClaims } from "./auth.server";
36
- import { isSecureRequest } from "./secureRequest";
37
- import { createSqliteSsoUserStore, type SsoUserRow, type SsoUserStore } from "./ssoUsers";
34
+ import { stageIdentityIsLocal } from "./stageIdentity.js";
35
+ import { SESSION_CLAIMS_KEY, type SessionClaims } from "./auth.server.js";
36
+ import { isSecureRequest } from "./secureRequest.js";
37
+ import { createSqliteSsoUserStore, type SsoUserRow, type SsoUserStore } from "./ssoUsers.js";
38
38
  import {
39
39
  CENSUS_MAX_SUBJECTS,
40
40
  type ContentCensus,
@@ -47,7 +47,7 @@ import {
47
47
  verifyGrant,
48
48
  verifyRevocation,
49
49
  verifySessionsRequest,
50
- } from "./sso";
50
+ } from "./sso.js";
51
51
  import {
52
52
  ACCOUNT_DRIFT_STATUS,
53
53
  accountDriftBody,
@@ -55,8 +55,8 @@ import {
55
55
  MAX_ACCOUNT_SLOTS,
56
56
  normalizeSlot,
57
57
  withSlot,
58
- } from "./accountSlots";
59
- import type { UserSessionStore } from "./userSessions";
58
+ } from "./accountSlots.js";
59
+ import type { UserSessionStore } from "./userSessions.js";
60
60
 
61
61
  export const SSO_CALLBACK_PATH = "/api/auth/sso/callback";
62
62
  export const SSO_START_PATH = "/api/auth/sso/start";
@@ -14,8 +14,8 @@
14
14
  * app had copied.
15
15
  */
16
16
  import type { Hono } from "hono";
17
- import { generateSsoKeyPair, mintGrant, type SsoKeyPair } from "./sso";
18
- import { SSO_CALLBACK_PATH } from "./ssoConsumer.server";
17
+ import { generateSsoKeyPair, mintGrant, type SsoKeyPair } from "./sso.js";
18
+ import { SSO_CALLBACK_PATH } from "./ssoConsumer.server.js";
19
19
 
20
20
  /** A user as the accounts satellite would know them — the shape grants are minted from. */
21
21
  export interface SeededTestUser {
@@ -65,22 +65,22 @@ import {
65
65
  normalizeSlot,
66
66
  slotCookieName,
67
67
  slotFromUrl,
68
- } from "./accountSlots";
68
+ } from "./accountSlots.js";
69
69
  import {
70
70
  clientAddressOf,
71
71
  clientFactsOf,
72
72
  clientUserAgentOf,
73
73
  describePlace,
74
74
  type PlaceLookup,
75
- } from "./clientDescription";
75
+ } from "./clientDescription.js";
76
76
  // 🔴 The compare, not a copy of it. This module carried its OWN `constantTimeEqual`
77
77
  // until 2026-09-17 — a `node:crypto` `timingSafeEqual` with both sides padded to a
78
78
  // common length — while `constantTime.ts` sat two files away with the same contract.
79
79
  // That made an eighth copy of this primitive inside the very package that publishes
80
80
  // it. Both forms were correct; neither knew about the other, which is the whole
81
81
  // failure mode.
82
- import { constantTimeEqual } from "./constantTime";
83
- import { isSecureRequest } from "./secureRequest";
82
+ import { constantTimeEqual } from "./constantTime.js";
83
+ import { isSecureRequest } from "./secureRequest.js";
84
84
 
85
85
  /**
86
86
  * One row of the `sessions` table, as both implementations hand it over.
@@ -35,7 +35,7 @@ import {
35
35
  type SessionRows,
36
36
  type UserSessionStore,
37
37
  type UserSessionStoreCoreOptions,
38
- } from "./userSessions.core";
38
+ } from "./userSessions.core.js";
39
39
 
40
40
  export {
41
41
  createUserSessionStoreOver,
@@ -48,7 +48,7 @@ export {
48
48
  type SlotOccupant,
49
49
  type UserSessionStore,
50
50
  type UserSessionStoreCoreOptions,
51
- } from "./userSessions.core";
51
+ } from "./userSessions.core.js";
52
52
 
53
53
  export interface UserSessionStoreOptions extends UserSessionStoreCoreOptions {
54
54
  dbPath: string;