@ai-matrx/auth 0.2.4 → 0.2.5

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — @ai-matrx/auth
2
2
 
3
+ ## 0.2.5
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/auth/v0.2.4..npm/auth/v0.2.5 -- apps/shared/auth`).
7
+ No source changes intended and no consumer action required.
8
+
3
9
  ## 0.2.4
4
10
  ### active organization options (round 2)
5
11
 
@@ -48,7 +54,7 @@ No source changes intended and no consumer action required.
48
54
  attaches (bounded wait, one retry after the session re-resolves, a foreign-authority token is signed out
49
55
  and never retried, every firing reported). Host-neutral: the host injects `report`, `isAnonymousByDesign`,
50
56
  `bypassesSessionWait`, `endUnverifiable`. From the website's `utils/supabase/sessionBarrier.ts`.
51
- - `/guest` (new section) — `createGuestHandover(...)`: a visitor's guest data survives sign-in (claim into the
57
+ - `/guest` (new section) — `createGuestHandover(...)` (the host injects `readGuestClaims`; the section builds no Supabase client): a visitor's guest data survives sign-in (claim into the
52
58
  account the session ends in, cookie kept on failure so the next sign-in retries) and sign-up (the same
53
59
  account is promoted in place); `guestClientCookieOptions` (the guest client's own cookie name, injected);
54
60
  `createGuestSessionEnsurer` (mint a guest once per tab/browser). From the website's `lib/guest/*`.
@@ -67,7 +73,8 @@ Tests: `session-barrier.test.ts`, `guest.test.ts`.
67
73
  (injectable `messages`), `resolveOrganizationWithLink` (the one ladder + the link, share admission injected).
68
74
  - `organization-gate` — `createOrganizationBootstrapGate`, `isNotAMemberRefusal`, `createNotAMemberRefusalNotice`,
69
75
  `resolveChildOrganizationId`, `resolveAdminSeat`, `adminSeatReplacesUserContext`.
70
- Tests: active-organization (+5), organization-gate (9).
76
+ - `readMembershipRows(db, containerType)` — the paged `mbr_for_user` raw-row read (any container type), returning the failing page's `{error,status}` so a host can wrap it in its own session retry.
77
+ Tests: active-organization (+5), organization-gate (11).
71
78
 
72
79
  ## 0.2.0
73
80
 
@@ -647,4 +647,4 @@ declare function storageHeldOrganization(storage: Pick<Storage, "getItem" | "set
647
647
  declare function memoryHeldOrganization(): HeldOrganizationStore;
648
648
  declare function createActiveOrganization(options: CreateActiveOrganizationOptions): ActiveOrganization;
649
649
 
650
- export { createNotAMemberRefusalNotice as $, type AuthClient as A, NoActiveOrganizationError as B, type CachedActiveOrganization as C, NotAMemberError as D, type NotAMemberRefusalNotice as E, ORGANIZATION_RESOLUTION_TIMEOUT_MS as F, type OrganizationBootstrapGate as G, type HeldOrganizationStore as H, type OrganizationLapse as I, type OrganizationMembership as J, type OrganizationRefusal as K, LINK_ORGANIZATION_QUERY_KEY as L, type OrganizationRung as M, NOT_A_MEMBER_RECHECK_GAP_MS as N, ORGANIZATION_ENTITY_TYPE as O, type OrganizationsDb as P, type ParentOrganization as Q, type ReadMembershipsOptions as R, type SessionSourceLike as S, type ResolveWithLinkInput as T, type UserCredentialsPort as U, type ResolvedOrganization as V, type ResolvedWithLink as W, adminSeatReplacesUserContext as X, classifyLinkOrganizationValue as Y, classifyOrganizationRefusal as Z, createActiveOrganization as _, SignInError as a, createOrganizationBootstrapGate as a0, decideLinkOrganization as a1, isNotAMemberRefusal as a2, linkOrganizationMalformedMessage as a3, linkOrganizationNotAMemberMessage as a4, linkOrganizationOfferMessage as a5, linkOrganizationSwitchAnnouncement as a6, memoryHeldOrganization as a7, oldestMembership as a8, orderOrganizations as a9, organizationMatches as aa, readAccountOrganizationChoices as ab, readLinkOrganizationParam as ac, readMemberships as ad, readOrganizationFavourites as ae, resolveActiveOrganization as af, resolveActiveOrganizationLazily as ag, resolveAdminSeat as ah, resolveChildOrganizationId as ai, resolveOrganizationWithLink as aj, setOrganizationFavourite as ak, storageHeldOrganization as al, toAccountOrganizationChoices as am, writeLastActiveOrganization as an, writeStartupOrganization as ao, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, type AccountOrganizationChoices as h, invalidatePerson as i, type ActiveOrganization as j, type ActiveOrganizationSnapshot as k, type ActiveOrganizationStatus as l, type AdminSeat as m, type AdminSeatInput as n, onSessionChange as o, type ArchiveFilter as p, type CreateActiveOrganizationOptions as q, refreshSession as r, sessionCredentials as s, type LadderInput as t, updatePerson as u, type LinkOrganizationDecision as v, type LinkOrganizationDecisionInput as w, type LinkOrganizationMembership as x, type LinkOrganizationMessages as y, type LinkOrganizationParam as z };
650
+ export { createNotAMemberRefusalNotice as $, type AuthClient as A, NoActiveOrganizationError as B, type CachedActiveOrganization as C, NotAMemberError as D, type NotAMemberRefusalNotice as E, ORGANIZATION_ENTITY_TYPE as F, ORGANIZATION_RESOLUTION_TIMEOUT_MS as G, type HeldOrganizationStore as H, type OrganizationBootstrapGate as I, type OrganizationLapse as J, type OrganizationMembership as K, LINK_ORGANIZATION_QUERY_KEY as L, type OrganizationRefusal as M, NOT_A_MEMBER_RECHECK_GAP_MS as N, type OrganizationsDb as O, type OrganizationRung as P, type ParentOrganization as Q, type ReadMembershipsOptions as R, type SessionSourceLike as S, type ResolveWithLinkInput as T, type UserCredentialsPort as U, type ResolvedOrganization as V, type ResolvedWithLink as W, adminSeatReplacesUserContext as X, classifyLinkOrganizationValue as Y, classifyOrganizationRefusal as Z, createActiveOrganization as _, SignInError as a, createOrganizationBootstrapGate as a0, decideLinkOrganization as a1, isNotAMemberRefusal as a2, linkOrganizationMalformedMessage as a3, linkOrganizationNotAMemberMessage as a4, linkOrganizationOfferMessage as a5, linkOrganizationSwitchAnnouncement as a6, memoryHeldOrganization as a7, oldestMembership as a8, orderOrganizations as a9, organizationMatches as aa, readAccountOrganizationChoices as ab, readLinkOrganizationParam as ac, readMemberships as ad, readOrganizationFavourites as ae, resolveActiveOrganization as af, resolveActiveOrganizationLazily as ag, resolveAdminSeat as ah, resolveChildOrganizationId as ai, resolveOrganizationWithLink as aj, setOrganizationFavourite as ak, storageHeldOrganization as al, toAccountOrganizationChoices as am, writeLastActiveOrganization as an, writeStartupOrganization as ao, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, type AccountOrganizationChoices as h, invalidatePerson as i, type ActiveOrganization as j, type ActiveOrganizationSnapshot as k, type ActiveOrganizationStatus as l, type AdminSeat as m, type AdminSeatInput as n, onSessionChange as o, type ArchiveFilter as p, type CreateActiveOrganizationOptions as q, refreshSession as r, sessionCredentials as s, type LadderInput as t, updatePerson as u, type LinkOrganizationDecision as v, type LinkOrganizationDecisionInput as w, type LinkOrganizationMembership as x, type LinkOrganizationMessages as y, type LinkOrganizationParam as z };
@@ -647,4 +647,4 @@ declare function storageHeldOrganization(storage: Pick<Storage, "getItem" | "set
647
647
  declare function memoryHeldOrganization(): HeldOrganizationStore;
648
648
  declare function createActiveOrganization(options: CreateActiveOrganizationOptions): ActiveOrganization;
649
649
 
650
- export { createNotAMemberRefusalNotice as $, type AuthClient as A, NoActiveOrganizationError as B, type CachedActiveOrganization as C, NotAMemberError as D, type NotAMemberRefusalNotice as E, ORGANIZATION_RESOLUTION_TIMEOUT_MS as F, type OrganizationBootstrapGate as G, type HeldOrganizationStore as H, type OrganizationLapse as I, type OrganizationMembership as J, type OrganizationRefusal as K, LINK_ORGANIZATION_QUERY_KEY as L, type OrganizationRung as M, NOT_A_MEMBER_RECHECK_GAP_MS as N, ORGANIZATION_ENTITY_TYPE as O, type OrganizationsDb as P, type ParentOrganization as Q, type ReadMembershipsOptions as R, type SessionSourceLike as S, type ResolveWithLinkInput as T, type UserCredentialsPort as U, type ResolvedOrganization as V, type ResolvedWithLink as W, adminSeatReplacesUserContext as X, classifyLinkOrganizationValue as Y, classifyOrganizationRefusal as Z, createActiveOrganization as _, SignInError as a, createOrganizationBootstrapGate as a0, decideLinkOrganization as a1, isNotAMemberRefusal as a2, linkOrganizationMalformedMessage as a3, linkOrganizationNotAMemberMessage as a4, linkOrganizationOfferMessage as a5, linkOrganizationSwitchAnnouncement as a6, memoryHeldOrganization as a7, oldestMembership as a8, orderOrganizations as a9, organizationMatches as aa, readAccountOrganizationChoices as ab, readLinkOrganizationParam as ac, readMemberships as ad, readOrganizationFavourites as ae, resolveActiveOrganization as af, resolveActiveOrganizationLazily as ag, resolveAdminSeat as ah, resolveChildOrganizationId as ai, resolveOrganizationWithLink as aj, setOrganizationFavourite as ak, storageHeldOrganization as al, toAccountOrganizationChoices as am, writeLastActiveOrganization as an, writeStartupOrganization as ao, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, type AccountOrganizationChoices as h, invalidatePerson as i, type ActiveOrganization as j, type ActiveOrganizationSnapshot as k, type ActiveOrganizationStatus as l, type AdminSeat as m, type AdminSeatInput as n, onSessionChange as o, type ArchiveFilter as p, type CreateActiveOrganizationOptions as q, refreshSession as r, sessionCredentials as s, type LadderInput as t, updatePerson as u, type LinkOrganizationDecision as v, type LinkOrganizationDecisionInput as w, type LinkOrganizationMembership as x, type LinkOrganizationMessages as y, type LinkOrganizationParam as z };
650
+ export { createNotAMemberRefusalNotice as $, type AuthClient as A, NoActiveOrganizationError as B, type CachedActiveOrganization as C, NotAMemberError as D, type NotAMemberRefusalNotice as E, ORGANIZATION_ENTITY_TYPE as F, ORGANIZATION_RESOLUTION_TIMEOUT_MS as G, type HeldOrganizationStore as H, type OrganizationBootstrapGate as I, type OrganizationLapse as J, type OrganizationMembership as K, LINK_ORGANIZATION_QUERY_KEY as L, type OrganizationRefusal as M, NOT_A_MEMBER_RECHECK_GAP_MS as N, type OrganizationsDb as O, type OrganizationRung as P, type ParentOrganization as Q, type ReadMembershipsOptions as R, type SessionSourceLike as S, type ResolveWithLinkInput as T, type UserCredentialsPort as U, type ResolvedOrganization as V, type ResolvedWithLink as W, adminSeatReplacesUserContext as X, classifyLinkOrganizationValue as Y, classifyOrganizationRefusal as Z, createActiveOrganization as _, SignInError as a, createOrganizationBootstrapGate as a0, decideLinkOrganization as a1, isNotAMemberRefusal as a2, linkOrganizationMalformedMessage as a3, linkOrganizationNotAMemberMessage as a4, linkOrganizationOfferMessage as a5, linkOrganizationSwitchAnnouncement as a6, memoryHeldOrganization as a7, oldestMembership as a8, orderOrganizations as a9, organizationMatches as aa, readAccountOrganizationChoices as ab, readLinkOrganizationParam as ac, readMemberships as ad, readOrganizationFavourites as ae, resolveActiveOrganization as af, resolveActiveOrganizationLazily as ag, resolveAdminSeat as ah, resolveChildOrganizationId as ai, resolveOrganizationWithLink as aj, setOrganizationFavourite as ak, storageHeldOrganization as al, toAccountOrganizationChoices as am, writeLastActiveOrganization as an, writeStartupOrganization as ao, getSession as b, signInWithOAuth as c, signInWithPassword as d, signOut as e, userCredentials as f, getPerson as g, type AccountOrganizationChoices as h, invalidatePerson as i, type ActiveOrganization as j, type ActiveOrganizationSnapshot as k, type ActiveOrganizationStatus as l, type AdminSeat as m, type AdminSeatInput as n, onSessionChange as o, type ArchiveFilter as p, type CreateActiveOrganizationOptions as q, refreshSession as r, sessionCredentials as s, type LadderInput as t, updatePerson as u, type LinkOrganizationDecision as v, type LinkOrganizationDecisionInput as w, type LinkOrganizationMembership as x, type LinkOrganizationMessages as y, type LinkOrganizationParam as z };
package/dist/guest.cjs CHANGED
@@ -28,7 +28,6 @@ __export(guest_exports, {
28
28
  looksLikeVisitorId: () => looksLikeVisitorId
29
29
  });
30
30
  module.exports = __toCommonJS(guest_exports);
31
- var import_ssr = require("@supabase/ssr");
32
31
  var VISITOR_ID = /^[A-Za-z0-9]{16,200}$/;
33
32
  function looksLikeVisitorId(id) {
34
33
  return typeof id === "string" && !id.startsWith("temp_") && VISITOR_ID.test(id);
@@ -42,21 +41,11 @@ function createGuestHandover(options) {
42
41
  const loud = options.log ?? ((m) => console.error(`[session-handover] LOUD: ${m}`));
43
42
  const isGuestCookie = (name) => isGuestCookieName(options.guestCookieName, name);
44
43
  const msg = (err) => err instanceof Error ? err.message : String(err);
45
- async function readClaims(jar) {
46
- if (options.readGuestClaims) return options.readGuestClaims(jar);
47
- if (!options.supabase) return null;
48
- const guest = (0, import_ssr.createServerClient)(options.supabase.url, options.supabase.publishableKey, {
49
- cookieOptions: { name: options.guestCookieName },
50
- cookies: { getAll: () => jar.getAll(), setAll: () => void 0 }
51
- });
52
- const { data } = await guest.auth.getClaims();
53
- return data?.claims ?? null;
54
- }
55
44
  async function readGuestPossession(visitorId) {
56
45
  const jar = await options.cookies();
57
46
  if (jar.getAll().some((c) => isGuestCookie(c.name))) {
58
47
  try {
59
- const claims = await readClaims(jar);
48
+ const claims = await options.readGuestClaims(jar);
60
49
  if (claims?.sub && claims.is_anonymous === true) return { guestId: claims.sub, proof: "guest_session" };
61
50
  } catch (err) {
62
51
  loud(`the guest cookie could not be verified: ${msg(err)}`);
package/dist/guest.d.cts CHANGED
@@ -1,3 +1,25 @@
1
+ /**
2
+ * @ai-matrx/auth/guest — a visitor's guest data survives sign-up and sign-in (moved from the
3
+ * website's `lib/guest/{session-handover,guest-supabase-client,ensure-guest-session}.ts`, 2026-10-12).
4
+ *
5
+ * A signed-out visitor who saves holds a GUEST session: a real, not-yet-permanent account that lives in
6
+ * its OWN cookie (never the main auth cookie, so a guest never looks signed in). Every place a session is
7
+ * REPLACED (password login, OAuth callback, email confirm, dev-login) runs through `handOverSession`:
8
+ *
9
+ * 1. read who the browser's guest is BEFORE the replacement (the verified claims of the guest cookie,
10
+ * else the visitor id mapped through the registry — the lost-session case);
11
+ * 2. replace the session;
12
+ * 3. when the result is a permanent account other than the guest, CLAIM the guest's workspace into it
13
+ * (all or nothing) and drop the guest cookie. A failed claim keeps the cookie, so the next replacement
14
+ * (or `settlePendingGuestClaim` on a signed-in load) tries again — it screams, never silently.
15
+ *
16
+ * Sign-up with email + password keeps the SAME account (`promoteGuest`): revive, promote in place, revive
17
+ * again, stamp the registry. Never falls back to a fresh account (that would orphan the guest).
18
+ *
19
+ * Host-neutral: the host injects the cookie jar, the guest store (admin reads and the claim/revive doors)
20
+ * and the cookie names. The browser half is `createGuestClientOptions` (the guest client's own cookie name,
21
+ * injected) and `createGuestSessionEnsurer` (mint a guest once per tab / per browser).
22
+ */
1
23
  type HandoverVia = "password_login" | "oauth_callback" | "email_otp" | "dev_login" | "sign_up";
2
24
  interface GuestPossession {
3
25
  guestId: string;
@@ -93,15 +115,15 @@ interface GuestHandoverOptions {
93
115
  /** Server cookie jar for this request. */
94
116
  cookies(): Promise<GuestCookieJar>;
95
117
  store: GuestStore;
96
- /** Verified claims of the guest cookie. Default: a server client over `supabase` url + key. */
97
- readGuestClaims?(jar: GuestCookieJar): Promise<{
118
+ /**
119
+ * Verified claims of the guest cookie (the anonymous JWT in this very request is the proof of possession).
120
+ * The host builds a server client over the guest cookie name and reads `getClaimsUser`; this section builds no
121
+ * Supabase client of its own.
122
+ */
123
+ readGuestClaims(jar: GuestCookieJar): Promise<{
98
124
  sub?: string;
99
125
  is_anonymous?: boolean;
100
126
  } | null>;
101
- supabase?: {
102
- url: string;
103
- publishableKey: string;
104
- };
105
127
  /** `Secure` on the carrier cookie. */
106
128
  secureCookies?: boolean;
107
129
  log?(message: string): void;
package/dist/guest.d.ts CHANGED
@@ -1,3 +1,25 @@
1
+ /**
2
+ * @ai-matrx/auth/guest — a visitor's guest data survives sign-up and sign-in (moved from the
3
+ * website's `lib/guest/{session-handover,guest-supabase-client,ensure-guest-session}.ts`, 2026-10-12).
4
+ *
5
+ * A signed-out visitor who saves holds a GUEST session: a real, not-yet-permanent account that lives in
6
+ * its OWN cookie (never the main auth cookie, so a guest never looks signed in). Every place a session is
7
+ * REPLACED (password login, OAuth callback, email confirm, dev-login) runs through `handOverSession`:
8
+ *
9
+ * 1. read who the browser's guest is BEFORE the replacement (the verified claims of the guest cookie,
10
+ * else the visitor id mapped through the registry — the lost-session case);
11
+ * 2. replace the session;
12
+ * 3. when the result is a permanent account other than the guest, CLAIM the guest's workspace into it
13
+ * (all or nothing) and drop the guest cookie. A failed claim keeps the cookie, so the next replacement
14
+ * (or `settlePendingGuestClaim` on a signed-in load) tries again — it screams, never silently.
15
+ *
16
+ * Sign-up with email + password keeps the SAME account (`promoteGuest`): revive, promote in place, revive
17
+ * again, stamp the registry. Never falls back to a fresh account (that would orphan the guest).
18
+ *
19
+ * Host-neutral: the host injects the cookie jar, the guest store (admin reads and the claim/revive doors)
20
+ * and the cookie names. The browser half is `createGuestClientOptions` (the guest client's own cookie name,
21
+ * injected) and `createGuestSessionEnsurer` (mint a guest once per tab / per browser).
22
+ */
1
23
  type HandoverVia = "password_login" | "oauth_callback" | "email_otp" | "dev_login" | "sign_up";
2
24
  interface GuestPossession {
3
25
  guestId: string;
@@ -93,15 +115,15 @@ interface GuestHandoverOptions {
93
115
  /** Server cookie jar for this request. */
94
116
  cookies(): Promise<GuestCookieJar>;
95
117
  store: GuestStore;
96
- /** Verified claims of the guest cookie. Default: a server client over `supabase` url + key. */
97
- readGuestClaims?(jar: GuestCookieJar): Promise<{
118
+ /**
119
+ * Verified claims of the guest cookie (the anonymous JWT in this very request is the proof of possession).
120
+ * The host builds a server client over the guest cookie name and reads `getClaimsUser`; this section builds no
121
+ * Supabase client of its own.
122
+ */
123
+ readGuestClaims(jar: GuestCookieJar): Promise<{
98
124
  sub?: string;
99
125
  is_anonymous?: boolean;
100
126
  } | null>;
101
- supabase?: {
102
- url: string;
103
- publishableKey: string;
104
- };
105
127
  /** `Secure` on the carrier cookie. */
106
128
  secureCookies?: boolean;
107
129
  log?(message: string): void;
package/dist/guest.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/guest.ts
2
- import { createServerClient } from "@supabase/ssr";
3
2
  var VISITOR_ID = /^[A-Za-z0-9]{16,200}$/;
4
3
  function looksLikeVisitorId(id) {
5
4
  return typeof id === "string" && !id.startsWith("temp_") && VISITOR_ID.test(id);
@@ -13,21 +12,11 @@ function createGuestHandover(options) {
13
12
  const loud = options.log ?? ((m) => console.error(`[session-handover] LOUD: ${m}`));
14
13
  const isGuestCookie = (name) => isGuestCookieName(options.guestCookieName, name);
15
14
  const msg = (err) => err instanceof Error ? err.message : String(err);
16
- async function readClaims(jar) {
17
- if (options.readGuestClaims) return options.readGuestClaims(jar);
18
- if (!options.supabase) return null;
19
- const guest = createServerClient(options.supabase.url, options.supabase.publishableKey, {
20
- cookieOptions: { name: options.guestCookieName },
21
- cookies: { getAll: () => jar.getAll(), setAll: () => void 0 }
22
- });
23
- const { data } = await guest.auth.getClaims();
24
- return data?.claims ?? null;
25
- }
26
15
  async function readGuestPossession(visitorId) {
27
16
  const jar = await options.cookies();
28
17
  if (jar.getAll().some((c) => isGuestCookie(c.name))) {
29
18
  try {
30
- const claims = await readClaims(jar);
19
+ const claims = await options.readGuestClaims(jar);
31
20
  if (claims?.sub && claims.is_anonymous === true) return { guestId: claims.sub, proof: "guest_session" };
32
21
  } catch (err) {
33
22
  loud(`the guest cookie could not be verified: ${msg(err)}`);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HeldOrganizationStore, A as AuthClient } from './active-organization-Cxm6GDIy.cjs';
2
- export { S as SessionSourceLike, a as SignInError, U as UserCredentialsPort, g as getPerson, b as getSession, i as invalidatePerson, o as onSessionChange, r as refreshSession, s as sessionCredentials, c as signInWithOAuth, d as signInWithPassword, e as signOut, u as updatePerson, f as userCredentials } from './active-organization-Cxm6GDIy.cjs';
1
+ import { H as HeldOrganizationStore, A as AuthClient } from './active-organization-DHitxVeN.cjs';
2
+ export { S as SessionSourceLike, a as SignInError, U as UserCredentialsPort, g as getPerson, b as getSession, i as invalidatePerson, o as onSessionChange, r as refreshSession, s as sessionCredentials, c as signInWithOAuth, d as signInWithPassword, e as signOut, u as updatePerson, f as userCredentials } from './active-organization-DHitxVeN.cjs';
3
3
  import { S as SessionStorage, M as MatrxOAuthClient } from './matrx-oauth-_Ji8X5Wm.cjs';
4
4
  export { C as ChromeStorageAreaLike, a as StorageUnavailableError, b as browserStorage, e as extensionStorage, k as keyValueStorage, m as memoryStorage } from './matrx-oauth-_Ji8X5Wm.cjs';
5
5
  import { SupabaseClient, User } from '@supabase/supabase-js';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HeldOrganizationStore, A as AuthClient } from './active-organization-Cxm6GDIy.js';
2
- export { S as SessionSourceLike, a as SignInError, U as UserCredentialsPort, g as getPerson, b as getSession, i as invalidatePerson, o as onSessionChange, r as refreshSession, s as sessionCredentials, c as signInWithOAuth, d as signInWithPassword, e as signOut, u as updatePerson, f as userCredentials } from './active-organization-Cxm6GDIy.js';
1
+ import { H as HeldOrganizationStore, A as AuthClient } from './active-organization-DHitxVeN.js';
2
+ export { S as SessionSourceLike, a as SignInError, U as UserCredentialsPort, g as getPerson, b as getSession, i as invalidatePerson, o as onSessionChange, r as refreshSession, s as sessionCredentials, c as signInWithOAuth, d as signInWithPassword, e as signOut, u as updatePerson, f as userCredentials } from './active-organization-DHitxVeN.js';
3
3
  import { S as SessionStorage, M as MatrxOAuthClient } from './matrx-oauth-_Ji8X5Wm.js';
4
4
  export { C as ChromeStorageAreaLike, a as StorageUnavailableError, b as browserStorage, e as extensionStorage, k as keyValueStorage, m as memoryStorage } from './matrx-oauth-_Ji8X5Wm.js';
5
5
  import { SupabaseClient, User } from '@supabase/supabase-js';
@@ -22,6 +22,7 @@ var organizations_exports = {};
22
22
  __export(organizations_exports, {
23
23
  LINK_ORGANIZATION_QUERY_KEY: () => LINK_ORGANIZATION_QUERY_KEY,
24
24
  MEMBERSHIPS_URL: () => MEMBERSHIPS_URL,
25
+ MEMBERSHIP_ROWS_PAGE: () => MEMBERSHIP_ROWS_PAGE,
25
26
  NOT_A_MEMBER_RECHECK_GAP_MS: () => NOT_A_MEMBER_RECHECK_GAP_MS,
26
27
  NoActiveOrganizationError: () => NoActiveOrganizationError,
27
28
  NotAMemberError: () => NotAMemberError,
@@ -57,6 +58,7 @@ __export(organizations_exports, {
57
58
  readAccountOrganizationChoices: () => readAccountOrganizationChoices,
58
59
  readCallerMemberships: () => readCallerMemberships,
59
60
  readLinkOrganizationParam: () => readLinkOrganizationParam,
61
+ readMembershipRows: () => readMembershipRows,
60
62
  readMemberships: () => readMemberships,
61
63
  readOrganizationFavourites: () => readOrganizationFavourites,
62
64
  resolveActiveOrganization: () => resolveActiveOrganization,
@@ -858,3 +860,17 @@ function organizationRequiredEnvelope(error, setOn = "request") {
858
860
  function organizationRequiredResponse(error) {
859
861
  return Response.json(organizationRequiredEnvelope(error), { status: 400 });
860
862
  }
863
+
864
+ // src/organization-membership-rows.ts
865
+ var MEMBERSHIP_ROWS_PAGE = 500;
866
+ async function readMembershipRows(db, containerType, pageSize = MEMBERSHIP_ROWS_PAGE) {
867
+ const rows = [];
868
+ for (let from = 0; ; from += pageSize) {
869
+ const answer = await db.rpc("mbr_for_user", { p_container_type: containerType }).order("id", { ascending: true }).range(from, from + pageSize - 1);
870
+ if (answer.error) return { data: null, error: answer.error, status: answer.status };
871
+ const page = Array.isArray(answer.data) ? answer.data : [];
872
+ rows.push(...page);
873
+ if (page.length < pageSize) break;
874
+ }
875
+ return { data: rows, error: null };
876
+ }
@@ -1,4 +1,5 @@
1
- export { h as AccountOrganizationChoices, j as ActiveOrganization, k as ActiveOrganizationSnapshot, l as ActiveOrganizationStatus, m as AdminSeat, n as AdminSeatInput, p as ArchiveFilter, C as CachedActiveOrganization, q as CreateActiveOrganizationOptions, H as HeldOrganizationStore, L as LINK_ORGANIZATION_QUERY_KEY, t as LadderInput, v as LinkOrganizationDecision, w as LinkOrganizationDecisionInput, x as LinkOrganizationMembership, y as LinkOrganizationMessages, z as LinkOrganizationParam, N as NOT_A_MEMBER_RECHECK_GAP_MS, B as NoActiveOrganizationError, D as NotAMemberError, E as NotAMemberRefusalNotice, O as ORGANIZATION_ENTITY_TYPE, F as ORGANIZATION_RESOLUTION_TIMEOUT_MS, G as OrganizationBootstrapGate, I as OrganizationLapse, J as OrganizationMembership, K as OrganizationRefusal, M as OrganizationRung, P as OrganizationsDb, Q as ParentOrganization, R as ReadMembershipsOptions, T as ResolveWithLinkInput, V as ResolvedOrganization, W as ResolvedWithLink, X as adminSeatReplacesUserContext, Y as classifyLinkOrganizationValue, Z as classifyOrganizationRefusal, _ as createActiveOrganization, $ as createNotAMemberRefusalNotice, a0 as createOrganizationBootstrapGate, a1 as decideLinkOrganization, a2 as isNotAMemberRefusal, a3 as linkOrganizationMalformedMessage, a4 as linkOrganizationNotAMemberMessage, a5 as linkOrganizationOfferMessage, a6 as linkOrganizationSwitchAnnouncement, a7 as memoryHeldOrganization, a8 as oldestMembership, a9 as orderOrganizations, aa as organizationMatches, ab as readAccountOrganizationChoices, ac as readLinkOrganizationParam, ad as readMemberships, ae as readOrganizationFavourites, af as resolveActiveOrganization, ag as resolveActiveOrganizationLazily, ah as resolveAdminSeat, ai as resolveChildOrganizationId, aj as resolveOrganizationWithLink, ak as setOrganizationFavourite, al as storageHeldOrganization, am as toAccountOrganizationChoices, an as writeLastActiveOrganization, ao as writeStartupOrganization } from './active-organization-Cxm6GDIy.cjs';
1
+ import { O as OrganizationsDb } from './active-organization-DHitxVeN.cjs';
2
+ export { h as AccountOrganizationChoices, j as ActiveOrganization, k as ActiveOrganizationSnapshot, l as ActiveOrganizationStatus, m as AdminSeat, n as AdminSeatInput, p as ArchiveFilter, C as CachedActiveOrganization, q as CreateActiveOrganizationOptions, H as HeldOrganizationStore, L as LINK_ORGANIZATION_QUERY_KEY, t as LadderInput, v as LinkOrganizationDecision, w as LinkOrganizationDecisionInput, x as LinkOrganizationMembership, y as LinkOrganizationMessages, z as LinkOrganizationParam, N as NOT_A_MEMBER_RECHECK_GAP_MS, B as NoActiveOrganizationError, D as NotAMemberError, E as NotAMemberRefusalNotice, F as ORGANIZATION_ENTITY_TYPE, G as ORGANIZATION_RESOLUTION_TIMEOUT_MS, I as OrganizationBootstrapGate, J as OrganizationLapse, K as OrganizationMembership, M as OrganizationRefusal, P as OrganizationRung, Q as ParentOrganization, R as ReadMembershipsOptions, T as ResolveWithLinkInput, V as ResolvedOrganization, W as ResolvedWithLink, X as adminSeatReplacesUserContext, Y as classifyLinkOrganizationValue, Z as classifyOrganizationRefusal, _ as createActiveOrganization, $ as createNotAMemberRefusalNotice, a0 as createOrganizationBootstrapGate, a1 as decideLinkOrganization, a2 as isNotAMemberRefusal, a3 as linkOrganizationMalformedMessage, a4 as linkOrganizationNotAMemberMessage, a5 as linkOrganizationOfferMessage, a6 as linkOrganizationSwitchAnnouncement, a7 as memoryHeldOrganization, a8 as oldestMembership, a9 as orderOrganizations, aa as organizationMatches, ab as readAccountOrganizationChoices, ac as readLinkOrganizationParam, ad as readMemberships, ae as readOrganizationFavourites, af as resolveActiveOrganization, ag as resolveActiveOrganizationLazily, ah as resolveAdminSeat, ai as resolveChildOrganizationId, aj as resolveOrganizationWithLink, ak as setOrganizationFavourite, al as storageHeldOrganization, am as toAccountOrganizationChoices, an as writeLastActiveOrganization, ao as writeStartupOrganization } from './active-organization-DHitxVeN.cjs';
2
3
  import '@supabase/supabase-js';
3
4
 
4
5
  /**
@@ -107,4 +108,26 @@ declare function organizationRequiredEnvelope(error: OrganizationRequiredServerE
107
108
  /** The standard `Response` (status 400) a route answers the refusal with — no framework needed. */
108
109
  declare function organizationRequiredResponse(error: OrganizationRequiredServerError): Response;
109
110
 
110
- export { MEMBERSHIPS_URL, type MembershipReadClient, ORGANIZATION_CONTEXT_REQUIRED_CODE, ORGANIZATION_REQUIRED_CODE, ORGANIZATION_REQUIRED_WIRE_CODE, type OrganizationHoldDetails, type OrganizationHoldSetOn, type OrganizationMembershipSummary, type OrganizationRequiredEnvelope, OrganizationRequiredServerError, type OrganizationRequiredWireMembership, extractOrganizationHoldMemberships, isOrganizationRequiredEnvelope, isOrganizationRequiredError, isOrganizationRequiredServerError, organizationRequired, organizationRequiredEnvelope, organizationRequiredResponse, readCallerMemberships };
111
+ /**
112
+ * The person's raw membership rows for ONE container type, PAGED — the canonical `mbr_for_user`
113
+ * door (moved from the website's membershipsService). PostgREST caps one answer at its max-rows
114
+ * (1000): a person in 1,043 organizations lost the last 43, so the read pages in stable id order
115
+ * until a short page.
116
+ *
117
+ * It does NOT throw: it returns the first failing page's `{ error, status }` so a host can wrap
118
+ * the whole read in its own session retry (a 401 on a recovering session) and map the error its
119
+ * own way.
120
+ */
121
+
122
+ declare const MEMBERSHIP_ROWS_PAGE = 500;
123
+ interface MembershipRowsAnswer<Row> {
124
+ readonly data: Row[] | null;
125
+ readonly error: {
126
+ message: string;
127
+ code?: string;
128
+ } | null;
129
+ readonly status?: number | undefined;
130
+ }
131
+ declare function readMembershipRows<Row = Record<string, unknown>>(db: OrganizationsDb, containerType: string, pageSize?: number): Promise<MembershipRowsAnswer<Row>>;
132
+
133
+ export { MEMBERSHIPS_URL, MEMBERSHIP_ROWS_PAGE, type MembershipReadClient, type MembershipRowsAnswer, ORGANIZATION_CONTEXT_REQUIRED_CODE, ORGANIZATION_REQUIRED_CODE, ORGANIZATION_REQUIRED_WIRE_CODE, type OrganizationHoldDetails, type OrganizationHoldSetOn, type OrganizationMembershipSummary, type OrganizationRequiredEnvelope, OrganizationRequiredServerError, type OrganizationRequiredWireMembership, OrganizationsDb, extractOrganizationHoldMemberships, isOrganizationRequiredEnvelope, isOrganizationRequiredError, isOrganizationRequiredServerError, organizationRequired, organizationRequiredEnvelope, organizationRequiredResponse, readCallerMemberships, readMembershipRows };
@@ -1,4 +1,5 @@
1
- export { h as AccountOrganizationChoices, j as ActiveOrganization, k as ActiveOrganizationSnapshot, l as ActiveOrganizationStatus, m as AdminSeat, n as AdminSeatInput, p as ArchiveFilter, C as CachedActiveOrganization, q as CreateActiveOrganizationOptions, H as HeldOrganizationStore, L as LINK_ORGANIZATION_QUERY_KEY, t as LadderInput, v as LinkOrganizationDecision, w as LinkOrganizationDecisionInput, x as LinkOrganizationMembership, y as LinkOrganizationMessages, z as LinkOrganizationParam, N as NOT_A_MEMBER_RECHECK_GAP_MS, B as NoActiveOrganizationError, D as NotAMemberError, E as NotAMemberRefusalNotice, O as ORGANIZATION_ENTITY_TYPE, F as ORGANIZATION_RESOLUTION_TIMEOUT_MS, G as OrganizationBootstrapGate, I as OrganizationLapse, J as OrganizationMembership, K as OrganizationRefusal, M as OrganizationRung, P as OrganizationsDb, Q as ParentOrganization, R as ReadMembershipsOptions, T as ResolveWithLinkInput, V as ResolvedOrganization, W as ResolvedWithLink, X as adminSeatReplacesUserContext, Y as classifyLinkOrganizationValue, Z as classifyOrganizationRefusal, _ as createActiveOrganization, $ as createNotAMemberRefusalNotice, a0 as createOrganizationBootstrapGate, a1 as decideLinkOrganization, a2 as isNotAMemberRefusal, a3 as linkOrganizationMalformedMessage, a4 as linkOrganizationNotAMemberMessage, a5 as linkOrganizationOfferMessage, a6 as linkOrganizationSwitchAnnouncement, a7 as memoryHeldOrganization, a8 as oldestMembership, a9 as orderOrganizations, aa as organizationMatches, ab as readAccountOrganizationChoices, ac as readLinkOrganizationParam, ad as readMemberships, ae as readOrganizationFavourites, af as resolveActiveOrganization, ag as resolveActiveOrganizationLazily, ah as resolveAdminSeat, ai as resolveChildOrganizationId, aj as resolveOrganizationWithLink, ak as setOrganizationFavourite, al as storageHeldOrganization, am as toAccountOrganizationChoices, an as writeLastActiveOrganization, ao as writeStartupOrganization } from './active-organization-Cxm6GDIy.js';
1
+ import { O as OrganizationsDb } from './active-organization-DHitxVeN.js';
2
+ export { h as AccountOrganizationChoices, j as ActiveOrganization, k as ActiveOrganizationSnapshot, l as ActiveOrganizationStatus, m as AdminSeat, n as AdminSeatInput, p as ArchiveFilter, C as CachedActiveOrganization, q as CreateActiveOrganizationOptions, H as HeldOrganizationStore, L as LINK_ORGANIZATION_QUERY_KEY, t as LadderInput, v as LinkOrganizationDecision, w as LinkOrganizationDecisionInput, x as LinkOrganizationMembership, y as LinkOrganizationMessages, z as LinkOrganizationParam, N as NOT_A_MEMBER_RECHECK_GAP_MS, B as NoActiveOrganizationError, D as NotAMemberError, E as NotAMemberRefusalNotice, F as ORGANIZATION_ENTITY_TYPE, G as ORGANIZATION_RESOLUTION_TIMEOUT_MS, I as OrganizationBootstrapGate, J as OrganizationLapse, K as OrganizationMembership, M as OrganizationRefusal, P as OrganizationRung, Q as ParentOrganization, R as ReadMembershipsOptions, T as ResolveWithLinkInput, V as ResolvedOrganization, W as ResolvedWithLink, X as adminSeatReplacesUserContext, Y as classifyLinkOrganizationValue, Z as classifyOrganizationRefusal, _ as createActiveOrganization, $ as createNotAMemberRefusalNotice, a0 as createOrganizationBootstrapGate, a1 as decideLinkOrganization, a2 as isNotAMemberRefusal, a3 as linkOrganizationMalformedMessage, a4 as linkOrganizationNotAMemberMessage, a5 as linkOrganizationOfferMessage, a6 as linkOrganizationSwitchAnnouncement, a7 as memoryHeldOrganization, a8 as oldestMembership, a9 as orderOrganizations, aa as organizationMatches, ab as readAccountOrganizationChoices, ac as readLinkOrganizationParam, ad as readMemberships, ae as readOrganizationFavourites, af as resolveActiveOrganization, ag as resolveActiveOrganizationLazily, ah as resolveAdminSeat, ai as resolveChildOrganizationId, aj as resolveOrganizationWithLink, ak as setOrganizationFavourite, al as storageHeldOrganization, am as toAccountOrganizationChoices, an as writeLastActiveOrganization, ao as writeStartupOrganization } from './active-organization-DHitxVeN.js';
2
3
  import '@supabase/supabase-js';
3
4
 
4
5
  /**
@@ -107,4 +108,26 @@ declare function organizationRequiredEnvelope(error: OrganizationRequiredServerE
107
108
  /** The standard `Response` (status 400) a route answers the refusal with — no framework needed. */
108
109
  declare function organizationRequiredResponse(error: OrganizationRequiredServerError): Response;
109
110
 
110
- export { MEMBERSHIPS_URL, type MembershipReadClient, ORGANIZATION_CONTEXT_REQUIRED_CODE, ORGANIZATION_REQUIRED_CODE, ORGANIZATION_REQUIRED_WIRE_CODE, type OrganizationHoldDetails, type OrganizationHoldSetOn, type OrganizationMembershipSummary, type OrganizationRequiredEnvelope, OrganizationRequiredServerError, type OrganizationRequiredWireMembership, extractOrganizationHoldMemberships, isOrganizationRequiredEnvelope, isOrganizationRequiredError, isOrganizationRequiredServerError, organizationRequired, organizationRequiredEnvelope, organizationRequiredResponse, readCallerMemberships };
111
+ /**
112
+ * The person's raw membership rows for ONE container type, PAGED — the canonical `mbr_for_user`
113
+ * door (moved from the website's membershipsService). PostgREST caps one answer at its max-rows
114
+ * (1000): a person in 1,043 organizations lost the last 43, so the read pages in stable id order
115
+ * until a short page.
116
+ *
117
+ * It does NOT throw: it returns the first failing page's `{ error, status }` so a host can wrap
118
+ * the whole read in its own session retry (a 401 on a recovering session) and map the error its
119
+ * own way.
120
+ */
121
+
122
+ declare const MEMBERSHIP_ROWS_PAGE = 500;
123
+ interface MembershipRowsAnswer<Row> {
124
+ readonly data: Row[] | null;
125
+ readonly error: {
126
+ message: string;
127
+ code?: string;
128
+ } | null;
129
+ readonly status?: number | undefined;
130
+ }
131
+ declare function readMembershipRows<Row = Record<string, unknown>>(db: OrganizationsDb, containerType: string, pageSize?: number): Promise<MembershipRowsAnswer<Row>>;
132
+
133
+ export { MEMBERSHIPS_URL, MEMBERSHIP_ROWS_PAGE, type MembershipReadClient, type MembershipRowsAnswer, ORGANIZATION_CONTEXT_REQUIRED_CODE, ORGANIZATION_REQUIRED_CODE, ORGANIZATION_REQUIRED_WIRE_CODE, type OrganizationHoldDetails, type OrganizationHoldSetOn, type OrganizationMembershipSummary, type OrganizationRequiredEnvelope, OrganizationRequiredServerError, type OrganizationRequiredWireMembership, OrganizationsDb, extractOrganizationHoldMemberships, isOrganizationRequiredEnvelope, isOrganizationRequiredError, isOrganizationRequiredServerError, organizationRequired, organizationRequiredEnvelope, organizationRequiredResponse, readCallerMemberships, readMembershipRows };
@@ -784,9 +784,24 @@ function organizationRequiredEnvelope(error, setOn = "request") {
784
784
  function organizationRequiredResponse(error) {
785
785
  return Response.json(organizationRequiredEnvelope(error), { status: 400 });
786
786
  }
787
+
788
+ // src/organization-membership-rows.ts
789
+ var MEMBERSHIP_ROWS_PAGE = 500;
790
+ async function readMembershipRows(db, containerType, pageSize = MEMBERSHIP_ROWS_PAGE) {
791
+ const rows = [];
792
+ for (let from = 0; ; from += pageSize) {
793
+ const answer = await db.rpc("mbr_for_user", { p_container_type: containerType }).order("id", { ascending: true }).range(from, from + pageSize - 1);
794
+ if (answer.error) return { data: null, error: answer.error, status: answer.status };
795
+ const page = Array.isArray(answer.data) ? answer.data : [];
796
+ rows.push(...page);
797
+ if (page.length < pageSize) break;
798
+ }
799
+ return { data: rows, error: null };
800
+ }
787
801
  export {
788
802
  LINK_ORGANIZATION_QUERY_KEY,
789
803
  MEMBERSHIPS_URL,
804
+ MEMBERSHIP_ROWS_PAGE,
790
805
  NOT_A_MEMBER_RECHECK_GAP_MS,
791
806
  NoActiveOrganizationError,
792
807
  NotAMemberError,
@@ -822,6 +837,7 @@ export {
822
837
  readAccountOrganizationChoices,
823
838
  readCallerMemberships,
824
839
  readLinkOrganizationParam,
840
+ readMembershipRows,
825
841
  readMemberships,
826
842
  readOrganizationFavourites,
827
843
  resolveActiveOrganization,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/auth",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "AI Matrx sign-in, session and organizations for every app: sign in/out, session storage and refresh per platform (browser, Next.js, extension, desktop, Node), the current person, their organizations and favourites, the one active organization (held requests, never a list filter), and the credentials @ai-matrx/data and @ai-matrx/api read.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -211,5 +211,5 @@
211
211
  "test": "vitest run",
212
212
  "verify:tarball": "node ./scripts/verify-tarball.mjs"
213
213
  },
214
- "gitHead": "f9020cf33c7ac2b8b854856131eb0b1268eb220d"
214
+ "gitHead": "9517977774bcd6e3ed1018bd331ca397a8e7ddfd"
215
215
  }