@oxyhq/services 5.8.10 → 5.9.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/core/index.js +207 -283
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/node/index.js +0 -9
- package/lib/commonjs/node/index.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +0 -4
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js +0 -4
- package/lib/commonjs/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +16 -27
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignUpScreen.js +4 -18
- package/lib/commonjs/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/commonjs/ui/styles/authStyles.js +1 -2
- package/lib/commonjs/ui/styles/authStyles.js.map +1 -1
- package/lib/module/core/index.js +207 -283
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/node/index.js +0 -4
- package/lib/module/node/index.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +0 -4
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/RecoverAccountScreen.js +0 -4
- package/lib/module/ui/screens/RecoverAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +16 -27
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/SignUpScreen.js +4 -18
- package/lib/module/ui/screens/SignUpScreen.js.map +1 -1
- package/lib/module/ui/styles/authStyles.js +1 -2
- package/lib/module/ui/styles/authStyles.js.map +1 -1
- package/lib/typescript/core/index.d.ts +29 -79
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/node/index.d.ts +0 -2
- package/lib/typescript/node/index.d.ts.map +1 -1
- package/lib/typescript/ui/screens/FeedbackScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/RecoverAccountScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SignUpScreen.d.ts.map +1 -1
- package/lib/typescript/ui/styles/authStyles.d.ts +0 -1
- package/lib/typescript/ui/styles/authStyles.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core/index.ts +213 -254
- package/src/node/index.ts +0 -4
- package/src/ui/screens/FeedbackScreen.tsx +0 -4
- package/src/ui/screens/RecoverAccountScreen.tsx +0 -4
- package/src/ui/screens/SignInScreen.tsx +16 -20
- package/src/ui/screens/SignUpScreen.tsx +4 -14
- package/src/ui/styles/authStyles.ts +0 -1
- package/lib/commonjs/node/createAuth.js +0 -95
- package/lib/commonjs/node/createAuth.js.map +0 -1
- package/lib/module/node/createAuth.js +0 -90
- package/lib/module/node/createAuth.js.map +0 -1
- package/lib/typescript/node/createAuth.d.ts +0 -7
- package/lib/typescript/node/createAuth.d.ts.map +0 -1
- package/src/node/createAuth.ts +0 -116
|
@@ -66,13 +66,6 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
66
66
|
const logoAnim = useRef(new Animated.Value(0)).current;
|
|
67
67
|
const progressAnim = useRef(new Animated.Value(initialStep ? 1.0 : 0.5)).current;
|
|
68
68
|
|
|
69
|
-
// Ensure animations are properly initialized
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
fadeAnim.setValue(1);
|
|
72
|
-
slideAnim.setValue(0);
|
|
73
|
-
scaleAnim.setValue(1);
|
|
74
|
-
}, [fadeAnim, slideAnim, scaleAnim]);
|
|
75
|
-
|
|
76
69
|
const { login, isLoading, user, isAuthenticated, sessions, oxyServices } = useOxy();
|
|
77
70
|
|
|
78
71
|
const colors = useThemeColors(theme);
|
|
@@ -236,10 +229,17 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
236
229
|
|
|
237
230
|
// Animation functions
|
|
238
231
|
const animateTransition = useCallback((nextStep: number) => {
|
|
239
|
-
//
|
|
232
|
+
// Scale down current content
|
|
233
|
+
Animated.timing(scaleAnim, {
|
|
234
|
+
toValue: 0.95,
|
|
235
|
+
duration: 150,
|
|
236
|
+
useNativeDriver: Platform.OS !== 'web',
|
|
237
|
+
}).start();
|
|
238
|
+
|
|
239
|
+
// Fade out
|
|
240
240
|
Animated.timing(fadeAnim, {
|
|
241
|
-
toValue: 0
|
|
242
|
-
duration:
|
|
241
|
+
toValue: 0,
|
|
242
|
+
duration: 200,
|
|
243
243
|
useNativeDriver: Platform.OS !== 'web',
|
|
244
244
|
}).start(() => {
|
|
245
245
|
setCurrentStep(nextStep);
|
|
@@ -248,23 +248,23 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
248
248
|
slideAnim.setValue(-50);
|
|
249
249
|
scaleAnim.setValue(0.95);
|
|
250
250
|
|
|
251
|
-
// Animate in new content
|
|
251
|
+
// Animate in new content
|
|
252
252
|
Animated.parallel([
|
|
253
253
|
Animated.timing(fadeAnim, {
|
|
254
254
|
toValue: 1,
|
|
255
|
-
duration:
|
|
255
|
+
duration: 300,
|
|
256
256
|
useNativeDriver: Platform.OS !== 'web',
|
|
257
257
|
}),
|
|
258
258
|
Animated.spring(slideAnim, {
|
|
259
259
|
toValue: 0,
|
|
260
|
-
tension:
|
|
261
|
-
friction:
|
|
260
|
+
tension: 80,
|
|
261
|
+
friction: 8,
|
|
262
262
|
useNativeDriver: Platform.OS !== 'web',
|
|
263
263
|
}),
|
|
264
264
|
Animated.spring(scaleAnim, {
|
|
265
265
|
toValue: 1,
|
|
266
|
-
tension:
|
|
267
|
-
friction:
|
|
266
|
+
tension: 80,
|
|
267
|
+
friction: 8,
|
|
268
268
|
useNativeDriver: Platform.OS !== 'web',
|
|
269
269
|
})
|
|
270
270
|
]).start();
|
|
@@ -407,8 +407,6 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
407
407
|
<KeyboardAvoidingView
|
|
408
408
|
style={[styles.container, { backgroundColor: colors.background }]}
|
|
409
409
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
410
|
-
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : 20}
|
|
411
|
-
enabled={Platform.OS !== 'web'}
|
|
412
410
|
>
|
|
413
411
|
<StatusBar
|
|
414
412
|
barStyle={theme === 'dark' ? 'light-content' : 'dark-content'}
|
|
@@ -419,8 +417,6 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
419
417
|
contentContainerStyle={styles.scrollContent}
|
|
420
418
|
showsVerticalScrollIndicator={false}
|
|
421
419
|
keyboardShouldPersistTaps="handled"
|
|
422
|
-
keyboardDismissMode="interactive"
|
|
423
|
-
automaticallyAdjustKeyboardInsets={Platform.OS === 'ios'}
|
|
424
420
|
>
|
|
425
421
|
{renderCurrentStep()}
|
|
426
422
|
</ScrollView>
|
|
@@ -634,12 +634,6 @@ const SignUpScreen: React.FC<BaseScreenProps> = ({
|
|
|
634
634
|
const fadeAnim = useRef(new Animated.Value(1)).current;
|
|
635
635
|
const slideAnim = useRef(new Animated.Value(0)).current;
|
|
636
636
|
|
|
637
|
-
// Ensure animations are properly initialized
|
|
638
|
-
useEffect(() => {
|
|
639
|
-
fadeAnim.setValue(1);
|
|
640
|
-
slideAnim.setValue(0);
|
|
641
|
-
}, [fadeAnim, slideAnim]);
|
|
642
|
-
|
|
643
637
|
// Memoized styles
|
|
644
638
|
const styles = useMemo(() => createAuthStyles(colors, theme), [colors, theme]);
|
|
645
639
|
|
|
@@ -659,8 +653,8 @@ const SignUpScreen: React.FC<BaseScreenProps> = ({
|
|
|
659
653
|
// Animation functions
|
|
660
654
|
const animateTransition = useCallback((nextStep: number) => {
|
|
661
655
|
Animated.timing(fadeAnim, {
|
|
662
|
-
toValue: 0
|
|
663
|
-
duration:
|
|
656
|
+
toValue: 0,
|
|
657
|
+
duration: 250,
|
|
664
658
|
useNativeDriver: Platform.OS !== 'web',
|
|
665
659
|
}).start(() => {
|
|
666
660
|
setCurrentStep(nextStep);
|
|
@@ -669,12 +663,12 @@ const SignUpScreen: React.FC<BaseScreenProps> = ({
|
|
|
669
663
|
Animated.parallel([
|
|
670
664
|
Animated.timing(fadeAnim, {
|
|
671
665
|
toValue: 1,
|
|
672
|
-
duration:
|
|
666
|
+
duration: 250,
|
|
673
667
|
useNativeDriver: Platform.OS !== 'web',
|
|
674
668
|
}),
|
|
675
669
|
Animated.timing(slideAnim, {
|
|
676
670
|
toValue: 0,
|
|
677
|
-
duration:
|
|
671
|
+
duration: 300,
|
|
678
672
|
useNativeDriver: Platform.OS !== 'web',
|
|
679
673
|
})
|
|
680
674
|
]).start();
|
|
@@ -831,8 +825,6 @@ const SignUpScreen: React.FC<BaseScreenProps> = ({
|
|
|
831
825
|
<KeyboardAvoidingView
|
|
832
826
|
style={[styles.container, { backgroundColor: colors.background }]}
|
|
833
827
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
834
|
-
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : 20}
|
|
835
|
-
enabled={Platform.OS !== 'web'}
|
|
836
828
|
>
|
|
837
829
|
<StatusBar
|
|
838
830
|
barStyle={theme === 'dark' ? 'light-content' : 'dark-content'}
|
|
@@ -842,8 +834,6 @@ const SignUpScreen: React.FC<BaseScreenProps> = ({
|
|
|
842
834
|
contentContainerStyle={styles.scrollContent}
|
|
843
835
|
showsVerticalScrollIndicator={false}
|
|
844
836
|
keyboardShouldPersistTaps="handled"
|
|
845
|
-
keyboardDismissMode="interactive"
|
|
846
|
-
automaticallyAdjustKeyboardInsets={Platform.OS === 'ios'}
|
|
847
837
|
>
|
|
848
838
|
{renderCurrentStep()}
|
|
849
839
|
</ScrollView>
|
|
@@ -29,7 +29,6 @@ export const createAuthStyles = (colors: AuthThemeColors, theme: string) => Styl
|
|
|
29
29
|
flex: 1,
|
|
30
30
|
justifyContent: 'flex-start',
|
|
31
31
|
alignItems: 'flex-start',
|
|
32
|
-
backgroundColor: colors.background, // Ensure background is maintained during transitions
|
|
33
32
|
},
|
|
34
33
|
|
|
35
34
|
// Header styles
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createAuth = createAuth;
|
|
7
|
-
var _express = _interopRequireDefault(require("express"));
|
|
8
|
-
var _core = require("../core");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
function createAuth(options) {
|
|
11
|
-
const oxy = new _core.OxyServices({
|
|
12
|
-
baseURL: options.baseURL
|
|
13
|
-
});
|
|
14
|
-
const router = _express.default.Router();
|
|
15
|
-
|
|
16
|
-
// Helper to handle async route functions
|
|
17
|
-
const wrap = fn => async (req, res) => {
|
|
18
|
-
try {
|
|
19
|
-
await fn(req, res);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
res.status(err?.status || 500).json({
|
|
22
|
-
message: err?.message || 'Server error'
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
router.post('/signup', wrap(async (req, res) => {
|
|
27
|
-
const {
|
|
28
|
-
username,
|
|
29
|
-
email,
|
|
30
|
-
password
|
|
31
|
-
} = req.body;
|
|
32
|
-
const result = await oxy.signUp(username, email, password);
|
|
33
|
-
res.json(result);
|
|
34
|
-
}));
|
|
35
|
-
router.post('/login', wrap(async (req, res) => {
|
|
36
|
-
const {
|
|
37
|
-
username,
|
|
38
|
-
password
|
|
39
|
-
} = req.body;
|
|
40
|
-
const result = await oxy.login(username, password);
|
|
41
|
-
res.json(result);
|
|
42
|
-
}));
|
|
43
|
-
router.post('/logout', wrap(async (req, res) => {
|
|
44
|
-
const token = req.headers.authorization?.split(' ')[1];
|
|
45
|
-
const refreshToken = req.body.refreshToken;
|
|
46
|
-
if (token) oxy.setTokens(token, refreshToken);
|
|
47
|
-
await oxy.logout();
|
|
48
|
-
res.json({
|
|
49
|
-
success: true
|
|
50
|
-
});
|
|
51
|
-
}));
|
|
52
|
-
router.post('/refresh', wrap(async (req, res) => {
|
|
53
|
-
const refreshToken = req.body.refreshToken;
|
|
54
|
-
const accessToken = req.headers.authorization?.split(' ')[1] || '';
|
|
55
|
-
oxy.setTokens(accessToken, refreshToken);
|
|
56
|
-
const tokens = await oxy.refreshTokens();
|
|
57
|
-
res.json(tokens);
|
|
58
|
-
}));
|
|
59
|
-
router.get('/validate', wrap(async (req, res) => {
|
|
60
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
61
|
-
oxy.setTokens(token, '');
|
|
62
|
-
const valid = await oxy.validate();
|
|
63
|
-
res.json({
|
|
64
|
-
valid
|
|
65
|
-
});
|
|
66
|
-
}));
|
|
67
|
-
router.get('/sessions', wrap(async (req, res) => {
|
|
68
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
69
|
-
oxy.setTokens(token, '');
|
|
70
|
-
const sessions = await oxy.getUserSessions();
|
|
71
|
-
res.json(sessions);
|
|
72
|
-
}));
|
|
73
|
-
router.delete('/sessions/:id', wrap(async (req, res) => {
|
|
74
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
75
|
-
oxy.setTokens(token, '');
|
|
76
|
-
const result = await oxy.logoutSession(req.params.id);
|
|
77
|
-
res.json(result);
|
|
78
|
-
}));
|
|
79
|
-
router.post('/sessions/logout-others', wrap(async (req, res) => {
|
|
80
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
81
|
-
oxy.setTokens(token, '');
|
|
82
|
-
const result = await oxy.logoutOtherSessions();
|
|
83
|
-
res.json(result);
|
|
84
|
-
}));
|
|
85
|
-
router.post('/sessions/logout-all', wrap(async (req, res) => {
|
|
86
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
87
|
-
oxy.setTokens(token, '');
|
|
88
|
-
const result = await oxy.logoutAllSessions();
|
|
89
|
-
res.json(result);
|
|
90
|
-
}));
|
|
91
|
-
return {
|
|
92
|
-
middleware: router
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=createAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_express","_interopRequireDefault","require","_core","e","__esModule","default","createAuth","options","oxy","OxyServices","baseURL","router","express","Router","wrap","fn","req","res","err","status","json","message","post","username","email","password","body","result","signUp","login","token","headers","authorization","split","refreshToken","setTokens","logout","success","accessToken","tokens","refreshTokens","get","valid","validate","sessions","getUserSessions","delete","logoutSession","params","id","logoutOtherSessions","logoutAllSessions","middleware"],"sourceRoot":"../../../src","sources":["node/createAuth.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAAsC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAM/B,SAASG,UAAUA,CAACC,OAA0B,EAAE;EACrD,MAAMC,GAAG,GAAG,IAAIC,iBAAW,CAAC;IAAEC,OAAO,EAAEH,OAAO,CAACG;EAAQ,CAAC,CAAC;EACzD,MAAMC,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAC,CAAC;;EAE/B;EACA,MAAMC,IAAI,GAAIC,EAAiD,IAAK,OAClEC,GAAY,EACZC,GAAa,KACV;IACH,IAAI;MACF,MAAMF,EAAE,CAACC,GAAG,EAAEC,GAAG,CAAC;IACpB,CAAC,CAAC,OAAOC,GAAQ,EAAE;MACjBD,GAAG,CAACE,MAAM,CAACD,GAAG,EAAEC,MAAM,IAAI,GAAG,CAAC,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAEH,GAAG,EAAEG,OAAO,IAAI;MAAe,CAAC,CAAC;IAClF;EACF,CAAC;EAEDV,MAAM,CAACW,IAAI,CACT,SAAS,EACTR,IAAI,CAAC,OAAOE,GAAG,EAAEC,GAAG,KAAK;IACvB,MAAM;MAAEM,Q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';
|
|
4
|
-
import { OxyServices } from '../core';
|
|
5
|
-
export function createAuth(options) {
|
|
6
|
-
const oxy = new OxyServices({
|
|
7
|
-
baseURL: options.baseURL
|
|
8
|
-
});
|
|
9
|
-
const router = express.Router();
|
|
10
|
-
|
|
11
|
-
// Helper to handle async route functions
|
|
12
|
-
const wrap = fn => async (req, res) => {
|
|
13
|
-
try {
|
|
14
|
-
await fn(req, res);
|
|
15
|
-
} catch (err) {
|
|
16
|
-
res.status(err?.status || 500).json({
|
|
17
|
-
message: err?.message || 'Server error'
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
router.post('/signup', wrap(async (req, res) => {
|
|
22
|
-
const {
|
|
23
|
-
username,
|
|
24
|
-
email,
|
|
25
|
-
password
|
|
26
|
-
} = req.body;
|
|
27
|
-
const result = await oxy.signUp(username, email, password);
|
|
28
|
-
res.json(result);
|
|
29
|
-
}));
|
|
30
|
-
router.post('/login', wrap(async (req, res) => {
|
|
31
|
-
const {
|
|
32
|
-
username,
|
|
33
|
-
password
|
|
34
|
-
} = req.body;
|
|
35
|
-
const result = await oxy.login(username, password);
|
|
36
|
-
res.json(result);
|
|
37
|
-
}));
|
|
38
|
-
router.post('/logout', wrap(async (req, res) => {
|
|
39
|
-
const token = req.headers.authorization?.split(' ')[1];
|
|
40
|
-
const refreshToken = req.body.refreshToken;
|
|
41
|
-
if (token) oxy.setTokens(token, refreshToken);
|
|
42
|
-
await oxy.logout();
|
|
43
|
-
res.json({
|
|
44
|
-
success: true
|
|
45
|
-
});
|
|
46
|
-
}));
|
|
47
|
-
router.post('/refresh', wrap(async (req, res) => {
|
|
48
|
-
const refreshToken = req.body.refreshToken;
|
|
49
|
-
const accessToken = req.headers.authorization?.split(' ')[1] || '';
|
|
50
|
-
oxy.setTokens(accessToken, refreshToken);
|
|
51
|
-
const tokens = await oxy.refreshTokens();
|
|
52
|
-
res.json(tokens);
|
|
53
|
-
}));
|
|
54
|
-
router.get('/validate', wrap(async (req, res) => {
|
|
55
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
56
|
-
oxy.setTokens(token, '');
|
|
57
|
-
const valid = await oxy.validate();
|
|
58
|
-
res.json({
|
|
59
|
-
valid
|
|
60
|
-
});
|
|
61
|
-
}));
|
|
62
|
-
router.get('/sessions', wrap(async (req, res) => {
|
|
63
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
64
|
-
oxy.setTokens(token, '');
|
|
65
|
-
const sessions = await oxy.getUserSessions();
|
|
66
|
-
res.json(sessions);
|
|
67
|
-
}));
|
|
68
|
-
router.delete('/sessions/:id', wrap(async (req, res) => {
|
|
69
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
70
|
-
oxy.setTokens(token, '');
|
|
71
|
-
const result = await oxy.logoutSession(req.params.id);
|
|
72
|
-
res.json(result);
|
|
73
|
-
}));
|
|
74
|
-
router.post('/sessions/logout-others', wrap(async (req, res) => {
|
|
75
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
76
|
-
oxy.setTokens(token, '');
|
|
77
|
-
const result = await oxy.logoutOtherSessions();
|
|
78
|
-
res.json(result);
|
|
79
|
-
}));
|
|
80
|
-
router.post('/sessions/logout-all', wrap(async (req, res) => {
|
|
81
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
82
|
-
oxy.setTokens(token, '');
|
|
83
|
-
const result = await oxy.logoutAllSessions();
|
|
84
|
-
res.json(result);
|
|
85
|
-
}));
|
|
86
|
-
return {
|
|
87
|
-
middleware: router
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=createAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["express","OxyServices","createAuth","options","oxy","baseURL","router","Router","wrap","fn","req","res","err","status","json","message","post","username","email","password","body","result","signUp","login","token","headers","authorization","split","refreshToken","setTokens","logout","success","accessToken","tokens","refreshTokens","get","valid","validate","sessions","getUserSessions","delete","logoutSession","params","id","logo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AAC,CAAC,CAAC,IAAI,EAAE;IAC5DvB,GAAG,CAACyB,SAAS,CAACL,KAAK,EAAE,EAAE,CAAC;IACxB,MAAMH,MAAM,GAAG,MAAMjB,GAAG,CAACwC,mBAAmB,CAAC,CAAC;IAC9CjC,GAAG,CAACG,IAAI,CAACO,MAAM,CAAC;EAClB,CAAC,CACH,CAAC;EAEDf,MAAM,CAACU,IAAI,CACT,sBAAsB,EACtBR,IAAI,CAAC,OAAOE,GAAG,EAAEC,GAAG,KAAK;IACvB,MAAMa,KAAK,GAAGd,GAAG,CAACe,OAAO,CAACC,aAAa,EAAEC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;IAC5DvB,GAAG,CAACyB,SAAS,CAACL,KAAK,EAAE,EAAE,CAAC;IACxB,MAAMH,MAAM,GAAG,MAAMjB,GAAG,CAACyC,iBAAiB,CAAC,CAAC;IAC5ClC,GAAG,CAACG,IAAI,CAACO,MAAM,CAAC;EAClB,CAAC,CACH,CAAC;EAED,OAAO;IAAEyB,UAAU,EAAExC;EAAO,CAAC;AAC/B","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAuth.d.ts","sourceRoot":"","sources":["../../../src/node/createAuth.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB;;EA2GpD"}
|
package/src/node/createAuth.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import type { Request, Response } from 'express';
|
|
3
|
-
import { OxyServices } from '../core';
|
|
4
|
-
|
|
5
|
-
export interface CreateAuthOptions {
|
|
6
|
-
baseURL: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function createAuth(options: CreateAuthOptions) {
|
|
10
|
-
const oxy = new OxyServices({ baseURL: options.baseURL });
|
|
11
|
-
const router = express.Router();
|
|
12
|
-
|
|
13
|
-
// Helper to handle async route functions
|
|
14
|
-
const wrap = (fn: (req: Request, res: Response) => Promise<any>) => async (
|
|
15
|
-
req: Request,
|
|
16
|
-
res: Response
|
|
17
|
-
) => {
|
|
18
|
-
try {
|
|
19
|
-
await fn(req, res);
|
|
20
|
-
} catch (err: any) {
|
|
21
|
-
res.status(err?.status || 500).json({ message: err?.message || 'Server error' });
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
router.post(
|
|
26
|
-
'/signup',
|
|
27
|
-
wrap(async (req, res) => {
|
|
28
|
-
const { username, email, password } = req.body;
|
|
29
|
-
const result = await oxy.signUp(username, email, password);
|
|
30
|
-
res.json(result);
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
router.post(
|
|
35
|
-
'/login',
|
|
36
|
-
wrap(async (req, res) => {
|
|
37
|
-
const { username, password } = req.body;
|
|
38
|
-
const result = await oxy.login(username, password);
|
|
39
|
-
res.json(result);
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
router.post(
|
|
44
|
-
'/logout',
|
|
45
|
-
wrap(async (req, res) => {
|
|
46
|
-
const token = req.headers.authorization?.split(' ')[1];
|
|
47
|
-
const refreshToken = req.body.refreshToken;
|
|
48
|
-
if (token) oxy.setTokens(token, refreshToken);
|
|
49
|
-
await oxy.logout();
|
|
50
|
-
res.json({ success: true });
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
router.post(
|
|
55
|
-
'/refresh',
|
|
56
|
-
wrap(async (req, res) => {
|
|
57
|
-
const refreshToken = req.body.refreshToken;
|
|
58
|
-
const accessToken = req.headers.authorization?.split(' ')[1] || '';
|
|
59
|
-
oxy.setTokens(accessToken, refreshToken);
|
|
60
|
-
const tokens = await oxy.refreshTokens();
|
|
61
|
-
res.json(tokens);
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
router.get(
|
|
66
|
-
'/validate',
|
|
67
|
-
wrap(async (req, res) => {
|
|
68
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
69
|
-
oxy.setTokens(token, '');
|
|
70
|
-
const valid = await oxy.validate();
|
|
71
|
-
res.json({ valid });
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
router.get(
|
|
76
|
-
'/sessions',
|
|
77
|
-
wrap(async (req, res) => {
|
|
78
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
79
|
-
oxy.setTokens(token, '');
|
|
80
|
-
const sessions = await oxy.getUserSessions();
|
|
81
|
-
res.json(sessions);
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
router.delete(
|
|
86
|
-
'/sessions/:id',
|
|
87
|
-
wrap(async (req, res) => {
|
|
88
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
89
|
-
oxy.setTokens(token, '');
|
|
90
|
-
const result = await oxy.logoutSession(req.params.id);
|
|
91
|
-
res.json(result);
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
router.post(
|
|
96
|
-
'/sessions/logout-others',
|
|
97
|
-
wrap(async (req, res) => {
|
|
98
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
99
|
-
oxy.setTokens(token, '');
|
|
100
|
-
const result = await oxy.logoutOtherSessions();
|
|
101
|
-
res.json(result);
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
router.post(
|
|
106
|
-
'/sessions/logout-all',
|
|
107
|
-
wrap(async (req, res) => {
|
|
108
|
-
const token = req.headers.authorization?.split(' ')[1] || '';
|
|
109
|
-
oxy.setTokens(token, '');
|
|
110
|
-
const result = await oxy.logoutAllSessions();
|
|
111
|
-
res.json(result);
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
return { middleware: router };
|
|
116
|
-
}
|