Repository navigation
Commit e53e02e
feat(console): a Mobile App page in the account app shows the code that connects the ObjectOS mobile app (#34141)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi91YSeH3thYWBG8zdtU9ZDBB)_
Fixes #29314
Clause-②: yes (widening) — a new account-app navigation entry and
component (`account:mobile_app`), a new `mobileApp` namespace in the
`@object-ui/i18n` packs, and a new optional `features.publicBaseUrl`
served on `GET /api/v1/auth/config` (declared in
`AuthFeaturesConfigSchema`, registered in
`PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`, typed on `AuthPublicConfig`);
nothing that worked before is refused
Metadata-protocol: added
Skills-docs: none — `features.publicBaseUrl` is a key the server serves
on its public auth config; no metadata author writes it, and no skill
teaches the auth config payload
## 维护者速读
- 改了什么:个人设置(头像菜单 → Profile 所在的 account 应用)在 Profile
之后新增「移动应用」页,显示二维码和可复制的连接链接 `objectos://connect?server=<本服务器公开地址>`;服务端
`GET /api/v1/auth/config` 新增 `features.publicBaseUrl`,就是服务器发邮件、OAuth
链接时用的那个公开地址(只含 scheme、host、路径)。
- 为什么改:用户装好 ObjectOS 手机 App 后,要扫码连到自己的服务器;现在只能手敲地址。
- 风险与回滚:匿名接口多了一个地址字段,但凭据、query、fragment 在服务端和页面两头都会去掉;地址是 localhost /
内网、或公网却只走 http 时不出码,提示把 `OS_AUTH_URL` 设成 https 公网地址;从不用浏览器当前地址。spec
因新增键按规则升 minor。回滚即还原本 PR。
-
先看:`packages/plugins/plugin-auth/src/public-base-url.ts`、`ui/packages/app-shell/src/console/mobile-app/mobileConnect.ts`、`packages/spec/src/api/auth-endpoints.zod.ts`。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/public-base-url.test.ts` 应 10 个测试全过(含走真实 `/api/v1/auth/config` 的两条)。
- 需要你做的:无,席位落地。
## What changes
**Server.**
- `GET /api/v1/auth/config` serves `features.publicBaseUrl`:
`publicBaseUrlOf(getCanonicalOrigin())`, the canonical origin every
emailed and OAuth link is built on (`OS_AUTH_URL`, then
`BETTER_AUTH_URL`, then `OS_BASE_URL`; sub-path kept; `https://`
prepended to a bare host; the loopback fallback when unset).
- `publicBaseUrlOf` (new, `plugin-auth`) reduces it to an address:
scheme, host (with a non-default port) and path, no trailing slash. A
username, password, query or fragment is dropped, because the door is
anonymous. A value that does not parse as an absolute URL is not served.
- `AuthFeaturesConfigSchema.publicBaseUrl` (optional string, with a
describe), `'publicBaseUrl'` appended to
`PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`, and the regenerated
`auth-endpoints.mdx` reference and `authorable-surface/api.json`
baseline.
**Console.**
- `MobileAppPage` (new, `@object-ui/app-shell`, lazy-loaded) reads
`features.publicBaseUrl` through `useAuth().getAuthConfig()` and judges
it with `mobileConnectTarget`:
- `ready`: a public host on `https:`. A QR code (the existing `qrcode`
dependency, as an SVG `data:` image on a white frame), the same link as
copyable text with **Copy link**, and one privacy line.
- `unreachable` / `not-public`: `localhost`, a loopback, private,
link-local or otherwise non-public host, or a scheme other than http(s).
No code; the alert names the address and says to set `OS_AUTH_URL` to
the public address.
- `unreachable` / `not-https`: a public host on plain `http:`. The
mobile app signs in through this address, so no code; the alert says to
serve the server over HTTPS and set `OS_AUTH_URL` to its `https://`
address.
- `unpublished`: the key is absent, blank or not an absolute URL (the
raw value is never shown). The alert says this server does not offer it
yet; no setting is named, because none can fix it.
- A failed config read shows its own message. `window.location` is never
read.
- The payload is `objectos://connect?server=` plus the URL-encoded
`normalizeServerUrl(publicBaseUrl)`: the same address-only
normalisation, applied again on the console side, so the code and every
refusal carry the server's address and nothing else.
- `deploymentReach`: the new `isPublicHostAddress` is scheme-agnostic;
`isPublicHttpsAddress` keeps its behaviour by parsing the URL, requiring
`https:`, and delegating. The Connect Agent widget is unchanged.
- `registerAppComponent({ ref: 'account:mobile_app', … })` in
`builtinComponents`; `AuthPublicConfig.features.publicBaseUrl?: string`
in `@object-ui/auth`.
- `packages/platform-objects` account app: `nav_account_mobile_app`
(component nav, `componentRef: 'account:mobile_app'`, icon `smartphone`)
right after Profile, with its label in all 11 app translation bundles.
- A `mobileApp` namespace (15 keys) in the 10 hand-written
`@object-ui/i18n` packs; `zh-Hant` regenerated with
`scripts/gen-zh-hant.mjs`.
- No app-store links: no setting carries them today.
## Tests
- `public-base-url.test.ts` (plugin-auth): over the REAL
`registerAuthRoutes` on a Hono app over a real `AuthManager`, `GET
/api/v1/auth/config` serves the configured URL with its sub-path, and a
configured credential, query and fragment are absent from the whole
response body; `getPublicConfig()` follows `getCanonicalOrigin` (bare
host, trailing slash) with a CONTROL for the loopback fallback;
`publicBaseUrlOf` cases, including an unparseable value served as
nothing.
- `mobileConnect.test.ts`: the payload for a public URL, a sub-path and
a port; 13 loopback / private / link-local addresses refused as
`not-public`; another scheme refused without its credential; a public
`http:` host refused as `not-https`, with a CONTROL on `https:`; eight
inputs (credentials, query, fragment, trailing slash, whitespace, case,
default port) normalised; the link's only parameter is `server`; a value
that is not an absolute URL reads as `unpublished`.
- `MobileAppPage.test.tsx`: the image `src` equals `qrcode`'s own SVG
for the expected link; a credential, query or fragment reaches neither
the code nor the page; Copy writes exactly the link; the not-public,
not-https and unpublished refusals with their keys and values (the
unpublished one names no `OS_AUTH_URL`); the failed read; every built-in
locale carries every `mobileApp` key with the same placeholders;
`account:mobile_app` resolves through the component registry to this
page.
- `account-mobile-app-nav.test.ts` (platform-objects):
`nav_account_mobile_app` sits immediately after `nav_account_profile`,
opens `account:mobile_app` and carries no gate, with a CONTROL that the
app still parses.
- `ui/e2e/mobile-app-connect-qr.spec.ts` (Playwright): the QR image
decodes (`naturalWidth > 0`) at ≥150px beside the link, Copy button and
privacy line; a CONTROL with a loopback URL shows the `OS_AUTH_URL`
remedy and no code.
- Ablations, each red then green after restore: the raw canonical origin
served (1 failed); the key not served (4 failed); no console-side
normalisation (12 failed); a public `http:` host treated as ready (2
failed); the registered ref renamed (1 failed); the nav entry moved
before Profile (1 failed); and, in the first round, the refusal
predicate removed (16), the sub-path dropped (3), a `window.location`
fallback (1), a broken image `src` (the e2e image test).
- Forced test edits, three, each because this PR adds a key or an entry
on purpose:
- `packages/cli/test/connect-agent-both-halves-wire.pin.test.ts`: the
account app's served nav ids count 14, not 13
(`nav_account_mobile_app`).
- `packages/spec/src/api/auth-endpoints.test.ts`: the served `features`
fixture gains `publicBaseUrl`, because the test requires it to name
every classified key.
- `packages/plugins/plugin-auth/src/auth-manager.test.ts`: the exact
`getPublicConfig().features` expectation gains `publicBaseUrl:
'http://localhost:3000'`.
## Acceptance notes
- File surface deviations, seat-approved: the account app
(`account.app.ts`) and its 11 translation bundles for the nav entry; the
server half in `auth-endpoints.zod.ts` and `auth-manager.ts`, added
after #34119 and #34099 merged, plus the new `public-base-url.ts`.
- Grading: the claim's `Metadata-protocol: none` is now `added`. The new
key moves the `authorable-surface/api.json` baseline, and
`check-changeset-no-major.mjs` refuses `none` with a moved baseline, so
`@objectstack/spec`, `@objectstack/plugin-auth` and
`@objectstack/platform-objects` are `minor`; the `@object-ui/*` packages
stay `patch`.
- The account app has no separate "user settings" page; the account app
reached from the avatar menu's Profile item is that surface.
- Cloud-agnostic: nothing here reads a Cloud setting; a Cloud deployment
publishes its URL through the same `OS_AUTH_URL`.
## Verification
<details><summary>Derived gates</summary>
- `node scripts/pm/dispatch-gates.mjs --ran` on the final record at
`7c7c5ba4`: "125 derived famil(ies) accounted for — 125 run, 0
NOT-MEASURED". All 125 exit 0.
- The round before it, at `cacb7dd1`, had three reds:
`check:test-source-alias` (a finding: the page test's registry check
reaches the metadata admin's dynamic `@objectstack/lint` import inside a
clocked window; fixed in `7c7c5ba4` by the module-top import the gate
prescribes), and `check:dts-closure` plus `pnpm --dir ui exec vitest run
scripts/` (both read `ui/` build output that was stale after merging
`main`; green after rebuilding the ui packages).
- Suites at the server-half head under the lock: `@objectstack/spec` 844
files, 26993 tests (one red fixed: the served-features fixture, listed
above); `@objectstack/plugin-auth` 278 files (one red fixed: the exact
`features` expectation); `@objectstack/platform-objects` 123 files, 2010
passed. The mobile-app vitest (47) and the Playwright spec (2) pass on
the UI changes; app-shell `tsc` and eslint are clean.
- `check-changeset-no-major.mjs --event` on this body offline: level
axis green with `Metadata-protocol: added` and every moved package
graded `minor`.
- Earlier rounds: 69 at `58280860` and 71 at `9cebce86`, all exit 0.
- Records: project share `ui-seat1/29314-gates-ran-final.txt`,
`ui-seat1/29314-gates-ran-r4.txt`, `ui-seat1/29314-ablations-r2.log`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmRLqg1PuH8D83b32SV
<!-- signed: domain:ui#1 · os-steve · session_01ADHkmRLqg1PuH8D83b32SV
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 2243872 commit e53e02e
43 files changed
Lines changed: 1267 additions & 9 deletions
File tree
- .changeset
- content/docs/references/api
- packages
- cli/test
- platform-objects/src/apps
- translations
- plugins/plugin-auth/src
- spec
- authorable-surface
- src
- api
- kernel
- ui
- e2e
- packages
- app-shell/src
- console
- connect
- mobile-app
- services
- auth/src
- i18n/src/locales
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
226 | | - | |
227 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
76 | 87 | | |
77 | 88 | | |
78 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
0 commit comments