@flow-industries/id 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +69 -8
  2. package/contracts/v1/openapi.json +818 -0
  3. package/contracts/v1/reports.json +188 -0
  4. package/contracts/v1/sdk-exports.json +1165 -0
  5. package/dist/sdk/browser-contract.d.ts +30 -0
  6. package/dist/sdk/browser-contract.js +19 -0
  7. package/dist/sdk/browser-session-route.d.ts +8 -0
  8. package/dist/sdk/browser-session-route.js +196 -0
  9. package/dist/sdk/client/create-flow.js +176 -166
  10. package/dist/sdk/client/dialog-host.js +11 -6
  11. package/dist/sdk/client/flow-widget.js +4 -4
  12. package/dist/sdk/client/idb.d.ts +1 -0
  13. package/dist/sdk/client/idb.js +24 -0
  14. package/dist/sdk/client/iframe-host.d.ts +2 -1
  15. package/dist/sdk/client/iframe-host.js +11 -1
  16. package/dist/sdk/client/index.d.ts +2 -0
  17. package/dist/sdk/client/index.js +1 -0
  18. package/dist/sdk/client/open-profile.js +19 -8
  19. package/dist/sdk/client/profile-button.d.ts +1 -13
  20. package/dist/sdk/client/profile-button.js +114 -170
  21. package/dist/sdk/client/reports.d.ts +9 -0
  22. package/dist/sdk/client/reports.js +30 -0
  23. package/dist/sdk/client/session.d.ts +1 -10
  24. package/dist/sdk/client/session.js +0 -37
  25. package/dist/sdk/client/static-flow.js +1 -0
  26. package/dist/sdk/contracts/http.d.ts +155 -0
  27. package/dist/sdk/contracts/http.js +91 -0
  28. package/dist/sdk/contracts/reports.d.ts +130 -0
  29. package/dist/sdk/contracts/reports.js +67 -0
  30. package/dist/sdk/dialog/remote/Messenger.d.ts +3 -0
  31. package/dist/sdk/dialog/remote/Messenger.js +9 -3
  32. package/dist/sdk/react/hooks.d.ts +1 -1
  33. package/dist/sdk/react/profile-button.d.ts +1 -12
  34. package/dist/sdk/react/profile-button.js +1 -12
  35. package/dist/sdk/session-route.js +101 -4
  36. package/dist/sdk/types/dialog.d.ts +0 -3
  37. package/dist/sdk/types/index.d.ts +2 -1
  38. package/dist/sdk/types/landing.d.ts +1 -0
  39. package/dist/sdk/types/reports.d.ts +7 -0
  40. package/dist/sdk/types/reports.js +0 -0
  41. package/dist/sdk/types/sdk.d.ts +7 -21
  42. package/dist/sdk/types/server.d.ts +6 -0
  43. package/dist/sdk/wagmi/index.js +0 -3
  44. package/package.json +18 -9
package/README.md CHANGED
@@ -37,15 +37,24 @@ bun add @flow-industries/id wagmi viem @tanstack/react-query
37
37
 
38
38
  ## Documentation
39
39
 
40
- Full documentation at **[docs.flow.industries/en/auth](https://docs.flow.industries/en/auth)**.
40
+ - [Integration guide](docs/integration-guide.md) — server setup, canonical sign-in, React, and account navigation.
41
+ - [Guest sessions](docs/guest-sessions.md) — silent guest creation and preserving identity during signup.
42
+ - [Action sessions](docs/action-sessions.md) — activity timing and the inline action widget.
41
43
 
42
- - [Getting started](https://docs.flow.industries/en/auth/getting-started) - install the SDK and ship a login button
43
- - [Concepts](https://docs.flow.industries/en/auth/concepts) - passkeys, audience-bound JWTs, sessions, and access keys
44
- - [SDK](https://docs.flow.industries/en/auth/sdk/create-flow) - `createFlow`, React hooks, Wagmi connector, and direct dialog control
45
- - [Wagmi](https://docs.flow.industries/en/auth/sdk/wagmi) - use Flow ID as a Wagmi connector
46
- - [Signing](https://docs.flow.industries/en/auth/signing) - messages, typed data, transactions, and batch calls
47
- - [JWT verify](https://docs.flow.industries/en/auth/jwt-verify) - verify Flow sessions on your backend
48
- - [API reference](https://docs.flow.industries/en/auth/api) and [self-hosting](https://docs.flow.industries/en/auth/self-hosting)
44
+ The Auth pages in the separate documentation repository are archived. Use the
45
+ guides here for the current SDK integration.
46
+
47
+ ## Sign-in and account pages
48
+
49
+ The SDK starts sign-in through your app's first-party `/flow/session` handler
50
+ and navigates to Flow ID's `/authorize` page. Completion returns to the saved
51
+ app path; read the new session after navigation instead of continuing after
52
+ `await flow.login()`.
53
+
54
+ `ProfileButton` and `flow.openAccount()` open `/account` in a normal new tab.
55
+ The source app stays loaded and refreshes its session on refocus. Sign-in and
56
+ own-account management no longer use an embedded dialog. See the
57
+ [integration guide](docs/integration-guide.md) for server wiring and migration.
49
58
 
50
59
  ## Public profile overlays
51
60
 
@@ -82,3 +91,55 @@ pointer lock before opening, then use `onClose` to restore their input state.
82
91
  ## License
83
92
 
84
93
  MIT
94
+
95
+
96
+ ### Migration compatibility checks
97
+
98
+ `bun run db:check` regenerates into a temporary directory and refuses schema drift or edits
99
+ to previously committed SQL. CI compares against the PR base or previous main commit.
100
+ `bun run test:migrations` exercises the committed chain, the supported previous schema,
101
+ current projections, older writes after upgrade, and deliberate missing-migration failures.
102
+ `MIGRATION_TEST_DATABASE_URL=postgres://... bun scripts/postgres-acceptance.ts` additionally
103
+ creates a unique disposable database on a test PostgreSQL server, runs the real migration
104
+ entrypoint, rejects a changed applied hash, and proves a failing final migration rolls back
105
+ both its schema changes and ledger entry. The test deletes only its own generated database.
106
+
107
+ The initial compatibility baseline is source `1bda372b69e2f66a3dc0cbb244bcbe7cb858f493` (schema through `0035`).
108
+ The tests freeze representative older SQL reads/writes; they do not boot every historical
109
+ application version. Advance this baseline deliberately when retiring support, and extend
110
+ the fixtures when changing a persisted contract. Migration failures block the image build;
111
+ production's PreSync job also refuses an applied ledger that is not an exact committed prefix.
112
+
113
+ Application rollback keeps the expanded schema. Pin the latest verified migration image via
114
+ Mesh's `migrate.image` while restoring the previous compatible application image. Do not run
115
+ down migrations or point an older migration image at a newer ledger: that is refused. A
116
+ destructive contract migration needs an explicit support-boundary change after older writers
117
+ and browser clients have drained.
118
+
119
+ ## Versioned consumer contracts
120
+
121
+ `bun run contracts:generate` produces the published
122
+ `@flow-industries/id/contracts/v1/reports.json` and `openapi.json` artifacts from
123
+ the same schemas used by the XP, action, presence and position handlers.
124
+ `bun run contracts:check` rejects stale output and incompatible changes to the
125
+ existing v1 request schema against `CONTRACT_BASE_REF` (default `origin/main`).
126
+ Keep existing v1 fields compatible; a breaking boundary needs a new version and
127
+ an overlap plan for deployed consumers.
128
+
129
+ Trusted service consumers can call `createReportsApi(host, serviceToken)` from
130
+ `@flow-industries/id`. The returned function accepts the operation name and its
131
+ typed request, validates both the outgoing request and successful response, and
132
+ throws `ReportRequestError` for non-success responses. Use the XP reporting
133
+ credential for action/XP operations and the room credential for presence/position;
134
+ never ship either service credential to a browser.
135
+
136
+ `bun run test:sdk-package` builds, packs and installs the actual SDK artifact in
137
+ a disposable consumer, checks public imports and declarations, and proves a
138
+ removed contract export fails. Producer tests execute the typed client against
139
+ real report handlers and validate minted guest/full session and JWT shapes.
140
+ CI gates both container and package publication on these checks.
141
+
142
+ The current OpenAPI artifact describes the service report boundary. The remaining
143
+ account, room management, study, settings, session and passkey HTTP operations
144
+ still need complete request/response descriptions and generated client coverage
145
+ before the full HTTP contract work is complete.