@oxyhq/services 5.24.0 → 5.25.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/web/WebOxyContext.js +23 -50
- package/lib/commonjs/web/WebOxyContext.js.map +1 -1
- package/lib/module/web/WebOxyContext.js +24 -51
- package/lib/module/web/WebOxyContext.js.map +1 -1
- package/lib/typescript/commonjs/web/WebOxyContext.d.ts +6 -5
- package/lib/typescript/commonjs/web/WebOxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/web/index.d.ts +1 -1
- package/lib/typescript/commonjs/web/index.d.ts.map +1 -1
- package/lib/typescript/module/web/WebOxyContext.d.ts +6 -5
- package/lib/typescript/module/web/WebOxyContext.d.ts.map +1 -1
- package/lib/typescript/module/web/index.d.ts +1 -1
- package/lib/typescript/module/web/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web/WebOxyContext.tsx +28 -60
- package/src/web/index.ts +1 -1
|
@@ -14,12 +14,13 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
14
14
|
/**
|
|
15
15
|
* Web-Only Oxy Context
|
|
16
16
|
* Clean implementation with ZERO React Native dependencies
|
|
17
|
+
* Uses CrossDomainAuth for proper SSO flow
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
const WebOxyContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
20
21
|
/**
|
|
21
22
|
* Web-only Oxy Provider
|
|
22
|
-
*
|
|
23
|
+
* Uses CrossDomainAuth for automatic SSO with FedCM/Popup/Redirect fallback
|
|
23
24
|
*/
|
|
24
25
|
function WebOxyProvider({
|
|
25
26
|
children,
|
|
@@ -31,21 +32,22 @@ function WebOxyProvider({
|
|
|
31
32
|
baseURL,
|
|
32
33
|
authWebUrl
|
|
33
34
|
}));
|
|
35
|
+
const [crossDomainAuth] = (0, _react.useState)(() => (0, _index.createCrossDomainAuth)(oxyServices));
|
|
34
36
|
const [user, setUser] = (0, _react.useState)(null);
|
|
35
37
|
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
36
38
|
const [error, setError] = (0, _react.useState)(null);
|
|
37
39
|
const [queryClient] = (0, _react.useState)(() => (0, _queryClient.createQueryClient)());
|
|
38
40
|
const isAuthenticated = !!user;
|
|
39
41
|
|
|
40
|
-
// Initialize -
|
|
42
|
+
// Initialize - handle callbacks, restore session, try silent sign-in
|
|
41
43
|
(0, _react.useEffect)(() => {
|
|
42
44
|
let mounted = true;
|
|
43
45
|
const initAuth = async () => {
|
|
44
46
|
try {
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
if (mounted &&
|
|
48
|
-
setUser(
|
|
47
|
+
// Complete initialization: handles callbacks, restores session, tries silent sign-in
|
|
48
|
+
const session = await crossDomainAuth.initialize();
|
|
49
|
+
if (mounted && session?.user) {
|
|
50
|
+
setUser(session.user);
|
|
49
51
|
}
|
|
50
52
|
} catch (err) {
|
|
51
53
|
// No active session - this is fine
|
|
@@ -60,7 +62,7 @@ function WebOxyProvider({
|
|
|
60
62
|
return () => {
|
|
61
63
|
mounted = false;
|
|
62
64
|
};
|
|
63
|
-
}, [
|
|
65
|
+
}, [crossDomainAuth]);
|
|
64
66
|
|
|
65
67
|
// Notify parent of auth state changes
|
|
66
68
|
(0, _react.useEffect)(() => {
|
|
@@ -70,59 +72,30 @@ function WebOxyProvider({
|
|
|
70
72
|
setError(null);
|
|
71
73
|
setIsLoading(true);
|
|
72
74
|
try {
|
|
73
|
-
//
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// Listen for message from popup
|
|
80
|
-
const handleMessage = async event => {
|
|
81
|
-
if (event.origin !== (authWebUrl || 'https://auth.oxy.so')) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (event.data.type === 'oxy-auth-success') {
|
|
85
|
-
const {
|
|
86
|
-
accessToken,
|
|
87
|
-
user: authUser
|
|
88
|
-
} = event.data;
|
|
89
|
-
|
|
90
|
-
// Store the access token for API requests
|
|
91
|
-
if (typeof window !== 'undefined' && accessToken) {
|
|
92
|
-
localStorage.setItem('oxy-access-token', accessToken);
|
|
93
|
-
}
|
|
94
|
-
setUser(authUser);
|
|
95
|
-
setIsLoading(false);
|
|
96
|
-
window.removeEventListener('message', handleMessage);
|
|
97
|
-
popup.close();
|
|
98
|
-
} else if (event.data.type === 'oxy-auth-error') {
|
|
99
|
-
setError(event.data.error || 'Authentication failed');
|
|
100
|
-
setIsLoading(false);
|
|
101
|
-
window.removeEventListener('message', handleMessage);
|
|
102
|
-
popup.close();
|
|
75
|
+
// Sign in with automatic method selection (FedCM → Popup → Redirect)
|
|
76
|
+
const session = await crossDomainAuth.signIn({
|
|
77
|
+
method: 'auto',
|
|
78
|
+
// Automatic fallback
|
|
79
|
+
onMethodSelected: method => {
|
|
80
|
+
console.log('[WebOxy] Using auth method:', method);
|
|
103
81
|
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const checkClosed = setInterval(() => {
|
|
109
|
-
if (popup.closed) {
|
|
110
|
-
clearInterval(checkClosed);
|
|
111
|
-
window.removeEventListener('message', handleMessage);
|
|
112
|
-
setIsLoading(false);
|
|
113
|
-
}
|
|
114
|
-
}, 500);
|
|
82
|
+
});
|
|
83
|
+
if (session?.user) {
|
|
84
|
+
setUser(session.user);
|
|
85
|
+
}
|
|
115
86
|
} catch (err) {
|
|
116
87
|
console.error('[WebOxy] Sign in error:', err);
|
|
117
88
|
setError(err instanceof Error ? err.message : 'Sign in failed');
|
|
89
|
+
} finally {
|
|
118
90
|
setIsLoading(false);
|
|
119
91
|
}
|
|
120
|
-
}, [
|
|
92
|
+
}, [crossDomainAuth]);
|
|
121
93
|
const signOut = (0, _react.useCallback)(async () => {
|
|
122
94
|
setError(null);
|
|
123
95
|
try {
|
|
124
|
-
// Clear stored
|
|
96
|
+
// Clear stored session
|
|
125
97
|
if (typeof window !== 'undefined') {
|
|
98
|
+
localStorage.removeItem('oxy-session');
|
|
126
99
|
localStorage.removeItem('oxy-access-token');
|
|
127
100
|
}
|
|
128
101
|
setUser(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_index","_reactQuery","_queryClient","_jsxRuntime","WebOxyContext","createContext","WebOxyProvider","children","baseURL","authWebUrl","onAuthStateChange","oxyServices","useState","OxyServices","user","setUser","isLoading","setIsLoading","error","setError","queryClient","createQueryClient","isAuthenticated","useEffect","mounted","initAuth","
|
|
1
|
+
{"version":3,"names":["_react","require","_index","_reactQuery","_queryClient","_jsxRuntime","WebOxyContext","createContext","WebOxyProvider","children","baseURL","authWebUrl","onAuthStateChange","oxyServices","useState","OxyServices","crossDomainAuth","createCrossDomainAuth","user","setUser","isLoading","setIsLoading","error","setError","queryClient","createQueryClient","isAuthenticated","useEffect","mounted","initAuth","session","initialize","err","console","log","signIn","useCallback","method","onMethodSelected","Error","message","signOut","window","localStorage","removeItem","contextValue","jsx","QueryClientProvider","client","Provider","value","useWebOxy","context","useContext","useAuth","isReady"],"sourceRoot":"../../../src","sources":["web/WebOxyContext.tsx"],"mappings":";;;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAA4D,IAAAI,WAAA,GAAAJ,OAAA;AAlB5D;AACA;AACA;AACA;AACA;;AAgCA,MAAMK,aAAa,gBAAG,IAAAC,oBAAa,EAA4B,IAAI,CAAC;AASpE;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAC;EAC7BC,QAAQ;EACRC,OAAO;EACPC,UAAU;EACVC;AACmB,CAAC,EAAE;EACtB,MAAM,CAACC,WAAW,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM,IAAIC,kBAAW,CAAC;IAAEL,OAAO;IAAEC;EAAW,CAAC,CAAC,CAAC;EAC9E,MAAM,CAACK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,eAAe;IACfN,SAAS;IACTE,KAAK;IACLa,MAAM;IACNM,OAAO;IACP5B;EACF,CAAC;EAED,oBACE,IAAAR,WAAA,CAAAyC,GAAA,EAAC3C,WAAA,CAAA4C,mBAAmB;IAACC,MAAM,EAAExB,WAAY;IAAAf,QAAA,eACvC,IAAAJ,WAAA,CAAAyC,GAAA,EAACxC,aAAa,CAAC2C,QAAQ;MAACC,KAAK,EAAEL,YAAa;MAAApC,QAAA,EACzCA;IAAQ,CACa;EAAC,CACN,CAAC;AAE1B;AAEO,SAAS0C,SAASA,CAAA,EAAG;EAC1B,MAAMC,OAAO,GAAG,IAAAC,iBAAU,EAAC/C,aAAa,CAAC;EACzC,IAAI,CAAC8C,OAAO,EAAE;IACZ,MAAM,IAAIb,KAAK,CAAC,8CAA8C,CAAC;EACjE;EACA,OAAOa,OAAO;AAChB;AAEO,SAASE,OAAOA,CAAA,EAAG;EACxB,MAAM;IAAEpC,IAAI;IAAEQ,eAAe;IAAEN,SAAS;IAAEE,KAAK;IAAEa,MAAM;IAAEM,OAAO;IAAE5B;EAAY,CAAC,GAAGsC,SAAS,CAAC,CAAC;EAE7F,OAAO;IACLjC,IAAI;IACJQ,eAAe;IACfN,SAAS;IACTmC,OAAO,EAAE,CAACnC,SAAS;IACnBE,KAAK;IACLa,MAAM;IACNM,OAAO;IACP5B;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Web-Only Oxy Context
|
|
5
5
|
* Clean implementation with ZERO React Native dependencies
|
|
6
|
+
* Uses CrossDomainAuth for proper SSO flow
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { createContext, useCallback, useContext, useEffect, useState } from 'react';
|
|
9
|
-
import { OxyServices } from "../core/index.js";
|
|
10
|
+
import { OxyServices, createCrossDomainAuth } from "../core/index.js";
|
|
10
11
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
11
12
|
import { createQueryClient } from "../ui/hooks/queryClient.js";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const WebOxyContext = /*#__PURE__*/createContext(null);
|
|
14
15
|
/**
|
|
15
16
|
* Web-only Oxy Provider
|
|
16
|
-
*
|
|
17
|
+
* Uses CrossDomainAuth for automatic SSO with FedCM/Popup/Redirect fallback
|
|
17
18
|
*/
|
|
18
19
|
export function WebOxyProvider({
|
|
19
20
|
children,
|
|
@@ -25,21 +26,22 @@ export function WebOxyProvider({
|
|
|
25
26
|
baseURL,
|
|
26
27
|
authWebUrl
|
|
27
28
|
}));
|
|
29
|
+
const [crossDomainAuth] = useState(() => createCrossDomainAuth(oxyServices));
|
|
28
30
|
const [user, setUser] = useState(null);
|
|
29
31
|
const [isLoading, setIsLoading] = useState(true);
|
|
30
32
|
const [error, setError] = useState(null);
|
|
31
33
|
const [queryClient] = useState(() => createQueryClient());
|
|
32
34
|
const isAuthenticated = !!user;
|
|
33
35
|
|
|
34
|
-
// Initialize -
|
|
36
|
+
// Initialize - handle callbacks, restore session, try silent sign-in
|
|
35
37
|
useEffect(() => {
|
|
36
38
|
let mounted = true;
|
|
37
39
|
const initAuth = async () => {
|
|
38
40
|
try {
|
|
39
|
-
//
|
|
40
|
-
const
|
|
41
|
-
if (mounted &&
|
|
42
|
-
setUser(
|
|
41
|
+
// Complete initialization: handles callbacks, restores session, tries silent sign-in
|
|
42
|
+
const session = await crossDomainAuth.initialize();
|
|
43
|
+
if (mounted && session?.user) {
|
|
44
|
+
setUser(session.user);
|
|
43
45
|
}
|
|
44
46
|
} catch (err) {
|
|
45
47
|
// No active session - this is fine
|
|
@@ -54,7 +56,7 @@ export function WebOxyProvider({
|
|
|
54
56
|
return () => {
|
|
55
57
|
mounted = false;
|
|
56
58
|
};
|
|
57
|
-
}, [
|
|
59
|
+
}, [crossDomainAuth]);
|
|
58
60
|
|
|
59
61
|
// Notify parent of auth state changes
|
|
60
62
|
useEffect(() => {
|
|
@@ -64,59 +66,30 @@ export function WebOxyProvider({
|
|
|
64
66
|
setError(null);
|
|
65
67
|
setIsLoading(true);
|
|
66
68
|
try {
|
|
67
|
-
//
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Listen for message from popup
|
|
74
|
-
const handleMessage = async event => {
|
|
75
|
-
if (event.origin !== (authWebUrl || 'https://auth.oxy.so')) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (event.data.type === 'oxy-auth-success') {
|
|
79
|
-
const {
|
|
80
|
-
accessToken,
|
|
81
|
-
user: authUser
|
|
82
|
-
} = event.data;
|
|
83
|
-
|
|
84
|
-
// Store the access token for API requests
|
|
85
|
-
if (typeof window !== 'undefined' && accessToken) {
|
|
86
|
-
localStorage.setItem('oxy-access-token', accessToken);
|
|
87
|
-
}
|
|
88
|
-
setUser(authUser);
|
|
89
|
-
setIsLoading(false);
|
|
90
|
-
window.removeEventListener('message', handleMessage);
|
|
91
|
-
popup.close();
|
|
92
|
-
} else if (event.data.type === 'oxy-auth-error') {
|
|
93
|
-
setError(event.data.error || 'Authentication failed');
|
|
94
|
-
setIsLoading(false);
|
|
95
|
-
window.removeEventListener('message', handleMessage);
|
|
96
|
-
popup.close();
|
|
69
|
+
// Sign in with automatic method selection (FedCM → Popup → Redirect)
|
|
70
|
+
const session = await crossDomainAuth.signIn({
|
|
71
|
+
method: 'auto',
|
|
72
|
+
// Automatic fallback
|
|
73
|
+
onMethodSelected: method => {
|
|
74
|
+
console.log('[WebOxy] Using auth method:', method);
|
|
97
75
|
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const checkClosed = setInterval(() => {
|
|
103
|
-
if (popup.closed) {
|
|
104
|
-
clearInterval(checkClosed);
|
|
105
|
-
window.removeEventListener('message', handleMessage);
|
|
106
|
-
setIsLoading(false);
|
|
107
|
-
}
|
|
108
|
-
}, 500);
|
|
76
|
+
});
|
|
77
|
+
if (session?.user) {
|
|
78
|
+
setUser(session.user);
|
|
79
|
+
}
|
|
109
80
|
} catch (err) {
|
|
110
81
|
console.error('[WebOxy] Sign in error:', err);
|
|
111
82
|
setError(err instanceof Error ? err.message : 'Sign in failed');
|
|
83
|
+
} finally {
|
|
112
84
|
setIsLoading(false);
|
|
113
85
|
}
|
|
114
|
-
}, [
|
|
86
|
+
}, [crossDomainAuth]);
|
|
115
87
|
const signOut = useCallback(async () => {
|
|
116
88
|
setError(null);
|
|
117
89
|
try {
|
|
118
|
-
// Clear stored
|
|
90
|
+
// Clear stored session
|
|
119
91
|
if (typeof window !== 'undefined') {
|
|
92
|
+
localStorage.removeItem('oxy-session');
|
|
120
93
|
localStorage.removeItem('oxy-access-token');
|
|
121
94
|
}
|
|
122
95
|
setUser(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useState","OxyServices","QueryClientProvider","createQueryClient","jsx","_jsx","WebOxyContext","WebOxyProvider","children","baseURL","authWebUrl","onAuthStateChange","oxyServices","user","setUser","isLoading","setIsLoading","error","setError","queryClient","isAuthenticated","mounted","initAuth","
|
|
1
|
+
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useState","OxyServices","createCrossDomainAuth","QueryClientProvider","createQueryClient","jsx","_jsx","WebOxyContext","WebOxyProvider","children","baseURL","authWebUrl","onAuthStateChange","oxyServices","crossDomainAuth","user","setUser","isLoading","setIsLoading","error","setError","queryClient","isAuthenticated","mounted","initAuth","session","initialize","err","console","log","signIn","method","onMethodSelected","Error","message","signOut","window","localStorage","removeItem","contextValue","client","Provider","value","useWebOxy","context","useAuth","isReady"],"sourceRoot":"../../../src","sources":["web/WebOxyContext.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,QAAQ,QAEH,OAAO;AACd,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,kBAAS;AAG5D,SAAS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O React Native dependencies
|
|
4
|
+
* Uses CrossDomainAuth for proper SSO flow
|
|
4
5
|
*/
|
|
5
6
|
import { type ReactNode } from 'react';
|
|
6
7
|
import { OxyServices } from '../core';
|
|
7
|
-
import type {
|
|
8
|
+
import type { MinimalUserData } from '../models/session';
|
|
8
9
|
export interface WebAuthState {
|
|
9
|
-
user:
|
|
10
|
+
user: MinimalUserData | null;
|
|
10
11
|
isAuthenticated: boolean;
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
error: string | null;
|
|
@@ -22,16 +23,16 @@ export interface WebOxyProviderProps {
|
|
|
22
23
|
children: ReactNode;
|
|
23
24
|
baseURL: string;
|
|
24
25
|
authWebUrl?: string;
|
|
25
|
-
onAuthStateChange?: (user:
|
|
26
|
+
onAuthStateChange?: (user: MinimalUserData | null) => void;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Web-only Oxy Provider
|
|
29
|
-
*
|
|
30
|
+
* Uses CrossDomainAuth for automatic SSO with FedCM/Popup/Redirect fallback
|
|
30
31
|
*/
|
|
31
32
|
export declare function WebOxyProvider({ children, baseURL, authWebUrl, onAuthStateChange, }: WebOxyProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
32
33
|
export declare function useWebOxy(): WebOxyContextValue;
|
|
33
34
|
export declare function useAuth(): {
|
|
34
|
-
user:
|
|
35
|
+
user: MinimalUserData | null;
|
|
35
36
|
isAuthenticated: boolean;
|
|
36
37
|
isLoading: boolean;
|
|
37
38
|
isReady: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebOxyContext.d.ts","sourceRoot":"","sources":["../../../../src/web/WebOxyContext.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"WebOxyContext.d.ts","sourceRoot":"","sources":["../../../../src/web/WebOxyContext.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAyB,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY,EAAE,cAAc;IACtE,WAAW,EAAE,WAAW,CAAC;CAC1B;AAID,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;CAC5D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,EAAE,mBAAmB,2CAsGrB;AAED,wBAAgB,SAAS,uBAMxB;AAED,wBAAgB,OAAO;;;;;;kBA1IP,OAAO,CAAC,IAAI,CAAC;mBACZ,OAAO,CAAC,IAAI,CAAC;;EAsJ7B"}
|
|
@@ -34,7 +34,7 @@ export type { CrossDomainAuthOptions, DeviceFingerprint, StoredDeviceInfo, } fro
|
|
|
34
34
|
export { WebOxyProvider, useWebOxy, useAuth } from './WebOxyContext';
|
|
35
35
|
export type { WebOxyProviderProps, WebAuthState, WebAuthActions, WebOxyContextValue } from './WebOxyContext';
|
|
36
36
|
export type { User, ApiError, Notification, FileMetadata, AssetUploadProgress, PaymentMethod, KarmaLeaderboardEntry, KarmaRule, Transaction, DeviceSession, } from '../models/interfaces';
|
|
37
|
-
export type { ClientSession } from '../models/session';
|
|
37
|
+
export type { ClientSession, MinimalUserData } from '../models/session';
|
|
38
38
|
export { SUPPORTED_LANGUAGES, getLanguageMetadata, getLanguageName, getNativeLanguageName, normalizeLanguageCode, } from '../utils/languageUtils';
|
|
39
39
|
export type { LanguageMetadata } from '../utils/languageUtils';
|
|
40
40
|
import { WebOxyProvider } from './WebOxyContext';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,aAAa,EACb,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI7G,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,aAAa,EACb,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAI7G,YAAY,EACV,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,eAAe,cAAc,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Web-Only Oxy Context
|
|
3
3
|
* Clean implementation with ZERO React Native dependencies
|
|
4
|
+
* Uses CrossDomainAuth for proper SSO flow
|
|
4
5
|
*/
|
|
5
6
|
import { type ReactNode } from 'react';
|
|
6
7
|
import { OxyServices } from '../core';
|
|
7
|
-
import type {
|
|
8
|
+
import type { MinimalUserData } from '../models/session';
|
|
8
9
|
export interface WebAuthState {
|
|
9
|
-
user:
|
|
10
|
+
user: MinimalUserData | null;
|
|
10
11
|
isAuthenticated: boolean;
|
|
11
12
|
isLoading: boolean;
|
|
12
13
|
error: string | null;
|
|
@@ -22,16 +23,16 @@ export interface WebOxyProviderProps {
|
|
|
22
23
|
children: ReactNode;
|
|
23
24
|
baseURL: string;
|
|
24
25
|
authWebUrl?: string;
|
|
25
|
-
onAuthStateChange?: (user:
|
|
26
|
+
onAuthStateChange?: (user: MinimalUserData | null) => void;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Web-only Oxy Provider
|
|
29
|
-
*
|
|
30
|
+
* Uses CrossDomainAuth for automatic SSO with FedCM/Popup/Redirect fallback
|
|
30
31
|
*/
|
|
31
32
|
export declare function WebOxyProvider({ children, baseURL, authWebUrl, onAuthStateChange, }: WebOxyProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
32
33
|
export declare function useWebOxy(): WebOxyContextValue;
|
|
33
34
|
export declare function useAuth(): {
|
|
34
|
-
user:
|
|
35
|
+
user: MinimalUserData | null;
|
|
35
36
|
isAuthenticated: boolean;
|
|
36
37
|
isLoading: boolean;
|
|
37
38
|
isReady: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebOxyContext.d.ts","sourceRoot":"","sources":["../../../../src/web/WebOxyContext.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"WebOxyContext.d.ts","sourceRoot":"","sources":["../../../../src/web/WebOxyContext.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAyB,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY,EAAE,cAAc;IACtE,WAAW,EAAE,WAAW,CAAC;CAC1B;AAID,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;CAC5D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,EAAE,mBAAmB,2CAsGrB;AAED,wBAAgB,SAAS,uBAMxB;AAED,wBAAgB,OAAO;;;;;;kBA1IP,OAAO,CAAC,IAAI,CAAC;mBACZ,OAAO,CAAC,IAAI,CAAC;;EAsJ7B"}
|
|
@@ -34,7 +34,7 @@ export type { CrossDomainAuthOptions, DeviceFingerprint, StoredDeviceInfo, } fro
|
|
|
34
34
|
export { WebOxyProvider, useWebOxy, useAuth } from './WebOxyContext';
|
|
35
35
|
export type { WebOxyProviderProps, WebAuthState, WebAuthActions, WebOxyContextValue } from './WebOxyContext';
|
|
36
36
|
export type { User, ApiError, Notification, FileMetadata, AssetUploadProgress, PaymentMethod, KarmaLeaderboardEntry, KarmaRule, Transaction, DeviceSession, } from '../models/interfaces';
|
|
37
|
-
export type { ClientSession } from '../models/session';
|
|
37
|
+
export type { ClientSession, MinimalUserData } from '../models/session';
|
|
38
38
|
export { SUPPORTED_LANGUAGES, getLanguageMetadata, getLanguageName, getNativeLanguageName, normalizeLanguageCode, } from '../utils/languageUtils';
|
|
39
39
|
export type { LanguageMetadata } from '../utils/languageUtils';
|
|
40
40
|
import { WebOxyProvider } from './WebOxyContext';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":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ACnB,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"description": "Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Web-Only Oxy Context
|
|
3
3
|
* Clean implementation with ZERO React Native dependencies
|
|
4
|
+
* Uses CrossDomainAuth for proper SSO flow
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -11,13 +12,14 @@ import {
|
|
|
11
12
|
useState,
|
|
12
13
|
type ReactNode,
|
|
13
14
|
} from 'react';
|
|
14
|
-
import { OxyServices } from '../core';
|
|
15
|
+
import { OxyServices, createCrossDomainAuth } from '../core';
|
|
15
16
|
import type { User } from '../models/interfaces';
|
|
17
|
+
import type { MinimalUserData } from '../models/session';
|
|
16
18
|
import { QueryClientProvider } from '@tanstack/react-query';
|
|
17
19
|
import { createQueryClient } from '../ui/hooks/queryClient';
|
|
18
20
|
|
|
19
21
|
export interface WebAuthState {
|
|
20
|
-
user:
|
|
22
|
+
user: MinimalUserData | null;
|
|
21
23
|
isAuthenticated: boolean;
|
|
22
24
|
isLoading: boolean;
|
|
23
25
|
error: string | null;
|
|
@@ -38,12 +40,12 @@ export interface WebOxyProviderProps {
|
|
|
38
40
|
children: ReactNode;
|
|
39
41
|
baseURL: string;
|
|
40
42
|
authWebUrl?: string;
|
|
41
|
-
onAuthStateChange?: (user:
|
|
43
|
+
onAuthStateChange?: (user: MinimalUserData | null) => void;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* Web-only Oxy Provider
|
|
46
|
-
*
|
|
48
|
+
* Uses CrossDomainAuth for automatic SSO with FedCM/Popup/Redirect fallback
|
|
47
49
|
*/
|
|
48
50
|
export function WebOxyProvider({
|
|
49
51
|
children,
|
|
@@ -52,24 +54,25 @@ export function WebOxyProvider({
|
|
|
52
54
|
onAuthStateChange,
|
|
53
55
|
}: WebOxyProviderProps) {
|
|
54
56
|
const [oxyServices] = useState(() => new OxyServices({ baseURL, authWebUrl }));
|
|
55
|
-
const [
|
|
57
|
+
const [crossDomainAuth] = useState(() => createCrossDomainAuth(oxyServices));
|
|
58
|
+
const [user, setUser] = useState<MinimalUserData | null>(null);
|
|
56
59
|
const [isLoading, setIsLoading] = useState(true);
|
|
57
60
|
const [error, setError] = useState<string | null>(null);
|
|
58
61
|
const [queryClient] = useState(() => createQueryClient());
|
|
59
62
|
|
|
60
63
|
const isAuthenticated = !!user;
|
|
61
64
|
|
|
62
|
-
// Initialize -
|
|
65
|
+
// Initialize - handle callbacks, restore session, try silent sign-in
|
|
63
66
|
useEffect(() => {
|
|
64
67
|
let mounted = true;
|
|
65
68
|
|
|
66
69
|
const initAuth = async () => {
|
|
67
70
|
try {
|
|
68
|
-
//
|
|
69
|
-
const
|
|
71
|
+
// Complete initialization: handles callbacks, restores session, tries silent sign-in
|
|
72
|
+
const session = await crossDomainAuth.initialize();
|
|
70
73
|
|
|
71
|
-
if (mounted &&
|
|
72
|
-
setUser(
|
|
74
|
+
if (mounted && session?.user) {
|
|
75
|
+
setUser(session.user);
|
|
73
76
|
}
|
|
74
77
|
} catch (err) {
|
|
75
78
|
// No active session - this is fine
|
|
@@ -86,7 +89,7 @@ export function WebOxyProvider({
|
|
|
86
89
|
return () => {
|
|
87
90
|
mounted = false;
|
|
88
91
|
};
|
|
89
|
-
}, [
|
|
92
|
+
}, [crossDomainAuth]);
|
|
90
93
|
|
|
91
94
|
// Notify parent of auth state changes
|
|
92
95
|
useEffect(() => {
|
|
@@ -98,67 +101,32 @@ export function WebOxyProvider({
|
|
|
98
101
|
setIsLoading(true);
|
|
99
102
|
|
|
100
103
|
try {
|
|
101
|
-
//
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
// Sign in with automatic method selection (FedCM → Popup → Redirect)
|
|
105
|
+
const session = await crossDomainAuth.signIn({
|
|
106
|
+
method: 'auto', // Automatic fallback
|
|
107
|
+
onMethodSelected: (method) => {
|
|
108
|
+
console.log('[WebOxy] Using auth method:', method);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (session?.user) {
|
|
113
|
+
setUser(session.user);
|
|
110
114
|
}
|
|
111
|
-
|
|
112
|
-
// Listen for message from popup
|
|
113
|
-
const handleMessage = async (event: MessageEvent) => {
|
|
114
|
-
if (event.origin !== (authWebUrl || 'https://auth.oxy.so')) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (event.data.type === 'oxy-auth-success') {
|
|
119
|
-
const { accessToken, user: authUser } = event.data;
|
|
120
|
-
|
|
121
|
-
// Store the access token for API requests
|
|
122
|
-
if (typeof window !== 'undefined' && accessToken) {
|
|
123
|
-
localStorage.setItem('oxy-access-token', accessToken);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
setUser(authUser);
|
|
127
|
-
setIsLoading(false);
|
|
128
|
-
|
|
129
|
-
window.removeEventListener('message', handleMessage);
|
|
130
|
-
popup.close();
|
|
131
|
-
} else if (event.data.type === 'oxy-auth-error') {
|
|
132
|
-
setError(event.data.error || 'Authentication failed');
|
|
133
|
-
setIsLoading(false);
|
|
134
|
-
window.removeEventListener('message', handleMessage);
|
|
135
|
-
popup.close();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
window.addEventListener('message', handleMessage);
|
|
140
|
-
|
|
141
|
-
// Check if popup was closed
|
|
142
|
-
const checkClosed = setInterval(() => {
|
|
143
|
-
if (popup.closed) {
|
|
144
|
-
clearInterval(checkClosed);
|
|
145
|
-
window.removeEventListener('message', handleMessage);
|
|
146
|
-
setIsLoading(false);
|
|
147
|
-
}
|
|
148
|
-
}, 500);
|
|
149
115
|
} catch (err) {
|
|
150
116
|
console.error('[WebOxy] Sign in error:', err);
|
|
151
117
|
setError(err instanceof Error ? err.message : 'Sign in failed');
|
|
118
|
+
} finally {
|
|
152
119
|
setIsLoading(false);
|
|
153
120
|
}
|
|
154
|
-
}, [
|
|
121
|
+
}, [crossDomainAuth]);
|
|
155
122
|
|
|
156
123
|
const signOut = useCallback(async () => {
|
|
157
124
|
setError(null);
|
|
158
125
|
|
|
159
126
|
try {
|
|
160
|
-
// Clear stored
|
|
127
|
+
// Clear stored session
|
|
161
128
|
if (typeof window !== 'undefined') {
|
|
129
|
+
localStorage.removeItem('oxy-session');
|
|
162
130
|
localStorage.removeItem('oxy-access-token');
|
|
163
131
|
}
|
|
164
132
|
|
package/src/web/index.ts
CHANGED
|
@@ -69,7 +69,7 @@ export type {
|
|
|
69
69
|
} from '../models/interfaces';
|
|
70
70
|
|
|
71
71
|
// Re-export session types
|
|
72
|
-
export type { ClientSession } from '../models/session';
|
|
72
|
+
export type { ClientSession, MinimalUserData } from '../models/session';
|
|
73
73
|
|
|
74
74
|
// ==================== Utilities ====================
|
|
75
75
|
export {
|