@oxy.so/services 1.0.3 → 1.1.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 (42) hide show
  1. package/lib/commonjs/index.js.map +1 -1
  2. package/lib/commonjs/ui/components/LanguageBridge.js +51 -0
  3. package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -0
  4. package/lib/commonjs/ui/components/OxyConsentScreen.js +132 -2
  5. package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -1
  6. package/lib/commonjs/ui/components/OxyProvider.js +19 -1
  7. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/module/ui/components/LanguageBridge.js +47 -0
  10. package/lib/module/ui/components/LanguageBridge.js.map +1 -0
  11. package/lib/module/ui/components/OxyConsentScreen.js +132 -2
  12. package/lib/module/ui/components/OxyConsentScreen.js.map +1 -1
  13. package/lib/module/ui/components/OxyProvider.js +19 -1
  14. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  15. package/lib/typescript/commonjs/index.d.ts +1 -1
  16. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  17. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts +19 -0
  18. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -0
  19. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts +17 -1
  20. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts +14 -0
  22. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/ui/types/navigation.d.ts +29 -0
  24. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  25. package/lib/typescript/module/index.d.ts +1 -1
  26. package/lib/typescript/module/index.d.ts.map +1 -1
  27. package/lib/typescript/module/ui/components/LanguageBridge.d.ts +19 -0
  28. package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -0
  29. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts +17 -1
  30. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts.map +1 -1
  31. package/lib/typescript/module/ui/components/OxyProvider.d.ts +14 -0
  32. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  33. package/lib/typescript/module/ui/types/navigation.d.ts +29 -0
  34. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  35. package/package.json +5 -4
  36. package/src/index.ts +1 -0
  37. package/src/ui/components/LanguageBridge.tsx +44 -0
  38. package/src/ui/components/OxyConsentScreen.tsx +127 -0
  39. package/src/ui/components/OxyProvider.tsx +17 -0
  40. package/src/ui/components/__tests__/LanguageBridge.test.tsx +81 -0
  41. package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +32 -0
  42. package/src/ui/types/navigation.ts +30 -0
@@ -1,3 +1,4 @@
1
+ import type { McpOAuthWriteAction } from '@oxy.so/contracts';
1
2
  /** The requesting application, resolved by the caller (never user-supplied raw). */
2
3
  export interface OxyConsentApplication {
3
4
  /** Display name of the requesting application. */
@@ -17,6 +18,8 @@ export interface OxyConsentApplication {
17
18
  }
18
19
  /** The account that will authorize the request (the currently signed-in user). */
19
20
  export interface OxyConsentUser {
21
+ /** Exact effective account bound to the grant. */
22
+ accountId?: string;
20
23
  /** Real display name, when the profile has one. */
21
24
  displayName?: string;
22
25
  /** Normalized handle — the sanctioned fallback when `displayName` is absent. */
@@ -24,6 +27,17 @@ export interface OxyConsentUser {
24
27
  /** Avatar — a URL or bare file id passed straight to `<Avatar source>`. */
25
28
  avatarUri?: string;
26
29
  }
30
+ export interface OxyConsentResource {
31
+ /** Oxy application that owns the protected MCP resource. */
32
+ application: {
33
+ name: string;
34
+ iconUrl?: string;
35
+ };
36
+ /** Canonical protected-resource URI bound into the access token. */
37
+ uri: string;
38
+ /** Effectful tools enabled by the requested capabilities. */
39
+ writeActions: McpOAuthWriteAction[];
40
+ }
27
41
  export interface OxyConsentScreenProps {
28
42
  /** The resolved requesting application. */
29
43
  application: OxyConsentApplication;
@@ -31,6 +45,8 @@ export interface OxyConsentScreenProps {
31
45
  scopes: string[];
32
46
  /** The account that will authorize the request, when known. */
33
47
  user?: OxyConsentUser;
48
+ /** Exact protected resource for an external MCP connection. */
49
+ resource?: OxyConsentResource;
34
50
  /** Approve handler — the caller mints the code / completes the flow. */
35
51
  onAllow: () => void | Promise<void>;
36
52
  /** Deny handler — the caller cancels the flow. */
@@ -40,6 +56,6 @@ export interface OxyConsentScreenProps {
40
56
  /** A blocking error message for the request, when present. */
41
57
  error?: string | null;
42
58
  }
43
- export declare function OxyConsentScreen({ application, scopes, user, onAllow, onDeny, busy, error, }: OxyConsentScreenProps): import("react").JSX.Element;
59
+ export declare function OxyConsentScreen({ application, scopes, user, resource, onAllow, onDeny, busy, error, }: OxyConsentScreenProps): import("react").JSX.Element;
44
60
  export default OxyConsentScreen;
45
61
  //# sourceMappingURL=OxyConsentScreen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OxyConsentScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/OxyConsentScreen.tsx"],"names":[],"mappings":"AA8BA,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,WAAW,EAAE,qBAAqB,CAAC;IACnC,wEAAwE;IACxE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,wEAAwE;IACxE,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,kDAAkD;IAClD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iFAAiF;IACjF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAqHD,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,MAAM,EACN,IAAI,EACJ,OAAO,EACP,MAAM,EACN,IAAY,EACZ,KAAY,GACb,EAAE,qBAAqB,+BA6KvB;AAoID,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"OxyConsentScreen.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/OxyConsentScreen.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQ7D,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,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';
34
34
  * return <Text>Welcome, {user?.username}!</Text>;
35
35
  * }
36
36
  * ```
37
+ *
38
+ * An app with its own translated UI passes a language config to follow the account's
39
+ * (or, signed out, the device/guest) resolved locale automatically — see ADR
40
+ * 0022 (`docs/adr/0022-app-i18n-follows-oxy-language.md`):
41
+ * ```tsx
42
+ * <OxyProvider
43
+ * baseURL="https://api.oxy.so"
44
+ * language={{
45
+ * supportedLocales: SUPPORTED_LANGUAGES, // this app's own catalog
46
+ * fallbackLocale: DEFAULT_LANGUAGE,
47
+ * onChange: (locale) => i18n.changeLanguage(locale),
48
+ * }}
49
+ * >
50
+ * ```
37
51
  */
38
52
  declare const OxyProvider: FC<OxyProviderProps>;
39
53
  export default OxyProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"OxyProvider.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/OxyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAqB,CAAC;AAsB5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA+LrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"OxyProvider.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/OxyProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAqB,CAAC;AAuB5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAiMrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -152,5 +152,34 @@ export interface OxyProviderProps {
152
152
  * @default 'persistent'
153
153
  */
154
154
  deviceCredentialStorage?: 'persistent' | 'ephemeral';
155
+ /**
156
+ * Wires the app's OWN i18n library to Oxy's resolved language, so the
157
+ * account (or, signed out, the device/guest locale) drives the app's
158
+ * translated UI directly — no app-local effect or "sync" component to
159
+ * remember to mount. Oxy decides WHICH language; the app keeps owning its
160
+ * own translation catalogs and library (i18next, FormatJS, or anything
161
+ * else) and is told through `onChange` when to switch.
162
+ *
163
+ * Omitted entirely (the default) when an app has no i18n of its own, or
164
+ * manages it independently of the account/device locale.
165
+ */
166
+ language?: OxyLanguageConfig;
167
+ }
168
+ export interface OxyLanguageConfig {
169
+ /** The exact locales this app ships a translation catalog for. */
170
+ supportedLocales: readonly string[];
171
+ /**
172
+ * Used when Oxy's resolved language matches none of `supportedLocales`,
173
+ * not even by base language (Oxy's account-locale catalog is broader
174
+ * than any one app's translations).
175
+ */
176
+ fallbackLocale: string;
177
+ /**
178
+ * Called whenever the resolved locale changes, coerced to the closest
179
+ * one in `supportedLocales`. May return a promise; a rejection is
180
+ * reported to `onError` instead of throwing into the app tree.
181
+ */
182
+ onChange: (locale: string) => void | Promise<void>;
183
+ onError?: (error: unknown, locale: string) => void;
155
184
  }
156
185
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/ui/types/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAA+B,CAAC;AAEtE,MAAM,WA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E,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/services",
3
- "version": "1.0.3",
3
+ "version": "1.1.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",
@@ -154,7 +154,8 @@
154
154
  }
155
155
  },
156
156
  "dependencies": {
157
- "@oxy.so/contracts": "1.0.1",
157
+ "@expo/config-plugins": "57.0.9",
158
+ "@oxy.so/contracts": "1.1.1",
158
159
  "@simplewebauthn/browser": "^13.3.0",
159
160
  "color": "^4.2.3"
160
161
  },
@@ -163,7 +164,7 @@
163
164
  "@commitlint/cli": "^21.2.1",
164
165
  "@commitlint/config-conventional": "^21.2.0",
165
166
  "@expo/vector-icons": "^15.0.3",
166
- "@oxy.so/core": "1.0.1",
167
+ "@oxy.so/core": "1.2.0",
167
168
  "@react-native-async-storage/async-storage": "^2.0.0",
168
169
  "@react-native-community/netinfo": "^12.0.1",
169
170
  "@react-native/babel-preset": "^0.86.2",
@@ -178,7 +179,7 @@
178
179
  "@types/jest": "^30.0.0",
179
180
  "@types/node": "^20.19.43",
180
181
  "@types/react": "*",
181
- "@oxy.so/bloom": "^1.0.0",
182
+ "@oxy.so/bloom": "^1.0.7",
182
183
  "copyfiles": "^2.4.1",
183
184
  "expo-constants": "~57.0.5",
184
185
  "expo-file-system": "~57.0.1",
package/src/index.ts CHANGED
@@ -296,6 +296,7 @@ export type {
296
296
  OxyConsentScreenProps,
297
297
  OxyConsentApplication,
298
298
  OxyConsentUser,
299
+ OxyConsentResource,
299
300
  } from './ui/components/OxyConsentScreen';
300
301
 
301
302
  // Optional signed-out gate primitive. Wrap any subtree (or the whole app via
@@ -0,0 +1,44 @@
1
+ import { useEffect, useMemo, useRef } from 'react';
2
+ import { coerceToSupportedLocale } from '@oxy.so/core';
3
+ import { useOxy } from '../context/OxyContext';
4
+ import type { OxyLanguageConfig } from '../types/navigation';
5
+
6
+ /**
7
+ * `OxyProvider`'s language config prop, realized. Oxy decides which
8
+ * language an account (or, signed out, the device/guest locale) should see;
9
+ * this is the ONE place that decision reaches the host app's own i18n library
10
+ * — so an app never re-derives or imperatively tracks a language of its own,
11
+ * and never mounts anything extra to get it. It owns only its translation
12
+ * catalogs.
13
+ *
14
+ * `currentLanguage` may name a locale the host app never shipped a catalog
15
+ * for — {@link coerceToSupportedLocale} narrows it to the closest one the app
16
+ * actually has (exact match, then same base language, then `fallbackLocale`).
17
+ *
18
+ * Renders nothing. Mounted by `OxyProvider` INSIDE `OxyRuntimeProvider` only
19
+ * when this config is supplied, so an app with no i18n of its own pays
20
+ * nothing.
21
+ */
22
+ export function LanguageBridge({ supportedLocales, fallbackLocale, onChange, onError }: OxyLanguageConfig): null {
23
+ const { currentLanguage } = useOxy();
24
+ const resolvedLocale = useMemo(
25
+ () => coerceToSupportedLocale(currentLanguage, supportedLocales, fallbackLocale),
26
+ [currentLanguage, supportedLocales, fallbackLocale],
27
+ );
28
+
29
+ // Refs, not effect dependencies: an inline `onChange`/`onError` (the common
30
+ // case) must not re-fire the effect on every render — only a genuine
31
+ // change in the RESOLVED locale should call it again.
32
+ const onChangeRef = useRef(onChange);
33
+ onChangeRef.current = onChange;
34
+ const onErrorRef = useRef(onError);
35
+ onErrorRef.current = onError;
36
+
37
+ useEffect(() => {
38
+ Promise.resolve(onChangeRef.current(resolvedLocale)).catch((error: unknown) => {
39
+ onErrorRef.current?.(error, resolvedLocale);
40
+ });
41
+ }, [resolvedLocale]);
42
+
43
+ return null;
44
+ }
@@ -21,6 +21,7 @@
21
21
  import { useCallback } from 'react';
22
22
  import { Linking, Pressable, ScrollView, StyleSheet, View } from 'react-native';
23
23
  import { logger } from '@oxy.so/core';
24
+ import type { McpOAuthWriteAction } from '@oxy.so/contracts';
24
25
  import { Avatar } from '@oxy.so/bloom/avatar';
25
26
  import { Button } from '@oxy.so/bloom/button';
26
27
  import { Text } from '@oxy.so/bloom/typography';
@@ -48,6 +49,8 @@ export interface OxyConsentApplication {
48
49
 
49
50
  /** The account that will authorize the request (the currently signed-in user). */
50
51
  export interface OxyConsentUser {
52
+ /** Exact effective account bound to the grant. */
53
+ accountId?: string;
51
54
  /** Real display name, when the profile has one. */
52
55
  displayName?: string;
53
56
  /** Normalized handle — the sanctioned fallback when `displayName` is absent. */
@@ -56,6 +59,18 @@ export interface OxyConsentUser {
56
59
  avatarUri?: string;
57
60
  }
58
61
 
62
+ export interface OxyConsentResource {
63
+ /** Oxy application that owns the protected MCP resource. */
64
+ application: {
65
+ name: string;
66
+ iconUrl?: string;
67
+ };
68
+ /** Canonical protected-resource URI bound into the access token. */
69
+ uri: string;
70
+ /** Effectful tools enabled by the requested capabilities. */
71
+ writeActions: McpOAuthWriteAction[];
72
+ }
73
+
59
74
  export interface OxyConsentScreenProps {
60
75
  /** The resolved requesting application. */
61
76
  application: OxyConsentApplication;
@@ -63,6 +78,8 @@ export interface OxyConsentScreenProps {
63
78
  scopes: string[];
64
79
  /** The account that will authorize the request, when known. */
65
80
  user?: OxyConsentUser;
81
+ /** Exact protected resource for an external MCP connection. */
82
+ resource?: OxyConsentResource;
66
83
  /** Approve handler — the caller mints the code / completes the flow. */
67
84
  onAllow: () => void | Promise<void>;
68
85
  /** Deny handler — the caller cancels the flow. */
@@ -192,6 +209,7 @@ export function OxyConsentScreen({
192
209
  application,
193
210
  scopes,
194
211
  user,
212
+ resource,
195
213
  onAllow,
196
214
  onDeny,
197
215
  busy = false,
@@ -259,6 +277,40 @@ export function OxyConsentScreen({
259
277
  ) : null}
260
278
  </View>
261
279
 
280
+ {resource ? (
281
+ <View style={styles.section}>
282
+ <Text style={[styles.sectionLabel, { color: theme.colors.textSecondary }]}>
283
+ {t('consent.resource.title')}
284
+ </Text>
285
+ <View
286
+ testID="consent-resource"
287
+ style={[styles.resourceCard, { borderColor: theme.colors.border, backgroundColor: theme.colors.card }]}
288
+ >
289
+ <Avatar
290
+ source={resource.application.iconUrl}
291
+ name={resource.application.name}
292
+ size={40}
293
+ />
294
+ <View style={styles.resourceText}>
295
+ <Text
296
+ testID="consent-resource-app"
297
+ numberOfLines={1}
298
+ style={[styles.accountName, { color: theme.colors.text }]}
299
+ >
300
+ {resource.application.name}
301
+ </Text>
302
+ <Text
303
+ testID="consent-resource-uri"
304
+ numberOfLines={2}
305
+ style={[styles.resourceUri, { color: theme.colors.textSecondary }]}
306
+ >
307
+ {resource.uri}
308
+ </Text>
309
+ </View>
310
+ </View>
311
+ </View>
312
+ ) : null}
313
+
262
314
  {/* Requested permissions */}
263
315
  <View style={styles.section}>
264
316
  <Text style={[styles.sectionLabel, { color: theme.colors.textSecondary }]}>
@@ -285,6 +337,29 @@ export function OxyConsentScreen({
285
337
  </View>
286
338
  </View>
287
339
 
340
+ {resource && resource.writeActions.length > 0 ? (
341
+ <View style={styles.section}>
342
+ <Text style={[styles.sectionLabel, { color: theme.colors.textSecondary }]}>
343
+ {t('consent.writeActions.title')}
344
+ </Text>
345
+ <View style={[styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.card }]}>
346
+ {resource.writeActions.map((action) => (
347
+ <View key={`${action.name}:${action.version}`} testID={`consent-write-action-${action.name}`} style={styles.actionRow}>
348
+ <View style={styles.actionCopy}>
349
+ <Text style={[styles.rowText, { color: theme.colors.text }]}>{action.description}</Text>
350
+ <Text style={[styles.actionName, { color: theme.colors.textSecondary }]}>{action.name}</Text>
351
+ </View>
352
+ <View style={[styles.effectBadge, { borderColor: theme.colors.border }]}>
353
+ <Text style={[styles.effectText, { color: theme.colors.textSecondary }]}>
354
+ {t(`consent.effects.${action.effect}`)}
355
+ </Text>
356
+ </View>
357
+ </View>
358
+ ))}
359
+ </View>
360
+ </View>
361
+ ) : null}
362
+
288
363
  {/* Authorizing account */}
289
364
  {user ? (
290
365
  <View
@@ -305,6 +380,15 @@ export function OxyConsentScreen({
305
380
  {user.handle}
306
381
  </Text>
307
382
  ) : null}
383
+ {user.accountId ? (
384
+ <Text
385
+ testID="consent-account-id"
386
+ numberOfLines={1}
387
+ style={[styles.accountId, { color: theme.colors.textSecondary }]}
388
+ >
389
+ {t('consent.account.id', { id: user.accountId })}
390
+ </Text>
391
+ ) : null}
308
392
  </View>
309
393
  </View>
310
394
  ) : null}
@@ -466,6 +550,49 @@ const styles = StyleSheet.create({
466
550
  accountHandle: {
467
551
  fontSize: 13,
468
552
  },
553
+ accountId: {
554
+ fontSize: 11,
555
+ },
556
+ resourceCard: {
557
+ flexDirection: 'row',
558
+ alignItems: 'center',
559
+ gap: 12,
560
+ borderWidth: StyleSheet.hairlineWidth,
561
+ borderRadius: 16,
562
+ padding: 12,
563
+ },
564
+ resourceText: {
565
+ flex: 1,
566
+ minWidth: 0,
567
+ gap: 2,
568
+ },
569
+ resourceUri: {
570
+ fontSize: 12,
571
+ lineHeight: 17,
572
+ },
573
+ actionRow: {
574
+ flexDirection: 'row',
575
+ alignItems: 'center',
576
+ gap: 10,
577
+ },
578
+ actionCopy: {
579
+ flex: 1,
580
+ minWidth: 0,
581
+ gap: 2,
582
+ },
583
+ actionName: {
584
+ fontSize: 11,
585
+ },
586
+ effectBadge: {
587
+ borderWidth: StyleSheet.hairlineWidth,
588
+ borderRadius: 999,
589
+ paddingHorizontal: 8,
590
+ paddingVertical: 4,
591
+ },
592
+ effectText: {
593
+ fontSize: 10,
594
+ fontWeight: '600',
595
+ },
469
596
  linksRow: {
470
597
  flexDirection: 'row',
471
598
  flexWrap: 'wrap',
@@ -14,6 +14,7 @@ import { createMemoryStorage, createPlatformStorage, type StorageInterface } fro
14
14
  import { isNetConnectivityOnline } from '../utils/netConnectivity';
15
15
  import { KeyboardBoundary } from './KeyboardBoundary';
16
16
  import { ProductAnalyticsObserver } from '../analytics/productAnalytics';
17
+ import { LanguageBridge } from './LanguageBridge';
17
18
 
18
19
  const bootStyles = StyleSheet.create({
19
20
  providerRoot: {
@@ -58,6 +59,20 @@ const isWeb = Platform.OS === 'web';
58
59
  * return <Text>Welcome, {user?.username}!</Text>;
59
60
  * }
60
61
  * ```
62
+ *
63
+ * An app with its own translated UI passes a language config to follow the account's
64
+ * (or, signed out, the device/guest) resolved locale automatically — see ADR
65
+ * 0022 (`docs/adr/0022-app-i18n-follows-oxy-language.md`):
66
+ * ```tsx
67
+ * <OxyProvider
68
+ * baseURL="https://api.oxy.so"
69
+ * language={{
70
+ * supportedLocales: SUPPORTED_LANGUAGES, // this app's own catalog
71
+ * fallbackLocale: DEFAULT_LANGUAGE,
72
+ * onChange: (locale) => i18n.changeLanguage(locale),
73
+ * }}
74
+ * >
75
+ * ```
61
76
  */
62
77
  const OxyProvider: FC<OxyProviderProps> = ({
63
78
  oxyServices,
@@ -76,6 +91,7 @@ const OxyProvider: FC<OxyProviderProps> = ({
76
91
  requireAuth = 'off',
77
92
  backgroundSession = false,
78
93
  deviceCredentialStorage = 'persistent',
94
+ language,
79
95
  }) => {
80
96
 
81
97
  // Storage + persistence wiring.
@@ -229,6 +245,7 @@ const OxyProvider: FC<OxyProviderProps> = ({
229
245
  onAuthStateChange={onAuthStateChange as OxyRuntimeProviderProps['onAuthStateChange']}
230
246
  >
231
247
  {productAnalytics ? <ProductAnalyticsObserver analytics={productAnalytics} /> : null}
248
+ {language ? <LanguageBridge {...language} /> : null}
232
249
  <SurfaceProvider>
233
250
  {requireAuth === 'off' ? (
234
251
  children
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { LanguageBridge } from '../LanguageBridge';
4
+
5
+ /**
6
+ * `OxyProvider`'s language config prop, realized: the one place Oxy's
7
+ * resolved language reaches a host app's own i18n library. `useOxy` is mocked here —
8
+ * it is the SDK's own well-tested context — so these tests exercise exactly
9
+ * what this component adds: coercion to the caller's catalog, and calling
10
+ * back only when the RESOLVED locale actually changes.
11
+ */
12
+
13
+ let mockCurrentLanguage = 'en-US';
14
+ jest.mock('../../context/OxyContext', () => ({
15
+ useOxy: () => ({ currentLanguage: mockCurrentLanguage }),
16
+ }));
17
+
18
+ const HOST_CATALOG = ['en-US', 'es-ES', 'fr-FR'] as const;
19
+
20
+ beforeEach(() => {
21
+ mockCurrentLanguage = 'en-US';
22
+ });
23
+
24
+ it('resolves and reports the account language on mount', () => {
25
+ mockCurrentLanguage = 'es-ES';
26
+ const onChange = jest.fn();
27
+ render(<LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={onChange} />);
28
+
29
+ expect(onChange).toHaveBeenCalledWith('es-ES');
30
+ });
31
+
32
+ it('coerces a locale the host never shipped a catalog for, by base language', () => {
33
+ mockCurrentLanguage = 'es-MX';
34
+ const onChange = jest.fn();
35
+ render(<LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={onChange} />);
36
+
37
+ expect(onChange).toHaveBeenCalledWith('es-ES');
38
+ });
39
+
40
+ it('falls back to the caller default when nothing matches, even by base', () => {
41
+ mockCurrentLanguage = 'ja-JP';
42
+ const onChange = jest.fn();
43
+ render(<LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={onChange} />);
44
+
45
+ expect(onChange).toHaveBeenCalledWith('en-US');
46
+ });
47
+
48
+ it('calls back again only when the RESOLVED locale changes', () => {
49
+ const onChange = jest.fn();
50
+ const { rerender } = render(
51
+ <LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={onChange} />,
52
+ );
53
+ expect(onChange).toHaveBeenCalledTimes(1);
54
+
55
+ // Same resolved locale, brand-new callback identity (the common case for an
56
+ // inline arrow function) — must not re-fire.
57
+ rerender(<LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={() => {}} />);
58
+ expect(onChange).toHaveBeenCalledTimes(1);
59
+
60
+ mockCurrentLanguage = 'fr-FR';
61
+ rerender(<LanguageBridge supportedLocales={HOST_CATALOG} fallbackLocale="en-US" onChange={onChange} />);
62
+ expect(onChange).toHaveBeenCalledTimes(2);
63
+ expect(onChange).toHaveBeenLastCalledWith('fr-FR');
64
+ });
65
+
66
+ it('reports a rejected onChange to onError instead of throwing', async () => {
67
+ const failure = new Error('catalog failed to load');
68
+ const onChange = jest.fn().mockRejectedValue(failure);
69
+ const onError = jest.fn();
70
+ render(
71
+ <LanguageBridge
72
+ supportedLocales={HOST_CATALOG}
73
+ fallbackLocale="en-US"
74
+ onChange={onChange}
75
+ onError={onError}
76
+ />,
77
+ );
78
+
79
+ await new Promise((resolve) => setTimeout(resolve, 0));
80
+ expect(onError).toHaveBeenCalledWith(failure, 'en-US');
81
+ });
@@ -24,6 +24,7 @@ function renderScreen(props: Partial<OxyConsentScreenProps> = {}) {
24
24
  application={props.application ?? baseApp}
25
25
  scopes={props.scopes ?? ['openid', 'profile']}
26
26
  user={props.user}
27
+ resource={props.resource}
27
28
  onAllow={props.onAllow ?? onAllow}
28
29
  onDeny={props.onDeny ?? onDeny}
29
30
  busy={props.busy}
@@ -138,6 +139,37 @@ describe('OxyConsentScreen', () => {
138
139
  expect(getByTestId('consent-account-name').textContent).toBe('Alice A');
139
140
  });
140
141
 
142
+ it('renders the exact MCP app, protected resource, account id and catalog-derived write actions', () => {
143
+ const { getByTestId } = renderScreen({
144
+ scopes: ['email.read', 'email.send'],
145
+ user: {
146
+ accountId: 'account-mail-1',
147
+ displayName: 'Oxy Mail',
148
+ handle: 'oxy-mail-account',
149
+ },
150
+ resource: {
151
+ application: { name: 'Inbox', iconUrl: 'inbox-icon' },
152
+ uri: 'https://mcp.inbox.oxy.so',
153
+ writeActions: [{
154
+ name: 'sendEmail',
155
+ version: '1.0.0',
156
+ description: 'Send an email from the selected mailbox.',
157
+ requiredCapabilities: ['email.send'],
158
+ effect: 'external',
159
+ }],
160
+ },
161
+ });
162
+
163
+ expect(getByTestId('consent-resource-app').textContent).toBe('Inbox');
164
+ expect(getByTestId('consent-resource-uri').textContent).toBe('https://mcp.inbox.oxy.so');
165
+ expect(getByTestId('consent-account-id').textContent).toContain('account-mail-1');
166
+ expect(getByTestId('consent-scope-email.send').textContent).toContain('email.send');
167
+ expect(getByTestId('consent-write-action-sendEmail').textContent).toContain(
168
+ 'Send an email from the selected mailbox.',
169
+ );
170
+ expect(getByTestId('consent-write-action-sendEmail').textContent).toContain('External');
171
+ });
172
+
141
173
  it('falls back to the handle when the account has no display name (D5)', () => {
142
174
  const { getByTestId } = renderScreen({ user: { handle: 'bob' } });
143
175
  expect(getByTestId('consent-account-name').textContent).toBe('bob');
@@ -172,4 +172,34 @@ export interface OxyProviderProps {
172
172
  * @default 'persistent'
173
173
  */
174
174
  deviceCredentialStorage?: 'persistent' | 'ephemeral';
175
+ /**
176
+ * Wires the app's OWN i18n library to Oxy's resolved language, so the
177
+ * account (or, signed out, the device/guest locale) drives the app's
178
+ * translated UI directly — no app-local effect or "sync" component to
179
+ * remember to mount. Oxy decides WHICH language; the app keeps owning its
180
+ * own translation catalogs and library (i18next, FormatJS, or anything
181
+ * else) and is told through `onChange` when to switch.
182
+ *
183
+ * Omitted entirely (the default) when an app has no i18n of its own, or
184
+ * manages it independently of the account/device locale.
185
+ */
186
+ language?: OxyLanguageConfig;
187
+ }
188
+
189
+ export interface OxyLanguageConfig {
190
+ /** The exact locales this app ships a translation catalog for. */
191
+ supportedLocales: readonly string[];
192
+ /**
193
+ * Used when Oxy's resolved language matches none of `supportedLocales`,
194
+ * not even by base language (Oxy's account-locale catalog is broader
195
+ * than any one app's translations).
196
+ */
197
+ fallbackLocale: string;
198
+ /**
199
+ * Called whenever the resolved locale changes, coerced to the closest
200
+ * one in `supportedLocales`. May return a promise; a rejection is
201
+ * reported to `onError` instead of throwing into the app tree.
202
+ */
203
+ onChange: (locale: string) => void | Promise<void>;
204
+ onError?: (error: unknown, locale: string) => void;
175
205
  }