autosolutions-os 0.2.5 → 0.3.1

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,170 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 - 2026-10-16
4
+
5
+ "Sign in with AutoSolutions" for the apps that keep their own Supabase
6
+ project (Key Accounts, Asset Portal, Candidate Hub, Ops Hub), and Label
7
+ Maker's fixed menu link on its autosolutions.app address. Nothing changes for
8
+ an app on the core: no entry it imports changed behaviour.
9
+
10
+ ### `autosolutions-os/federation` (new entry)
11
+
12
+ For an app on its own project that adds the core as the custom OpenID Connect
13
+ provider `custom:autosolutions` (docs/CONTRACT.md, "Federated: own project,
14
+ one sign-in"; docs/RUNBOOK.md, "Add an app to Sign in with AutoSolutions").
15
+ It takes the app's own supabase-js client and imports neither supabase-js nor
16
+ React.
17
+
18
+ - `signInWithAutoSolutions(client, { redirectTo })` starts the flow through
19
+ the app's own project. With `automatic: true` the sign-in page can call it by
20
+ itself: it starts only on an autosolutions.app address, only when the core's
21
+ shared cookie shows a live session, at most once a minute, and never after a
22
+ sign-out here, a "no access" answer (`holdAutomaticSignIn()`) or an attempt
23
+ that did not come back, until the person clicks. `skipBrowserRedirect` is
24
+ passed through for a popup flow (Ops Hub).
25
+ - `followCoreSession(client, { onSignedOut })`, installed once at the app's
26
+ root on every address, marks the session that came back through
27
+ AutoSolutions (`as-sso`, the core user id, in the app's localStorage) and
28
+ keeps only that session in step with the core. On an autosolutions.app
29
+ address it reads the core's cookies on load, on focus, when the tab comes
30
+ back into view and once a minute: the sign-out note with no live core
31
+ session signs out here (local scope); another person at the core signs out
32
+ here; the same person, or no cookie and no note, does nothing. Google,
33
+ password, email-link, partner and candidate sessions are never touched.
34
+ - `signOutWithAutoSolutions(client, { returnTo })`: for an AutoSolutions
35
+ session, sign out here (local scope), hold the automatic start, then go
36
+ through the Hub's `/sign-out` back to `returnTo`, so the Hub and every app
37
+ follow. For any other session it does nothing and returns false.
38
+ - `signOutEverywhereUrl(returnTo)`: that Hub address,
39
+ `https://autosolutions.app/sign-out?return_to=...`.
40
+ - `coreIdentity(user)`: the person's `custom:autosolutions` identity in the
41
+ app's project (the core user id, the email the core vouched for and whether
42
+ it said it was verified), or null.
43
+ - `cameThroughAutoSolutions(user?)`, `holdAutomaticSignIn()`,
44
+ `AUTOSOLUTIONS_PROVIDER`, `SIGN_OUT_PATH`.
45
+
46
+ The cookie rules are session.ts's own: `followCoreSession` reads the shared
47
+ copy with `sharedSessionCookieName` and `joinChunks`, and the note with the
48
+ same parser and the same "a copy the sign-out ended" rule
49
+ (`parseSignedOutNote`, `signedOutCopy`, `signedOutCookieName`, now exported
50
+ from session.ts for it; nothing in session.ts behaves differently). The
51
+ functions type-check against supabase-js 2.106.2 (Ops Hub), 2.112.3 and
52
+ 2.118.0 with no cast.
53
+
54
+ ### Label Maker's fixed address
55
+
56
+ `OS_TOOL_LINKS["carton-label-generator"]` (and so `staticLinks()`) is
57
+ `https://label-maker.autosolutions.app`, where Label Maker is served and can
58
+ read the shared session, instead of `https://label-maker-app.lovable.app`. Only
59
+ frames off the core use the fixed address; frames on the core follow the
60
+ catalogue's `launch_url`, which is checked separately.
61
+
62
+ ## 0.3.0 - 2026-10-16
63
+
64
+ The OS menu becomes Cliff's menu map, every app shows the Hub panel, and
65
+ every row goes somewhere: to its app, or to its page in the Hub. Needs
66
+ `autosolutions-design-system` 6.5.0 (the peer range is now `>=6.5.0 <7`), whose
67
+ frame draws Cliff's newest design: take both in one commit.
68
+
69
+ ### The menu is Cliff's map
70
+
71
+ - `OS_MENU` is the menu map of Cliff's design (its functions kit,
72
+ `dashboards/nav.js` and `data.js`, 16 October): his ids, labels, groups,
73
+ order and statuses, and each tool's views as `tabs` (every view's id and
74
+ label), which the tool's page in the Hub shows as tabs. Finance, Commercial
75
+ and Operations open with an Overview row (`finance-home`,
76
+ `commercial-home`, `operations-home`, marked `overview: true`, in a group
77
+ with no title, `""`). Commercial > Planning keeps the two rows the design
78
+ keeps from before its merge, Customer scorecard and Clearance list. Our four
79
+ Live apps stay, each at the end of its group: Shelf simulator, Key
80
+ accounts, PM Copilot, Candidate hub. 56 tools and three Overviews, 21 Live
81
+ as before. Every glyph is in the design system's `NAV_ICONS` (Board pack
82
+ has its own, `fin-board-pack`, new in 6.5.0).
83
+ - What moved. Finance: P&L vs LY (was P&L vs budget), Balance sheet v LY,
84
+ Inventory valuation (moved here from Operations, still `inventory-value`),
85
+ Working capital and Sales ratios (new). Commercial: Sales (was Live sales by
86
+ channel), Customers (was New customer acquisition and At risk / lapsed
87
+ customers), Customer forecast collaboration and Clearance list (new).
88
+ Operations: Order OTIF (was Customer OTIF). Marketing is as it was.
89
+ Statuses are the map's: most Finance tools, for example, are In progress
90
+ now.
91
+ - `OS_TOOL_ALIASES` and `osToolId(id)`: the five ids that changed
92
+ (`pl-vs-budget` is `pl-vs-ly`, `live-sales-by-channel` is `sales`,
93
+ `customer-otif` is `order-otif`, `new-customer-acquisition` and
94
+ `at-risk-customers` are `customers`). An app that still passes one, as a
95
+ tool of its own, a link or a lock, lands on the new row; an entry under the
96
+ new id wins over one under an old id. The frame reports the new id.
97
+ - `OS_TOOL_LINKS` keeps every Live tool's app link exactly, under the new
98
+ ids (`sales` for Ops Hub's sales dashboard).
99
+
100
+ ### Every app shows the Hub panel
101
+
102
+ - `OS_HUB_MENU` is the design's Hub panel: "Smart Comms Hub" (Overview,
103
+ Inbox, Calendar, Tasks, Slack, Monday, Accounts, Configuration) and
104
+ "Assistants" (Unmarked Agent, Brand Voice Capture, Signature Generator),
105
+ each row with its route in the Hub (`/comms/overview` and the other comms
106
+ views, `/comms/settings` for Configuration, `/comms/agent`,
107
+ `/launcher?section=brandvoice`, `/launcher?section=signature`).
108
+ - `osFrame` draws it whenever `hubItems` is not given. In another app the
109
+ rail's Hub now opens it, as any function opens its menu (it went straight
110
+ to the Hub before), and each row is a link into the Hub with the company as
111
+ `?tenant=`. In the Hub its rows are the Hub's own routes. `hubItems` still
112
+ wins (the Hub passes its own rows, to lock what it gates); `hubItems: []`
113
+ draws no Hub menu, and the rail's Hub goes to the Hub as before.
114
+
115
+ ### Every row goes somewhere
116
+
117
+ - A tool with no app of its own, and every Overview, opens its page in the
118
+ Hub, which the Hub builds from the design's sample dashboards:
119
+ `/os/<function>` for an Overview, `/os/<function>/<tool>` for a tool, and
120
+ `?tab=<view>` for one of its views (`osHubPath(fn, tool?, tab?)`). In another
121
+ app such a row is a link through `HUB_URL` (`hubUrl`), with `?tenant=`; in
122
+ the Hub it is the Hub's own route, which places the location on its row,
123
+ views included (a row that opens an app keeps the place of its page in the
124
+ Hub too). A frame off the core reaches them the same way.
125
+ - A row is locked only when its tool has an app the person does not hold
126
+ (`HINTS.locked`), and while os_context() is read (`HINTS.checking`, now for
127
+ every tool with an app, whatever its status). Nothing is locked for its
128
+ status any more. A tool whose app is held but not deployed, and an app's
129
+ tool that a frame off the core cannot reach (no fixed address), open their
130
+ page in the Hub, where the core decides. `HINTS.notBuilt` and
131
+ `HINTS.notLinked` stay exported; the frame no longer draws them.
132
+ - `catalogueLinks(apps)`: held with an address, a link, whatever the map's
133
+ status; held without one, neither (its page in the Hub); not held, locked.
134
+
135
+ ### Kept
136
+
137
+ The routing rules are unchanged: `locate`, `targetFor`, the reselect rules,
138
+ a page filed under a tab, the Hub's own rows, Admin and Settings, a refused
139
+ navigation, the company switch. `targetFor` still honours `back: true` for a
140
+ caller that passes it; design system 6.5.0 no longer reports it, as its tool
141
+ panel has no Back to hub. `OsWorkspaceFrame` takes the same props.
142
+
143
+ ### Upgrading
144
+
145
+ - Take 0.3.0 with design system 6.5.0, in one commit.
146
+ - Code that reads the menu's ids: `sales`, `pl-vs-ly`, `order-otif`,
147
+ `customers`, and Inventory valuation (`inventory-value`) is in Finance.
148
+ Ops Hub's own tests read `row("operations", "inventory-value")` and
149
+ `row("commercial", "live-sales-by-channel")` (src/shared/lib/ops-nav.test.ts,
150
+ and `/sales-dashboard` in OpsFrame.test.tsx): they are
151
+ `row("finance", "inventory-value")` and `row("commercial", "sales")`.
152
+ - Tests that count the menu (53 tools) or its groups, or expect a row to be
153
+ locked for its status ("Not built yet", "In progress", "To build", "Live,
154
+ not linked from the Hub yet"): those rows link to their page in the Hub
155
+ now. PM Copilot's `src/test/ops-frame-nav.test.ts` reads the Operations >
156
+ Planning group, which still ends with PM Copilot and Candidate hub.
157
+ - Tests that expect the rail's Hub to go to the Hub in an app other than the
158
+ Hub: it opens the Hub panel now (pass `hubItems: []` to keep the old
159
+ behaviour).
160
+ - The Hub: its own rows (`hubItems`) still win, so nothing changes until it
161
+ moves. To draw the design's panel it stops passing them, or builds them
162
+ from `OS_HUB_MENU` with its locks (Brand Voice Capture's id there is
163
+ `voice`), and it serves the `/os/...` pages. Its test "reads a held app
164
+ with no address yet as not linked" (src/launcher/nav.test.ts, Carton label
165
+ generator) now finds the row's page in the Hub, its own route
166
+ `/os/operations/carton-label-generator`, instead of `HINTS.notLinked`.
167
+
3
168
  ## 0.2.5 - 2026-10-15
4
169
 
5
170
  Single sign-on fix. Signed in at the Hub, people opening an app were asked to
package/README.md CHANGED
@@ -51,26 +51,63 @@ publishSessionChanges(supabase, ref);
51
51
  followSharedSession(supabase, ref);
52
52
  ```
53
53
 
54
+ ## Sign in with AutoSolutions (an app on its own project)
55
+
56
+ An app that keeps its own Supabase project, its own people and its own roles
57
+ (Key Accounts, Asset Portal, Candidate Hub, Ops Hub) adds the core as the
58
+ custom OpenID Connect provider `custom:autosolutions` and uses
59
+ `autosolutions-os/federation` with its own client (docs/CONTRACT.md,
60
+ "Federated: own project, one sign-in"; docs/RUNBOOK.md has the setup, click by
61
+ click):
62
+
63
+ ```ts
64
+ import {
65
+ followCoreSession, holdAutomaticSignIn, signInWithAutoSolutions, signOutWithAutoSolutions,
66
+ } from "autosolutions-os/federation";
67
+
68
+ // Once, at the root, on every address.
69
+ followCoreSession(supabase, { onSignedOut: () => navigate({ to: "/auth" }) });
70
+
71
+ // The sign-in page: the button, and the start with no click once the app knows there is no session.
72
+ const redirectTo = `${window.location.origin}/auth`;
73
+ await signInWithAutoSolutions(supabase, { redirectTo }); // on a click
74
+ await signInWithAutoSolutions(supabase, { redirectTo, automatic: true }); // by itself; refuses when it should
75
+
76
+ // The app's own rules said no: show "No access to <app>", and do not start by itself again.
77
+ holdAutomaticSignIn();
78
+
79
+ // Sign out: through the Hub for an AutoSolutions session, the app's own way otherwise.
80
+ if (!(await signOutWithAutoSolutions(supabase, { returnTo: "/auth", user }))) await supabase.auth.signOut();
81
+ ```
82
+
83
+ The person keeps the same account in the app: the app's project links the
84
+ AutoSolutions identity to the user with the same verified email.
85
+ `coreIdentity(user)` reads it (the core user id and the email). On an
86
+ autosolutions.app address an AutoSolutions session follows the core: signed
87
+ out at the Hub, or someone else signed in there, and it signs out here at the
88
+ next load, focus, tab switch or minute. Other sessions (Google, passwords,
89
+ email links, partners, candidates) are never touched. On a lovable.app address
90
+ the core's cookie cannot be read, so the session lasts until it expires or the
91
+ person signs out in the app.
92
+
54
93
  ## The workspace frame
55
94
 
56
95
  `OsWorkspaceFrame` is the frame every app on the core renders around its pages:
57
- the top bar with the company's mark and switcher, the rail, the OS menu (the 53
58
- tools of the menu map: the handoff's 49 plus Shelf simulator, Key accounts, PM
59
- Copilot and Candidate hub), the footer with Admin for people who manage something, and the
60
- browser-tab icon. It needs `autosolutions-design-system` 6.4.0 or later
61
- (an optional peer: only this entry point uses it). Take this package's 0.2.4
62
- and the design system's 6.4.0 together, in one commit: 0.2.4 sends a company
63
- switch the app's new company does not hold to the Hub, reads os_context()
64
- for the person signed in and asks again after a failure, and makes this
65
- app's own rows and tabs links; 6.4.0 brings the final design and the frame's
66
- own fixes (wide pages scroll sideways again, a phone's menu closes on every
67
- pick, no search box without a search, and the rest in its CHANGELOG). An
68
- app that renders `OsWorkspaceFrame` changes nothing else, but for the
69
- options below (`hrefFor`, a navigation promise, `auth`). Code that calls `osFrame().targetFor`
70
- itself in the Hub (a test of the Hub's rows, say) and means Back to hub passes
71
- `back: true`: since 0.2.3 the hub function with no row and no flag is the
72
- rail's Hub (see below). The Hub's adoption of 0.2.3 updates its one test that
73
- does this (the CHANGELOG has the change).
96
+ the top bar with the company's mark and switcher, the rail, the OS menu (Cliff's
97
+ menu map, 0.3.0: 56 tools and an Overview first in Finance, Commercial and
98
+ Operations, our Shelf simulator, Key accounts, PM Copilot and Candidate hub
99
+ among them), the Hub panel, the footer with Admin for people who manage
100
+ something, and the browser-tab icon. It needs `autosolutions-design-system`
101
+ 6.5.0 or later (an optional peer: only this entry point uses it). Take this
102
+ package's 0.3.0 and the design system's 6.5.0 together, in one commit: 0.3.0
103
+ brings the design's menu map, its Hub panel in every app and a page in the
104
+ Hub for every row with no app of its own; 6.5.0 brings Cliff's newest design
105
+ (the new logo, and a tool open in its own panel, its icon and name over its
106
+ tabs, with no Back to hub). An app that renders `OsWorkspaceFrame` changes
107
+ nothing in its code, but for the ids that changed (below) if it reads them.
108
+ Code that calls `osFrame().targetFor` itself in the Hub and means Back to hub
109
+ passes `back: true`, which the frame no longer reports (there is no Back to
110
+ hub since design system 6.5.0).
74
111
 
75
112
  ```tsx
76
113
  import { OsWorkspaceFrame } from "autosolutions-os/frame";
@@ -120,33 +157,38 @@ why).
120
157
  - `tools` are this app's own rows, by menu-map id, with their routes. They are
121
158
  live whatever the map says. A row the map does not have takes `fn`, `section`,
122
159
  `label` and `icon`. A row can carry a `badge` (a count), and so can a tab.
160
+ An id the map had before 0.3.0 still works (`OS_TOOL_ALIASES`: `pl-vs-budget`
161
+ is `pl-vs-ly`, `live-sales-by-channel` is `sales`, `customer-otif` is
162
+ `order-otif`, `new-customer-acquisition` and `at-risk-customers` are
163
+ `customers`), and the frame reports the row by its new id.
123
164
  - `tabs` is a flat list, or titled groups (`{ title, items }[]`) drawn with the
124
- menu's own section headings. A tab with a `path` navigates; one without is
125
- page state, read from the frame's state (`children` as a function).
126
- - Every other tool opens its app in the same tab, and only if the person holds
127
- that app: the menu reaches every app the app switcher offers (all but the
128
- Hub itself, which is the rail's Hub). `OS_TOOL_LINKS` names each tool's app,
129
- and `os_context()` decides:
165
+ menu's own section headings. Opened, the panel shows the tool's icon and
166
+ name, then these (design system 6.5.0). A tab with a `path` navigates; one
167
+ without is page state, read from the frame's state (`children` as a
168
+ function).
169
+ - Every other row goes somewhere, in the same tab. A tool with an app of its
170
+ own opens that app only if the person holds it: the menu reaches every app
171
+ the app switcher offers (all but the Hub itself, which is the rail's Hub).
172
+ `OS_TOOL_LINKS` names each tool's app, and `os_context()` decides, whatever
173
+ status the map gives the tool:
130
174
  - held, with an address: the tool goes there (plus its `path`) with
131
- `?tenant=`, whatever status the map gives it (Influencer Manager is In
132
- progress in the map, Marketing calendar and Paid media have none, yet a
133
- company that holds their apps reaches them);
134
- - held, not deployed yet: a Live tool reads "Live, not linked from the Hub
135
- yet", any other keeps its status;
136
- - not held: a Live tool is locked ("Ask your company admin to switch this on
137
- for you"); any other keeps its status (Not built yet, In progress, To
138
- build).
139
- A tool's fixed `url` is never used here; it is for frames off the core
140
- (`staticLinks()`). Tools with no app follow the map: Pricing researcher and
141
- Brand voice copywriter read "Live, not linked from the Hub yet", anything
142
- not Live shows its status.
175
+ `?tenant=`;
176
+ - held, not deployed yet: its page in the Hub (below);
177
+ - not held: locked ("Ask your company admin to switch this on for you"),
178
+ the one way a row is locked.
179
+ Every tool with no app of its own, and every Overview, opens its page in the
180
+ Hub (0.3.0): `/os/<function>` for an Overview, `/os/<function>/<tool>` for a
181
+ tool, with `?tab=<view>` for one of its views (`osHubPath`), which the Hub
182
+ builds from the design's sample dashboards. Here it is a link through
183
+ `HUB_URL` with `?tenant=`; in the Hub, its own route. A tool's fixed `url` is
184
+ never used here; it is for frames off the core (`staticLinks()`).
143
185
  - os_context() is read once per page and person: another person signing in
144
186
  on the same browser, without a reload, reads their own (pass `auth`, the
145
187
  app's `supabase.auth`, to have sign-ins followed live in this tab too). A
146
188
  read that fails is asked again (1, 3, 10, 30 and 60 seconds on, when the
147
189
  window comes back, and when the location changes), and until it answers
148
- other apps' tools read "Checking your access…" and the plate's place is
149
- kept, drawn as nothing.
190
+ every tool with an app reads "Checking your access…" and the plate's place
191
+ is kept, drawn as nothing.
150
192
  - The company plate is `markFor(tenant, "plain")`. A company with no artwork
151
193
  there (one outside the brand bucket's eight, with no stored logo), or whose
152
194
  artwork fails to load, has its name on the plate instead (its whole name
@@ -169,7 +211,7 @@ why).
169
211
  `refreshOsContext(os)` reads the core again (asking again if that fails).
170
212
  The function reports its own failures.
171
213
  - `actions` go in the top bar before the plate (What's new, a notification
172
- bell). `panelFooter` renders in the panel under the open tool's tabs, in the
214
+ bell). `panelFooter` renders in the tool's panel under its tabs, in the
173
215
  panel's padding, scrolling with them (Create Studio's sessions).
174
216
  - Settings goes to `settingsPath` when the app has a settings page, and to the
175
217
  Hub's settings when it has none.
@@ -185,26 +227,33 @@ why).
185
227
  applies. `data-*` and `aria-*` props land on the frame's root.
186
228
  - Admin appears when `my_admin_scope()` says the person manages something; pass
187
229
  `admin` to decide it yourself.
188
- - The Hub passes `hubItems`, its own rows. In any other app the rail's Hub, Back
189
- to hub and Admin go to the Hub. In the Hub, the rail's Hub is its menu's
190
- control: pressed after browsing another function's menu, it reopens the Hub
191
- menu on the page the person is on (a thread, a tool, the Overview), with no
192
- navigation. From another place (Admin, an app's Settings) it lands on the
193
- Hub's landing, as Back to hub does from anywhere. `targetFor` tells the two
194
- apart by the design system's `back` flag (6.3.4): the hub function with no
195
- row is the rail's Hub, and with `back: true` it is Back to hub.
230
+ - Every app shows the Hub panel (0.3.0, `OS_HUB_MENU`, the design's): Smart
231
+ Comms Hub (Overview, Inbox, Calendar, Tasks, Slack, Monday, Accounts,
232
+ Configuration) and Assistants (Unmarked Agent, Brand Voice Capture,
233
+ Signature Generator). The rail's Hub opens it, as any function does, and
234
+ each row is a link into the Hub with `?tenant=`; Admin goes to the Hub. Pass
235
+ `hubItems` to draw other rows (the Hub passes its own, to lock what it
236
+ gates), or `hubItems={[]}` for none, and the rail's Hub then goes to the
237
+ Hub, as before 0.3.0. In the Hub the panel's rows are its own routes, and
238
+ the rail's Hub is its menu's control: pressed after browsing another
239
+ function's menu, it reopens the Hub menu on the page the person is on, with
240
+ no navigation; from another place (Admin, an app's Settings) it lands on the
241
+ Hub's landing. `targetFor` still honours the design system's `back` flag
242
+ for a caller that passes it.
196
243
 
197
244
  ### Off the core
198
245
 
199
246
  `autosolutions-os/nav` is plain data and functions, with no React and no
200
- Supabase: the rail (`OS_FUNCTIONS`), the menu map (`OS_MENU`), `OS_TOOL_LINKS`,
201
- `HUB_URL`, `HUB_PATHS`, `HINTS`, `osFooter()`, `staticLinks()` and
202
- `osFrame()`, the routing rules the frame runs on. An app on its own project
203
- (Ops Hub: see "Linked, not federated" in `docs/CONTRACT.md`) pairs it with the
204
- design system's `WorkspaceFrame`, a static plate and no switcher. `staticLinks()`
205
- are the fixed addresses (Ops Hub's tools, Label Maker, CRM, Key accounts, PM
206
- Copilot), with no tenant hint; with no catalogue to ask, they are all live, and
207
- each app's own sign-in decides. If the app's CSS is a fork of the design
247
+ Supabase: the rail (`OS_FUNCTIONS`), the menu map (`OS_MENU`), the Hub panel
248
+ (`OS_HUB_MENU`), `OS_TOOL_LINKS`, `OS_TOOL_ALIASES` and `osToolId()`,
249
+ `osHubPath()`, `HUB_URL`, `HUB_PATHS`, `HINTS`, `osFooter()`, `staticLinks()`
250
+ and `osFrame()`, the routing rules the frame runs on. An app on its own
251
+ project (Ops Hub: see "Linked, not federated" in `docs/CONTRACT.md`) pairs it
252
+ with the design system's `WorkspaceFrame`, a static plate and no switcher.
253
+ `staticLinks()` are the fixed addresses (Ops Hub's tools, Label Maker, CRM, Key
254
+ accounts, PM Copilot), with no tenant hint; with no catalogue to ask, they are
255
+ all live, and each app's own sign-in decides. Every other row opens its page
256
+ in the Hub through `HUB_URL` (`hubUrl`), where the core decides. If the app's CSS is a fork of the design
208
257
  system, import `autosolutions-design-system/frame.css` instead of `styles.css`
209
258
  (see the design system's README).
210
259
 
@@ -222,7 +271,7 @@ const here = pathname + search;
222
271
  footerItems={frame.footerItems}
223
272
  location={{ ...frame.locate(here), href: here }}
224
273
  onNavigate={(state) => {
225
- // The state whole: `reselect` and `back` (Back to hub) change where it goes.
274
+ // The state whole: `reselect` changes where it goes.
226
275
  const target = frame.targetFor(state, here);
227
276
  if (!target) return false; // goes nowhere: the frame stays where `here` is
228
277
  if (target.external) window.location.assign(target.href);
@@ -0,0 +1,143 @@
1
+ /** The provider identifier every federated project registers. */
2
+ export declare const AUTOSOLUTIONS_PROVIDER = "custom:autosolutions";
3
+ /** The Hub's sign-out page. */
4
+ export declare const SIGN_OUT_PATH = "/sign-out";
5
+ type Identity = {
6
+ provider?: unknown;
7
+ id?: unknown;
8
+ identity_id?: unknown;
9
+ email?: unknown;
10
+ last_sign_in_at?: unknown;
11
+ identity_data?: {
12
+ [key: string]: unknown;
13
+ } | null;
14
+ };
15
+ type UserLike = {
16
+ id?: unknown;
17
+ identities?: Identity[] | null;
18
+ } | null | undefined;
19
+ type SessionLike = {
20
+ user?: UserLike;
21
+ } | null | undefined;
22
+ /** The parts of a supabase-js client this module uses (any supabase-js 2.x client fits). */
23
+ export type FederatedAuth = {
24
+ onAuthStateChange(callback: (event: string, session: SessionLike) => void): unknown;
25
+ signOut(options?: {
26
+ scope?: "global" | "local" | "others";
27
+ }): Promise<unknown>;
28
+ };
29
+ export type FederatedSignIn = {
30
+ signInWithOAuth(credentials: {
31
+ provider: any;
32
+ options?: {
33
+ [key: string]: unknown;
34
+ };
35
+ }): Promise<{
36
+ data: unknown;
37
+ error: unknown;
38
+ }>;
39
+ };
40
+ /** The person's AutoSolutions identity in the app's project. */
41
+ export type CoreIdentity = {
42
+ /** The core user id: the same person in the Hub and every app on the core. */
43
+ sub: string;
44
+ /** The address the core vouched for when it was linked, or last signed in. */
45
+ email: string | null;
46
+ /** Whether the core said that address is verified; null when it did not say. */
47
+ emailVerified: boolean | null;
48
+ /** The identity's own row id in the app's project, when supabase-js reports it. */
49
+ identityId: string | null;
50
+ /** When the person last came in through AutoSolutions, as the app's project recorded it. */
51
+ lastSignInAt: string | null;
52
+ };
53
+ /**
54
+ * The `custom:autosolutions` identity of a user of the app's project, or null
55
+ * when the person has never come in through AutoSolutions.
56
+ */
57
+ export declare function coreIdentity(user: UserLike): CoreIdentity | null;
58
+ export type SignInOptions = {
59
+ /** Where the app's project sends the person back to: one of that project's Redirect URLs. */
60
+ redirectTo: string;
61
+ /**
62
+ * The sign-in page starts the flow by itself rather than on a click. It then
63
+ * starts only on an autosolutions.app address, when the core's cookie shows
64
+ * a live session, at most once a minute, and not after a sign-out here, a
65
+ * "no access" answer (`holdAutomaticSignIn`) or an attempt that did not come
66
+ * back. A click clears all of that.
67
+ */
68
+ automatic?: boolean;
69
+ /** Return the provider's address instead of going there (a popup flow, as in Ops Hub). */
70
+ skipBrowserRedirect?: boolean;
71
+ /** Extra scopes. The provider's own setting already asks for `openid email profile`. */
72
+ scopes?: string;
73
+ };
74
+ export type SignInResult = {
75
+ started: true;
76
+ url: string | null;
77
+ } | {
78
+ started: false;
79
+ reason: "off-domain" | "returning" | "held" | "too-soon" | "no-core-session";
80
+ } | {
81
+ started: false;
82
+ reason: "error";
83
+ error: unknown;
84
+ };
85
+ /**
86
+ * Start "Sign in with AutoSolutions". On a click, always; with `automatic`,
87
+ * only when the rules above allow it, so a sign-in page can call it as soon as
88
+ * it knows there is no session, and never loops.
89
+ */
90
+ export declare function signInWithAutoSolutions(client: {
91
+ auth: FederatedSignIn;
92
+ }, options: SignInOptions): Promise<SignInResult>;
93
+ /**
94
+ * Keep the automatic start from running until the person clicks: after a
95
+ * "no access" answer from the app's own rules, and before a sign-out here
96
+ * (`signOutWithAutoSolutions` does it).
97
+ */
98
+ export declare function holdAutomaticSignIn(): void;
99
+ /**
100
+ * Whether this browser's session in the app came through AutoSolutions. With
101
+ * `user`, also that it is that person's (their AutoSolutions identity is the
102
+ * one the marker names). Needs `followCoreSession`, which sets the marker.
103
+ */
104
+ export declare function cameThroughAutoSolutions(user?: UserLike): boolean;
105
+ export type FollowOptions = {
106
+ /**
107
+ * Called once this app has signed out (local scope) because the core did
108
+ * (`"core-signed-out"`) or because someone else is signed in at the core
109
+ * (`"different-person"`). The app's own SIGNED_OUT handling shows the
110
+ * sign-in page either way; use this to say why, or to navigate.
111
+ */
112
+ onSignedOut?: (reason: "core-signed-out" | "different-person") => void;
113
+ /** How often to look while the page is open. Default once a minute. */
114
+ intervalMs?: number;
115
+ };
116
+ /**
117
+ * Install once, at the app's root, on every address: it records which
118
+ * sessions came through AutoSolutions everywhere, and on an autosolutions.app
119
+ * address keeps those sessions in step with the core (see the top of this
120
+ * file). Returns a function that stops it.
121
+ */
122
+ export declare function followCoreSession(client: {
123
+ auth: FederatedAuth;
124
+ }, options?: FollowOptions): () => void;
125
+ /**
126
+ * The Hub's sign-out page, which signs the person out of the core (so the Hub
127
+ * and every app follow) and then returns to `returnTo`, when the Hub allows
128
+ * that address. A relative `returnTo` is taken from this page's address.
129
+ */
130
+ export declare function signOutEverywhereUrl(returnTo: string): string;
131
+ /**
132
+ * The app's sign-out for a session that came through AutoSolutions: hold the
133
+ * automatic start, sign out here (local scope), then go through the Hub's
134
+ * sign-out back to `returnTo` (the app's sign-in page). Returns false, and does
135
+ * nothing, for any other session: the app then signs out as it always has.
136
+ */
137
+ export declare function signOutWithAutoSolutions(client: {
138
+ auth: FederatedAuth;
139
+ }, options: {
140
+ returnTo: string;
141
+ user?: UserLike;
142
+ }): Promise<boolean>;
143
+ export {};