@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.
- package/lib/commonjs/ui/components/OxyConsentScreen.js +10 -7
- package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -1
- package/lib/commonjs/ui/oauth/explicitOAuthConsent.js +10 -5
- package/lib/commonjs/ui/oauth/explicitOAuthConsent.js.map +1 -1
- package/lib/module/ui/components/OxyConsentScreen.js +10 -7
- package/lib/module/ui/components/OxyConsentScreen.js.map +1 -1
- package/lib/module/ui/oauth/explicitOAuthConsent.js +10 -5
- package/lib/module/ui/oauth/explicitOAuthConsent.js.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts +3 -1
- package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +2 -1
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +28 -50
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts +13 -13
- package/lib/typescript/commonjs/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSupervision.d.ts +108 -108
- package/lib/typescript/commonjs/ui/oauth/explicitOAuthConsent.d.ts +4 -6
- package/lib/typescript/commonjs/ui/oauth/explicitOAuthConsent.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts +3 -1
- package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +2 -1
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +28 -50
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts +13 -13
- package/lib/typescript/module/ui/hooks/queries/usePersonalPlans.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSupervision.d.ts +108 -108
- package/lib/typescript/module/ui/oauth/explicitOAuthConsent.d.ts +4 -6
- package/lib/typescript/module/ui/oauth/explicitOAuthConsent.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ui/components/OxyConsentScreen.tsx +40 -31
- package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +13 -0
- package/src/ui/context/oxyContextTypes.ts +2 -1
- package/src/ui/oauth/__tests__/explicitOAuthConsent.test.ts +17 -0
- 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.
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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);
|