@oxy.so/services 14.10.1 → 14.11.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 (88) hide show
  1. package/lib/commonjs/index.js +10 -0
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/boot/runProviderColdBoot.js +3 -1
  4. package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
  5. package/lib/commonjs/ui/components/OxyProvider.js +52 -18
  6. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  7. package/lib/commonjs/ui/context/OxyContext.js +15 -5
  8. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  9. package/lib/commonjs/ui/context/OxyHostedContext.js +515 -0
  10. package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -0
  11. package/lib/commonjs/ui/context/oxyRuntimeContext.js.map +1 -1
  12. package/lib/commonjs/ui/hooks/useAuth.js +13 -2
  13. package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
  14. package/lib/commonjs/ui/hooks/useOxyEvent.js +9 -5
  15. package/lib/commonjs/ui/hooks/useOxyEvent.js.map +1 -1
  16. package/lib/commonjs/ui/session/hostSession.js +474 -0
  17. package/lib/commonjs/ui/session/hostSession.js.map +1 -0
  18. package/lib/module/index.js +3 -0
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/ui/boot/runProviderColdBoot.js +3 -1
  21. package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
  22. package/lib/module/ui/components/OxyProvider.js +53 -19
  23. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  24. package/lib/module/ui/context/OxyContext.js +15 -5
  25. package/lib/module/ui/context/OxyContext.js.map +1 -1
  26. package/lib/module/ui/context/OxyHostedContext.js +510 -0
  27. package/lib/module/ui/context/OxyHostedContext.js.map +1 -0
  28. package/lib/module/ui/context/oxyRuntimeContext.js.map +1 -1
  29. package/lib/module/ui/hooks/useAuth.js +13 -2
  30. package/lib/module/ui/hooks/useAuth.js.map +1 -1
  31. package/lib/module/ui/hooks/useOxyEvent.js +9 -5
  32. package/lib/module/ui/hooks/useOxyEvent.js.map +1 -1
  33. package/lib/module/ui/session/hostSession.js +467 -0
  34. package/lib/module/ui/session/hostSession.js.map +1 -0
  35. package/lib/typescript/commonjs/index.d.ts +1 -0
  36. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts +6 -0
  38. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts +40 -0
  42. package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +19 -2
  44. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/ui/context/oxyRuntimeContext.d.ts +6 -0
  46. package/lib/typescript/commonjs/ui/context/oxyRuntimeContext.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +3 -0
  48. package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/ui/hooks/useOxyEvent.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/ui/session/hostSession.d.ts +69 -0
  51. package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -0
  52. package/lib/typescript/commonjs/ui/types/navigation.d.ts +24 -1
  53. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts +4 -0
  55. package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts.map +1 -1
  56. package/lib/typescript/module/index.d.ts +1 -0
  57. package/lib/typescript/module/index.d.ts.map +1 -1
  58. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts +6 -0
  59. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  60. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  61. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  62. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts +40 -0
  63. package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -0
  64. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +19 -2
  65. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  66. package/lib/typescript/module/ui/context/oxyRuntimeContext.d.ts +6 -0
  67. package/lib/typescript/module/ui/context/oxyRuntimeContext.d.ts.map +1 -1
  68. package/lib/typescript/module/ui/hooks/useAuth.d.ts +3 -0
  69. package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
  70. package/lib/typescript/module/ui/hooks/useOxyEvent.d.ts.map +1 -1
  71. package/lib/typescript/module/ui/session/hostSession.d.ts +69 -0
  72. package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -0
  73. package/lib/typescript/module/ui/types/navigation.d.ts +24 -1
  74. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  75. package/lib/typescript/module/ui/utils/identityCrypto.d.ts +4 -0
  76. package/lib/typescript/module/ui/utils/identityCrypto.d.ts.map +1 -1
  77. package/package.json +4 -4
  78. package/src/index.ts +3 -0
  79. package/src/ui/boot/runProviderColdBoot.ts +12 -1
  80. package/src/ui/components/OxyProvider.tsx +77 -34
  81. package/src/ui/context/OxyContext.tsx +19 -4
  82. package/src/ui/context/OxyHostedContext.tsx +678 -0
  83. package/src/ui/context/oxyContextTypes.ts +21 -2
  84. package/src/ui/context/oxyRuntimeContext.ts +9 -1
  85. package/src/ui/hooks/useAuth.ts +13 -1
  86. package/src/ui/hooks/useOxyEvent.ts +8 -5
  87. package/src/ui/session/hostSession.ts +515 -0
  88. package/src/ui/types/navigation.ts +24 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The provider's session source on a platform that holds the Oxy session
3
+ * (ADR 0058 decision 1).
4
+ *
5
+ * Headless: it reads an {@link OxySessionHost} and drives the provider's
6
+ * runtime (ADR 0004) and the client's two auth seams with it. Nothing here
7
+ * persists anything, mints anything, or touches `/session/device/*`:
8
+ *
9
+ * - `http.setAccessTokenProvider` answers the host's last token from memory;
10
+ * `http.setAuthRefreshHandler` asks the host (`preflight`, `response-401`).
11
+ * - A snapshot whose `revision` (or status, or account) changes is ONE context
12
+ * transition, in ADR 0002's order: the token is dropped and the session
13
+ * epoch bumped, a token for the new account is awaited, and only then is the
14
+ * account published.
15
+ * - Offline the account is published with no token: `canUsePrivateApi` stays
16
+ * false and the app shows what it cached under that account's id.
17
+ * - Sign-in, switch, sign-out and account management are the platform's:
18
+ * {@link HostSession.request} hands them over and changes nothing here.
19
+ */
20
+ import type { OxyServices, User } from '@oxy.so/core';
21
+ import type { OxyHostAccount, OxyHostRequest, OxyHostSnapshot, OxySessionHost } from '@oxy.so/core/host';
22
+ import type { OxyRuntime } from '../runtime/index.js';
23
+ /**
24
+ * Thrown by an operation a hosted provider leaves to the platform that holds
25
+ * the session (ADR 0058 decision 1): a sign-in this app would commit itself,
26
+ * device management, a switch that must return the new account. The platform's
27
+ * own UI does these; the result reaches the app as a snapshot.
28
+ */
29
+ export declare class HostedSessionError extends Error {
30
+ readonly operation: string;
31
+ readonly code = "oxy_session_hosted";
32
+ constructor(operation: string);
33
+ }
34
+ /** How long a context transition waits for the host's token before publishing the account without one. */
35
+ export declare const HOST_TOKEN_DEADLINE_MS = 10000;
36
+ export interface HostSessionOptions {
37
+ host: OxySessionHost;
38
+ oxyServices: OxyServices;
39
+ runtime: OxyRuntime;
40
+ /**
41
+ * The account changed (`'account'`) or a token for the same account arrived
42
+ * or went (`'token'`). The user socket follows this.
43
+ */
44
+ onTokenChange?: (kind: 'account' | 'token') => void;
45
+ logger: (message: string, error?: unknown) => void;
46
+ /** Tests. */
47
+ tokenDeadlineMs?: number;
48
+ /** Tests. */
49
+ retryBackoffMs?: readonly number[];
50
+ }
51
+ export interface HostSession {
52
+ /** Begin following the host. Returns the disposer; may be started again after it. */
53
+ start(): () => void;
54
+ /** Hand an action to the platform's own UI. Never changes the session itself. */
55
+ request(action: OxyHostRequest): Promise<void>;
56
+ /** Re-read the host's snapshot now, and fetch a token if one is due. */
57
+ refresh(): Promise<void>;
58
+ /** The platform this session comes from. */
59
+ readonly platform: OxySessionHost['platform'];
60
+ }
61
+ /**
62
+ * The host's snapshot, checked. A host that throws or answers something that is
63
+ * not a snapshot is `unavailable` — signed out, never a reason to sign in here.
64
+ */
65
+ export declare function readHostSnapshot(host: OxySessionHost): OxyHostSnapshot;
66
+ /** The provider's `User` for the snapshot's account, over what the API said about it. */
67
+ export declare function userFromHostAccount(account: OxyHostAccount, base: User | null): User;
68
+ export declare function createHostSession(options: HostSessionOptions): HostSession;
69
+ //# sourceMappingURL=hostSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostSession.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/hostSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,eAAe,EAGf,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAY,CAAC;AAG7C;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAG/B,QAAQ,CAAC,SAAS,EAAE,MAAM;IAFtC,QAAQ,CAAC,IAAI,wBAAwB;gBAEhB,SAAS,EAAE,MAAM;CAMvC;AAED,0GAA0G;AAC1G,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,UAAU,CAAC;IACpB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,KAAK,IAAI,CAAC;IACpD,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnD,aAAa;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa;IACb,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,KAAK,IAAI,MAAM,IAAI,CAAC;IACpB,iFAAiF;IACjF,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,wEAAwE;IACxE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CAC/C;AA0BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAsBtE;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAYpF;AAmBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgW1E"}
@@ -2,7 +2,7 @@ import type { ReactNode, RefObject } from 'react';
2
2
  import type { QueryClient } from '@tanstack/react-query';
3
3
  import type { AccountQueriesConfig } from '../hooks/accountQueryPersistence.js';
4
4
  import type { RouteName } from '../navigation/routes.js';
5
- import type { SessionMode } from '@oxy.so/core/session';
5
+ import type { AuthStateStore, SessionMode } from '@oxy.so/core/session';
6
6
  import type { WebAuthMode } from '../oauth/types.js';
7
7
  import type { ProductAnalytics } from '../analytics/productAnalytics.js';
8
8
  export interface StepController {
@@ -98,6 +98,13 @@ export interface OxyProviderProps {
98
98
  * skipped — it commits whichever account the IdP resolves, which is not
99
99
  * necessarily the local key's owner.
100
100
  *
101
+ * On a platform that holds the Oxy session — OxyOS, Astro — the platform
102
+ * registers a session host (`@oxy.so/core/host`, ADR 0058) before the app
103
+ * runs, and an `'account'` provider takes its session from it: the
104
+ * platform's token and account, nothing persisted, and `signIn()`,
105
+ * `openAccountDialog()`, a switch and `logout()` handed to the platform's
106
+ * own UI. The app does not choose. `'identity'` is never hosted.
107
+ *
101
108
  * Read once at mount, like `baseURL` / `oxyServices`: changing it on a
102
109
  * mounted provider does not re-bind the session.
103
110
  * @default 'account'
@@ -163,6 +170,22 @@ export interface OxyProviderProps {
163
170
  language?: OxyLanguageConfig;
164
171
  /** Persist bounded first-touch link labels and attach them only to a new account. */
165
172
  campaignAttribution?: boolean;
173
+ /**
174
+ * The seam for a PLATFORM'S SETUP CLIENT (OxyOS's login screen): where this
175
+ * provider persists the session credential instead of the platform's own
176
+ * storage. Every credential write — `{ deviceId, deviceSecret }`, the warm
177
+ * token, the sign-out marker — goes through it and nowhere else: no secure
178
+ * store, no `localStorage`, no shared device slot (the sibling-app lane is
179
+ * off) and no background credential (`backgroundSession` is ignored). The
180
+ * email-code, password and authenticator sign-ins and the "add a password"
181
+ * flow (ADR 0030) run as usual; `save()` receives the credential the moment
182
+ * a sign-in commits, so the platform can take it over.
183
+ *
184
+ * Ordinary apps never pass it. Never combined with a session host: when a
185
+ * platform has registered one (`@oxy.so/core/host`), the host wins and this
186
+ * is ignored. Read once, at mount.
187
+ */
188
+ authStateStore?: AuthStateStore;
166
189
  }
167
190
  export interface OxyLanguageConfig {
168
191
  /** Previous app-owned storage keys, migrated once without replacing a current SDK choice. */
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/ui/types/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KA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;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,kEAAkE;IAClE,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD"}
@@ -55,6 +55,10 @@ export declare const loadIdentityCrypto: () => Promise<{
55
55
  retiredKeyFromPhrase: typeof import("@oxy.so/core/crypto").retiredKeyFromPhrase;
56
56
  retiredKeyFromPrivateKey: typeof import("@oxy.so/core/crypto").retiredKeyFromPrivateKey;
57
57
  exportRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").exportRetiredIdentityKeys;
58
+ claimRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").claimRetiredIdentityKeys;
59
+ countQuarantinedRetiredKeys: typeof import("@oxy.so/core/crypto").countQuarantinedRetiredKeys;
60
+ unmirrorPersonalRetiredKeys: typeof import("@oxy.so/core/crypto").unmirrorPersonalRetiredKeys;
61
+ RetiredKeyRingUnreadableError: typeof import("@oxy.so/core/crypto").RetiredKeyRingUnreadableError;
58
62
  SignatureService: typeof import("@oxy.so/core/crypto").SignatureService;
59
63
  RecoveryPhraseService: typeof import("@oxy.so/core/crypto").RecoveryPhraseService;
60
64
  BACKUP_KDF_ENCRYPTION_INFO: "oxy-backup-encryption-key";
@@ -1 +1 @@
1
- {"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
1
+ {"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/services",
3
- "version": "14.10.1",
3
+ "version": "14.11.0",
4
4
  "description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -183,7 +183,7 @@
183
183
  "devDependencies": {
184
184
  "@expo/app-integrity": "~58.0.2",
185
185
  "@expo/vector-icons": "^15.1.1",
186
- "@oxy.so/core": "7.32.0",
186
+ "@oxy.so/core": "7.34.0",
187
187
  "@react-native-async-storage/async-storage": "^3.1.1",
188
188
  "@react-native-community/netinfo": "^12.0.1",
189
189
  "@react-native/babel-preset": "^0.88.1",
@@ -230,13 +230,13 @@
230
230
  "expo-video": "~58.0.13"
231
231
  },
232
232
  "//@oxy.so/bloom": "Bloom 11.1.0 adds the shared grouped sections, usage card, subscription plans, frame appearance and overlay navigation APIs used by this SDK. First-party Bloom peers remain open above this tested minimum.",
233
- "//@oxy.so/core": "Core 7.13.0 supplies the `usernamePolicy.*`, `actionErrors.*` and `signin.errors.{network,invalidInput,server}` strings every username field and failure toast is worded with; 7.9.1 fences ordinary authenticated HTTP requests across session changes during auth preflight, which organization claim and creation require; 7.9.0 supplies `deviceComparisonCode`, the short code `OxyDeviceSignIn` prints; 7.8.0 supplies the device sign-in request's `approvalUrl` and the `signin.device.*` strings `OxyDeviceSignIn` shows; 7.7.0 supplies the bounded native asset file adapter and phase progress installed by OxyProvider; 7.6.0 forwards guest locale and first-touch campaign metadata through signup; 7.3.0 supplies `users.lookupMany`, with which the account members screen fails (and retries) a profile read whose chunk failed instead of caching those members as handle-less; 7.2.0 supplies `assets.cachedUrl`, with which `useFileDownloadUrl` answers an already-resolved URL in its first render; 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
233
+ "//@oxy.so/core": "Core 7.34.0 supplies `@oxy.so/core/host` (the session host contract, ADR 0058), `createUserEventSocket` and `session.sessionId`, which the provider's host mode is built on; 7.13.0 supplies the `usernamePolicy.*`, `actionErrors.*` and `signin.errors.{network,invalidInput,server}` strings every username field and failure toast is worded with; 7.9.1 fences ordinary authenticated HTTP requests across session changes during auth preflight, which organization claim and creation require; 7.9.0 supplies `deviceComparisonCode`, the short code `OxyDeviceSignIn` prints; 7.8.0 supplies the device sign-in request's `approvalUrl` and the `signin.device.*` strings `OxyDeviceSignIn` shows; 7.7.0 supplies the bounded native asset file adapter and phase progress installed by OxyProvider; 7.6.0 forwards guest locale and first-touch campaign metadata through signup; 7.3.0 supplies `users.lookupMany`, with which the account members screen fails (and retries) a profile read whose chunk failed instead of caching those members as handle-less; 7.2.0 supplies `assets.cachedUrl`, with which `useFileDownloadUrl` answers an already-resolved URL in its first render; 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
234
234
  "//react-native": "React Native 0.81 to 0.88, React 19.1+ and Expo SDK 54 to 58. The floors are the Expo SDK 54 stack (react-native 0.81.6, react 19.1.4, react-native-web 0.21.4, expo 54.0.38 and the module versions its bundledNativeModules.json pins), which compat/expo-54 installs as an external consumer and checks on every CI run (`bun check.mjs`): every peer here admits that stack, services' published src typechecks against its types, and <OxyProvider> mounts and settles its cold boot on iOS (React Native 0.81), web (react-native-web 0.21) and react-native-macos 0.81 with the native modules macOS lacks absent. Astro, Oxy's browser, runs react-native-macos 0.81 (0.83 is its latest release), which is why the floor is not 0.85. The SDK 56 floors these replaced were the versions current when the ranges were first written, not measurements.",
235
235
  "peerDependencies": {
236
236
  "@expo/app-integrity": ">=0.1.10 <59.0.0",
237
237
  "@expo/vector-icons": "^15.0.3",
238
238
  "@oxy.so/bloom": ">=11.1.0",
239
- "@oxy.so/core": "^7.32.0",
239
+ "@oxy.so/core": "^7.34.0",
240
240
  "@react-native-async-storage/async-storage": ">=2.0.0 <4.0.0",
241
241
  "@react-native-community/netinfo": ">=11.4.1 <13.0.0",
242
242
  "@tanstack/query-async-storage-persister": "^5.101",
package/src/index.ts CHANGED
@@ -81,6 +81,9 @@ export type { OxyProductEvent, ProductAnalytics } from './ui/analytics/productAn
81
81
  // `sessionMode="identity"` — an identity-bound app authenticates as the owner of
82
82
  // the local identity key and cannot switch accounts.
83
83
  export { IdentityBoundSessionError } from './ui/session/identityBinding';
84
+ // Thrown by an operation that a platform holding the session (a session host,
85
+ // ADR 0058) does itself: a sign-in this app would commit, device management.
86
+ export { HostedSessionError } from './ui/session/hostSession';
84
87
 
85
88
  // ---------------------------------------------------------------------------
86
89
  // Zustand stores
@@ -107,6 +107,12 @@ export interface RunProviderColdBootOptions {
107
107
  sessionMode?: SessionMode;
108
108
  /** The identity binding required by `sessionMode: 'identity'`. */
109
109
  identity?: IdentityBinding;
110
+ /**
111
+ * `false` keeps the device-wide shared credential slot out of this boot (no
112
+ * adopt, no publish): the provider was given a platform's own store
113
+ * (`OxyProviderProps.authStateStore`). Default `true`.
114
+ */
115
+ useSharedDeviceCredential?: boolean;
110
116
  sessionClient: SessionClient;
111
117
  /** Provider-owned fresh classifier, also used by explicit action recovery. */
112
118
  resolveSessionLane?: () => Promise<'device' | 'oauth'>;
@@ -204,7 +210,12 @@ async function restoreDeviceSession(
204
210
  // instead of falling back to signing a challenge with the Commons identity
205
211
  // key. `null` on web, where each origin is its own device by design; the
206
212
  // core lane is also skipped outright in `sessionMode: 'identity'`.
207
- sharedDeviceCredential: createPlatformSharedDeviceCredentialStore() ?? undefined,
213
+ // Off when the provider was given a platform's own store: the credential
214
+ // then lives there and nowhere else.
215
+ sharedDeviceCredential:
216
+ opts.useSharedDeviceCredential === false
217
+ ? undefined
218
+ : (createPlatformSharedDeviceCredentialStore() ?? undefined),
208
219
  overallDeadlineMs: COLD_BOOT_OVERALL_DEADLINE_MS,
209
220
  isOffline: () => offline,
210
221
  requireServerVerdict: painted,
@@ -4,6 +4,8 @@ import { AppState, Platform, StyleSheet } from 'react-native';
4
4
  import { GestureHandlerRootView } from 'react-native-gesture-handler';
5
5
  import type { OxyProviderProps } from '../types/navigation';
6
6
  import { OxyRuntimeProvider, type OxyRuntimeProviderProps } from '../context/OxyContext';
7
+ import { OxyHostedRuntimeProvider } from '../context/OxyHostedContext';
8
+ import { getOxySessionHost } from '@oxy.so/core/host';
7
9
  import { QueryClientProvider, focusManager, onlineManager } from '@tanstack/react-query';
8
10
  import { SurfaceProvider } from '@oxy.so/bloom/surfaces';
9
11
  import { ToastOutlet } from '@oxy.so/bloom/toast';
@@ -105,7 +107,20 @@ const OxyProvider: FC<OxyProviderProps> = ({
105
107
  backgroundSession = false,
106
108
  language,
107
109
  campaignAttribution = false,
110
+ authStateStore,
108
111
  }) => {
112
+ // A platform that holds the Oxy session (ADR 0058) registers its host before
113
+ // the app's code runs. Read once, like `baseURL`: a host registered later
114
+ // does not re-bind a mounted provider. `'identity'` is never hosted.
115
+ const [sessionHost] = useState(() => (sessionMode === 'account' ? getOxySessionHost() : null));
116
+ useEffect(() => {
117
+ if (__DEV__ && sessionHost && authStateStore) {
118
+ loggerUtil.warn(
119
+ 'OxyProvider: authStateStore is ignored — a platform holds the session here (session host)',
120
+ { component: 'OxyProvider' },
121
+ );
122
+ }
123
+ }, [sessionHost, authStateStore]);
109
124
  const support = useMemo(
110
125
  () => ({ onAskAlia, documentationUrl, aliaAvatar, oxyOneArtwork }),
111
126
  [onAskAlia, documentationUrl, aliaAvatar, oxyOneArtwork],
@@ -253,42 +268,70 @@ const OxyProvider: FC<OxyProviderProps> = ({
253
268
  // duplicate scope that silently shadows the consumer's configuration.
254
269
  // It DOES set Bloom's locale (`BloomLocaleBridge`) to Oxy's language, but
255
270
  // defers to a locale the app already set above it.
271
+ const providerChildren = (
272
+ <>
273
+ <SupervisionStateObserver />
274
+ {productAnalytics ? <ProductAnalyticsObserver analytics={productAnalytics} /> : null}
275
+ <AccountLanguageBoundary language={language}>
276
+ <BloomLocaleBridge>
277
+ <OxySupportContext.Provider value={support}>
278
+ <SurfaceProvider>
279
+ {requireAuth === 'off' ? (
280
+ children
281
+ ) : (
282
+ <RequireOxyAuth prompt={requireAuth}>{children}</RequireOxyAuth>
283
+ )}
284
+ </SurfaceProvider>
285
+ </OxySupportContext.Provider>
286
+ <ToastOutlet />
287
+ </BloomLocaleBridge>
288
+ </AccountLanguageBoundary>
289
+ </>
290
+ );
291
+
256
292
  const coreContent = (
257
293
  <QueryClientProvider client={queryClient}>
258
- <OxyRuntimeProvider
259
- oxyServices={oxyServices as OxyRuntimeProviderProps['oxyServices']}
260
- baseURL={baseURL}
261
- authWebUrl={authWebUrl}
262
- authRedirectUri={authRedirectUri}
263
- authorizeBaseUrl={authorizeBaseUrl}
264
- storageKeyPrefix={storageKeyPrefix}
265
- clientId={clientId}
266
- sessionMode={sessionMode}
267
- webAuthMode={webAuthMode}
268
- backgroundSession={backgroundSession}
269
- legacyLanguageKeys={language?.legacyStorageKeys}
270
- captureCampaignAttribution={campaignAttribution}
271
- platformStorage={platformStorage}
272
- accountQueries={accountQueries}
273
- onAuthStateChange={onAuthStateChange as OxyRuntimeProviderProps['onAuthStateChange']}
274
- >
275
- <SupervisionStateObserver />
276
- {productAnalytics ? <ProductAnalyticsObserver analytics={productAnalytics} /> : null}
277
- <AccountLanguageBoundary language={language}>
278
- <BloomLocaleBridge>
279
- <OxySupportContext.Provider value={support}>
280
- <SurfaceProvider>
281
- {requireAuth === 'off' ? (
282
- children
283
- ) : (
284
- <RequireOxyAuth prompt={requireAuth}>{children}</RequireOxyAuth>
285
- )}
286
- </SurfaceProvider>
287
- </OxySupportContext.Provider>
288
- <ToastOutlet />
289
- </BloomLocaleBridge>
290
- </AccountLanguageBoundary>
291
- </OxyRuntimeProvider>
294
+ {sessionHost ? (
295
+ <OxyHostedRuntimeProvider
296
+ session={sessionHost}
297
+ oxyServices={oxyServices as OxyRuntimeProviderProps['oxyServices']}
298
+ baseURL={baseURL}
299
+ authWebUrl={authWebUrl}
300
+ authRedirectUri={authRedirectUri}
301
+ authorizeBaseUrl={authorizeBaseUrl}
302
+ storageKeyPrefix={storageKeyPrefix}
303
+ clientId={clientId}
304
+ webAuthMode={webAuthMode}
305
+ legacyLanguageKeys={language?.legacyStorageKeys}
306
+ captureCampaignAttribution={campaignAttribution}
307
+ platformStorage={platformStorage}
308
+ accountQueries={accountQueries}
309
+ onAuthStateChange={onAuthStateChange as OxyRuntimeProviderProps['onAuthStateChange']}
310
+ >
311
+ {providerChildren}
312
+ </OxyHostedRuntimeProvider>
313
+ ) : (
314
+ <OxyRuntimeProvider
315
+ oxyServices={oxyServices as OxyRuntimeProviderProps['oxyServices']}
316
+ baseURL={baseURL}
317
+ authWebUrl={authWebUrl}
318
+ authRedirectUri={authRedirectUri}
319
+ authorizeBaseUrl={authorizeBaseUrl}
320
+ storageKeyPrefix={storageKeyPrefix}
321
+ clientId={clientId}
322
+ sessionMode={sessionMode}
323
+ webAuthMode={webAuthMode}
324
+ backgroundSession={backgroundSession}
325
+ legacyLanguageKeys={language?.legacyStorageKeys}
326
+ captureCampaignAttribution={campaignAttribution}
327
+ platformStorage={platformStorage}
328
+ accountQueries={accountQueries}
329
+ authStateStore={authStateStore}
330
+ onAuthStateChange={onAuthStateChange as OxyRuntimeProviderProps['onAuthStateChange']}
331
+ >
332
+ {providerChildren}
333
+ </OxyRuntimeProvider>
334
+ )}
292
335
  </QueryClientProvider>
293
336
  );
294
337
 
@@ -168,6 +168,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
168
168
  captureCampaignAttribution = false,
169
169
  platformStorage,
170
170
  accountQueries,
171
+ authStateStore: providedAuthStateStore,
171
172
  onAuthStateChange,
172
173
  onError,
173
174
  }) => {
@@ -200,11 +201,19 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
200
201
  // web; SecureStore session blob on native). Built ONCE per provider mount.
201
202
  // Tracked, so a sign-in press can tell SYNCHRONOUSLY whether this origin
202
203
  // holds a device credential (the browser bridge must open inside the press).
204
+ //
205
+ // A platform's setup client passes its own (`authStateStore`): then it is the
206
+ // ONLY place a credential is written — the shared device slot and the
207
+ // background credential below are off, so nothing reaches platform storage.
203
208
  const authStoreRef = useRef<CredentialTrackingAuthStateStore | null>(null);
209
+ const ownsCredentialStorageRef = useRef(providedAuthStateStore === undefined);
204
210
  if (!authStoreRef.current) {
205
- authStoreRef.current = trackDeviceCredential(createPlatformAuthStateStore({ sessionMode }));
211
+ authStoreRef.current = trackDeviceCredential(
212
+ providedAuthStateStore ?? createPlatformAuthStateStore({ sessionMode }),
213
+ );
206
214
  }
207
215
  const authStore: AuthStateStore = authStoreRef.current;
216
+ const usesSharedDeviceCredential = ownsCredentialStorageRef.current;
208
217
 
209
218
  // Identity-bound session binding (`sessionMode: 'identity'`) — the platform pin
210
219
  // store plus the memoised pinned account id every lane below binds to. Built
@@ -791,7 +800,9 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
791
800
  ...(!identity && !isWebBrowser()
792
801
  ? {
793
802
  allowCommonsIdentityFallback: false,
794
- sharedDeviceCredential: createPlatformSharedDeviceCredentialStore() ?? undefined,
803
+ sharedDeviceCredential: usesSharedDeviceCredential
804
+ ? (createPlatformSharedDeviceCredentialStore() ?? undefined)
805
+ : undefined,
795
806
  }
796
807
  : {}),
797
808
  });
@@ -806,7 +817,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
806
817
  scheduler.dispose();
807
818
  oxyServices.http.setAuthRefreshHandler(null);
808
819
  };
809
- }, [oxyServices, authStore, identity, runtime]);
820
+ }, [oxyServices, authStore, identity, runtime, usesSharedDeviceCredential]);
810
821
 
811
822
  // ── Session commit funnel ────────────────────────────────────────────────
812
823
  // The single place a session becomes committed: plant tokens, persist the
@@ -1473,6 +1484,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
1473
1484
  authRedirectUri,
1474
1485
  sessionMode,
1475
1486
  identity: identity?.binding,
1487
+ useSharedDeviceCredential: usesSharedDeviceCredential,
1476
1488
  resolveSessionLane: resolveRegisteredLane,
1477
1489
  beforeDeviceBoot: identity
1478
1490
  ? async () => {
@@ -1504,6 +1516,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
1504
1516
  authRedirectUri,
1505
1517
  sessionMode,
1506
1518
  identity,
1519
+ usesSharedDeviceCredential,
1507
1520
  syncDeviceCredentialToHost,
1508
1521
  sessionClient,
1509
1522
  setTokenReady,
@@ -1760,7 +1773,9 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
1760
1773
  // needs a bearer, and keyed on the signed-in account so a sign-out or an
1761
1774
  // account switch revokes the credential before anything else happens.
1762
1775
  useBackgroundSessionSync({
1763
- enabled: backgroundSession,
1776
+ // A platform's own store (`authStateStore`) means no credential of ours
1777
+ // anywhere else, the background one included.
1778
+ enabled: backgroundSession && usesSharedDeviceCredential,
1764
1779
  oxyServices,
1765
1780
  userId: user?.id ?? null,
1766
1781
  canUsePrivateApi,