@oxy.so/services 12.14.0 → 13.0.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 (36) hide show
  1. package/lib/commonjs/ui/components/OxyConsentScreen.js +10 -7
  2. package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -1
  3. package/lib/commonjs/ui/oauth/explicitOAuthConsent.js +10 -5
  4. package/lib/commonjs/ui/oauth/explicitOAuthConsent.js.map +1 -1
  5. package/lib/module/ui/components/OxyConsentScreen.js +10 -7
  6. package/lib/module/ui/components/OxyConsentScreen.js.map +1 -1
  7. package/lib/module/ui/oauth/explicitOAuthConsent.js +10 -5
  8. package/lib/module/ui/oauth/explicitOAuthConsent.js.map +1 -1
  9. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts +3 -1
  10. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts.map +1 -1
  11. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +2 -1
  12. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  13. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +28 -50
  14. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  15. package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts +13 -13
  16. package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
  17. package/lib/typescript/commonjs/ui/hooks/queries/useSupervision.d.ts +108 -108
  18. package/lib/typescript/commonjs/ui/oauth/explicitOAuthConsent.d.ts +4 -6
  19. package/lib/typescript/commonjs/ui/oauth/explicitOAuthConsent.d.ts.map +1 -1
  20. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts +3 -1
  21. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts.map +1 -1
  22. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +2 -1
  23. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  24. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +28 -50
  25. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  26. package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts +13 -13
  27. package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
  28. package/lib/typescript/module/ui/hooks/queries/useSupervision.d.ts +108 -108
  29. package/lib/typescript/module/ui/oauth/explicitOAuthConsent.d.ts +4 -6
  30. package/lib/typescript/module/ui/oauth/explicitOAuthConsent.d.ts.map +1 -1
  31. package/package.json +4 -4
  32. package/src/ui/components/OxyConsentScreen.tsx +40 -31
  33. package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +13 -0
  34. package/src/ui/context/oxyContextTypes.ts +2 -1
  35. package/src/ui/oauth/__tests__/explicitOAuthConsent.test.ts +17 -0
  36. package/src/ui/oauth/explicitOAuthConsent.ts +10 -5
@@ -129,7 +129,8 @@ export interface OxyContextState {
129
129
 
130
130
  /**
131
131
  * Ask the already-authenticated user for explicit OAuth consent to exact
132
- * application scopes. Must be called from a user gesture. Works on web and
132
+ * external application scopes. Own Oxy apps do not use this operation.
133
+ * Must be called from a user gesture. Works on web and
133
134
  * native and commits only a callback bound to the same user, state, PKCE pair
134
135
  * and byte-exact redirect URI.
135
136
  */
@@ -82,6 +82,23 @@ describe('requestOAuthConsent', () => {
82
82
  jest.restoreAllMocks();
83
83
  });
84
84
 
85
+ it.each(['first_party', 'internal', 'system'])(
86
+ 'does not request consent for an own %s application',
87
+ async (type) => {
88
+ const context = makeContext('native');
89
+ const apps = context.oxyServices.apps.getPublic as jest.Mock;
90
+ apps.mockResolvedValue({ id: 'own-app', type, scopes: [...EXACT_SCOPES] });
91
+ expect(
92
+ await requestOAuthConsent(context, {
93
+ redirectUri: NATIVE_REDIRECT_URI,
94
+ scopes: EXACT_SCOPES,
95
+ }),
96
+ ).toEqual({ status: 'unsupported', reason: 'first-party-application' });
97
+ expect(openNative).not.toHaveBeenCalled();
98
+ expect(context.commitSession).not.toHaveBeenCalled();
99
+ },
100
+ );
101
+
85
102
  it('uses the existing web popup transport with exact scopes and redirect', async () => {
86
103
  const popup = fakePopup();
87
104
  jest.spyOn(window, 'open').mockReturnValue(popup as unknown as Window);
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * Explicit OAuth consent for an already-authenticated Oxy user.
3
3
  *
4
- * This is deliberately separate from sign-in routing. First-party applications
5
- * normally use the account dialog, but a consent-required scope (for example
6
- * `acting-as:offline`) still has to go through the OAuth authorize surface. The
7
- * caller must invoke this operation from a real user gesture; it never runs on
8
- * mount, retries silently, or grants anything locally.
4
+ * External applications may request additional scopes through OAuth. Own Oxy
5
+ * applications use the account dialog and never create OAuth consent grants.
6
+ * The caller invokes this operation from a user gesture.
9
7
  */
10
8
 
11
9
  import type { OxyServices, PublicApplication } from "@oxy.so/core";
@@ -44,6 +42,7 @@ export type OAuthConsentFailureReason =
44
42
 
45
43
  export type OAuthConsentUnsupportedReason =
46
44
  | "missing-client-id"
45
+ | "first-party-application"
47
46
  | "identity-bound"
48
47
  | "not-authenticated"
49
48
  | "unsupported-platform";
@@ -173,6 +172,12 @@ export async function requestOAuthConsent(
173
172
  return { status: "failed", reason: "client-resolution-failed" };
174
173
  }
175
174
 
175
+ if (application.isOfficial || application.isInternal ||
176
+ ["first_party", "internal", "system"].includes(application.type)) {
177
+ closeOAuthPopup(popup);
178
+ return { status: "unsupported", reason: "first-party-application" };
179
+ }
180
+
176
181
  const configuredScopes = new Set(application.scopes);
177
182
  if (options.scopes.some((scope) => !configuredScopes.has(scope))) {
178
183
  closeOAuthPopup(popup);