@oxyhq/services 5.18.2 → 5.18.4
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/mixins/index.js +36 -13
- package/lib/commonjs/core/mixins/index.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/client.js +177 -0
- package/lib/commonjs/ui/client.js.map +1 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js +98 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js +412 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +63 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +115 -0
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSettingToggle.js +7 -1
- package/lib/commonjs/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/commonjs/ui/hooks/useWebSSO.js +75 -0
- package/lib/commonjs/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/commonjs/ui/index.js +17 -2
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js +38 -58
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/server.js +105 -0
- package/lib/commonjs/ui/server.js.map +1 -0
- package/lib/commonjs/ui/utils/iconNames.js +133 -0
- package/lib/commonjs/ui/utils/iconNames.js.map +1 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js +7 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/requestUtils.js +4 -3
- package/lib/commonjs/utils/requestUtils.js.map +1 -1
- package/lib/module/core/mixins/index.js +36 -13
- package/lib/module/core/mixins/index.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/client.js +48 -0
- package/lib/module/ui/client.js.map +1 -0
- package/lib/module/ui/components/WebOxyProvider.js +94 -0
- package/lib/module/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/module/ui/components/profile/EditFieldModal.js +406 -0
- package/lib/module/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +63 -1
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +106 -0
- package/lib/module/ui/hooks/useAuth.js.map +1 -0
- package/lib/module/ui/hooks/useSettingToggle.js +7 -1
- package/lib/module/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/module/ui/hooks/useWebSSO.js +71 -0
- package/lib/module/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/module/ui/index.js +17 -3
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/SearchSettingsScreen.js +39 -59
- package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/module/ui/server.js +65 -0
- package/lib/module/ui/server.js.map +1 -0
- package/lib/module/ui/utils/iconNames.js +124 -0
- package/lib/module/ui/utils/iconNames.js.map +1 -0
- package/lib/module/ui/utils/sessionHelpers.js +7 -0
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/requestUtils.js +4 -2
- package/lib/module/utils/requestUtils.js.map +1 -1
- package/lib/typescript/commonjs/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/commonjs/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +34 -0
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/index.d.ts +2 -2
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/server.d.ts +43 -0
- package/lib/typescript/commonjs/ui/server.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts.map +1 -1
- package/lib/typescript/module/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/module/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +34 -0
- package/lib/typescript/module/ui/client.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/module/ui/index.d.ts +2 -2
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/server.d.ts +43 -0
- package/lib/typescript/module/ui/server.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/module/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/module/utils/requestUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/mixins/index.ts +57 -43
- package/src/index.ts +6 -1
- package/src/ui/client.ts +56 -0
- package/src/ui/components/WebOxyProvider.tsx +109 -0
- package/src/ui/components/profile/EditFieldModal.tsx +465 -0
- package/src/ui/context/OxyContext.tsx +69 -0
- package/src/ui/hooks/useAuth.ts +159 -0
- package/src/ui/hooks/useSettingToggle.ts +7 -3
- package/src/ui/hooks/useWebSSO.ts +93 -0
- package/src/ui/index.ts +17 -2
- package/src/ui/screens/PrivacySettingsScreen.tsx +54 -63
- package/src/ui/screens/SearchSettingsScreen.tsx +42 -64
- package/src/ui/server.ts +70 -0
- package/src/ui/utils/iconNames.ts +136 -0
- package/src/ui/utils/sessionHelpers.ts +10 -3
- package/src/utils/requestUtils.ts +10 -7
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-safe UI exports (noops)
|
|
3
|
+
*
|
|
4
|
+
* Import from this module for SSR environments where React components
|
|
5
|
+
* shouldn't be rendered on the server.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { OxyProvider, useOxy } from '@oxyhq/services/ui/server';
|
|
9
|
+
*/
|
|
10
|
+
export declare const OxyProvider: () => null;
|
|
11
|
+
export declare const OxySignInButton: () => null;
|
|
12
|
+
export declare const OxyLogo: () => null;
|
|
13
|
+
export declare const Avatar: () => null;
|
|
14
|
+
export declare const FollowButton: () => null;
|
|
15
|
+
export declare const OxyPayButton: () => null;
|
|
16
|
+
export declare const FontLoader: () => null;
|
|
17
|
+
export declare const setupFonts: () => void;
|
|
18
|
+
export declare const OxyIcon: () => null;
|
|
19
|
+
export declare const useOxy: () => {};
|
|
20
|
+
export declare const useAuth: () => {};
|
|
21
|
+
export declare const useFollow: () => {};
|
|
22
|
+
export declare const useStorage: () => {
|
|
23
|
+
storage: null;
|
|
24
|
+
isReady: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const ProfileScreen: () => null;
|
|
27
|
+
export declare const useAuthStore: () => {};
|
|
28
|
+
export declare const useAccountStore: () => {};
|
|
29
|
+
export declare const fontFamilies: {};
|
|
30
|
+
export declare const fontStyles: {};
|
|
31
|
+
export declare const toast: (() => void) & {
|
|
32
|
+
success: () => void;
|
|
33
|
+
error: () => void;
|
|
34
|
+
info: () => void;
|
|
35
|
+
warning: () => void;
|
|
36
|
+
loading: () => void;
|
|
37
|
+
dismiss: () => void;
|
|
38
|
+
};
|
|
39
|
+
export { OxyServices } from '../core';
|
|
40
|
+
export type { User, LoginResponse, ApiError } from '../models/interfaces';
|
|
41
|
+
export { handleAuthError, isInvalidSessionError, isTimeoutOrNetworkError, extractErrorMessage, } from './utils/errorHandlers';
|
|
42
|
+
export type { HandleAuthErrorOptions } from './utils/errorHandlers';
|
|
43
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/ui/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,eAAO,MAAM,WAAW,YAAgB,CAAC;AACzC,eAAO,MAAM,eAAe,YAAgB,CAAC;AAC7C,eAAO,MAAM,OAAO,YAAgB,CAAC;AACrC,eAAO,MAAM,MAAM,YAAgB,CAAC;AACpC,eAAO,MAAM,YAAY,YAAgB,CAAC;AAC1C,eAAO,MAAM,YAAY,YAAgB,CAAC;AAC1C,eAAO,MAAM,UAAU,YAAgB,CAAC;AACxC,eAAO,MAAM,UAAU,YAAW,CAAC;AACnC,eAAO,MAAM,OAAO,YAAgB,CAAC;AAGrC,eAAO,MAAM,MAAM,UAAW,CAAC;AAG/B,eAAO,MAAM,OAAO,UAAW,CAAC;AAChC,eAAO,MAAM,SAAS,UAAW,CAAC;AAClC,eAAO,MAAM,UAAU;;;CAA0B,CAAC;AAGlD,eAAO,MAAM,aAAa,YAAgB,CAAC;AAG3C,eAAO,MAAM,YAAY,UAAW,CAAC;AACrC,eAAO,MAAM,eAAe,UAAW,CAAC;AAGxC,eAAO,MAAM,YAAY,IAAK,CAAC;AAC/B,eAAO,MAAM,UAAU,IAAK,CAAC;AAG7B,eAAO,MAAM,KAAK;;;;;;;CAUjB,CAAC;AAGF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EACH,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe icon name utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides centralized, typed icon name mappings to eliminate `as any` casts
|
|
5
|
+
* when using dynamic icon names with @expo/vector-icons.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Profile field icons (MaterialCommunityIcons)
|
|
9
|
+
*/
|
|
10
|
+
export declare const PROFILE_FIELD_ICONS: {
|
|
11
|
+
readonly displayName: "account-outline";
|
|
12
|
+
readonly username: "at";
|
|
13
|
+
readonly email: "email-outline";
|
|
14
|
+
readonly bio: "text-box-outline";
|
|
15
|
+
readonly location: "map-marker-outline";
|
|
16
|
+
readonly links: "link-variant";
|
|
17
|
+
readonly website: "web";
|
|
18
|
+
readonly phone: "phone-outline";
|
|
19
|
+
readonly birthday: "cake-variant-outline";
|
|
20
|
+
};
|
|
21
|
+
export type ProfileFieldIconKey = keyof typeof PROFILE_FIELD_ICONS;
|
|
22
|
+
/**
|
|
23
|
+
* Get icon name for a profile field
|
|
24
|
+
*/
|
|
25
|
+
export declare function getProfileFieldIcon(field: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Settings section icons (MaterialCommunityIcons)
|
|
28
|
+
*/
|
|
29
|
+
export declare const SETTINGS_ICONS: {
|
|
30
|
+
readonly account: "account-cog-outline";
|
|
31
|
+
readonly privacy: "shield-account-outline";
|
|
32
|
+
readonly security: "lock-outline";
|
|
33
|
+
readonly notifications: "bell-outline";
|
|
34
|
+
readonly language: "translate";
|
|
35
|
+
readonly appearance: "palette-outline";
|
|
36
|
+
readonly storage: "folder-outline";
|
|
37
|
+
readonly help: "help-circle-outline";
|
|
38
|
+
readonly about: "information-outline";
|
|
39
|
+
readonly logout: "logout";
|
|
40
|
+
};
|
|
41
|
+
export type SettingsIconKey = keyof typeof SETTINGS_ICONS;
|
|
42
|
+
/**
|
|
43
|
+
* Get icon name for a settings section
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSettingsIcon(section: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* File type icons (MaterialCommunityIcons)
|
|
48
|
+
*/
|
|
49
|
+
export declare const FILE_TYPE_ICONS: {
|
|
50
|
+
readonly image: "image-outline";
|
|
51
|
+
readonly video: "video-outline";
|
|
52
|
+
readonly audio: "music-note-outline";
|
|
53
|
+
readonly document: "file-document-outline";
|
|
54
|
+
readonly pdf: "file-pdf-box";
|
|
55
|
+
readonly archive: "folder-zip-outline";
|
|
56
|
+
readonly code: "code-tags";
|
|
57
|
+
readonly spreadsheet: "file-excel-outline";
|
|
58
|
+
readonly presentation: "file-presentation-outline";
|
|
59
|
+
readonly text: "file-document-edit-outline";
|
|
60
|
+
readonly unknown: "file-outline";
|
|
61
|
+
};
|
|
62
|
+
export type FileTypeIconKey = keyof typeof FILE_TYPE_ICONS;
|
|
63
|
+
/**
|
|
64
|
+
* Get icon name for a file type
|
|
65
|
+
*/
|
|
66
|
+
export declare function getFileTypeIcon(type: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Action icons (Ionicons)
|
|
69
|
+
*/
|
|
70
|
+
export declare const ACTION_ICONS: {
|
|
71
|
+
readonly close: "close";
|
|
72
|
+
readonly back: "chevron-back";
|
|
73
|
+
readonly forward: "chevron-forward";
|
|
74
|
+
readonly add: "add";
|
|
75
|
+
readonly remove: "remove";
|
|
76
|
+
readonly delete: "trash-outline";
|
|
77
|
+
readonly edit: "pencil-outline";
|
|
78
|
+
readonly save: "checkmark";
|
|
79
|
+
readonly cancel: "close";
|
|
80
|
+
readonly search: "search-outline";
|
|
81
|
+
readonly filter: "filter-outline";
|
|
82
|
+
readonly sort: "swap-vertical-outline";
|
|
83
|
+
readonly refresh: "refresh-outline";
|
|
84
|
+
readonly share: "share-outline";
|
|
85
|
+
readonly copy: "copy-outline";
|
|
86
|
+
readonly download: "download-outline";
|
|
87
|
+
readonly upload: "cloud-upload-outline";
|
|
88
|
+
};
|
|
89
|
+
export type ActionIconKey = keyof typeof ACTION_ICONS;
|
|
90
|
+
/**
|
|
91
|
+
* Get icon name for an action
|
|
92
|
+
*/
|
|
93
|
+
export declare function getActionIcon(action: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Status icons (Ionicons)
|
|
96
|
+
*/
|
|
97
|
+
export declare const STATUS_ICONS: {
|
|
98
|
+
readonly success: "checkmark-circle";
|
|
99
|
+
readonly error: "alert-circle";
|
|
100
|
+
readonly warning: "warning";
|
|
101
|
+
readonly info: "information-circle";
|
|
102
|
+
readonly loading: "hourglass-outline";
|
|
103
|
+
readonly pending: "time-outline";
|
|
104
|
+
readonly online: "ellipse";
|
|
105
|
+
readonly offline: "ellipse-outline";
|
|
106
|
+
};
|
|
107
|
+
export type StatusIconKey = keyof typeof STATUS_ICONS;
|
|
108
|
+
/**
|
|
109
|
+
* Get icon name for a status
|
|
110
|
+
*/
|
|
111
|
+
export declare function getStatusIcon(status: string): string;
|
|
112
|
+
//# sourceMappingURL=iconNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconNames.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/iconNames.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;CAUtB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,cAAc,CAAC;AAE1D;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;CAYlB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;CAkBf,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AAEtD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { OxyServices } from '../../core';
|
|
2
1
|
import type { ClientSession } from '../../models/session';
|
|
3
2
|
interface DeviceSession {
|
|
4
3
|
sessionId: string;
|
|
@@ -15,6 +14,12 @@ interface DeviceSession {
|
|
|
15
14
|
userId?: string;
|
|
16
15
|
isCurrent?: boolean;
|
|
17
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Service type for session helpers.
|
|
19
|
+
* Uses 'any' to work around TypeScript mixin composition type inference issues.
|
|
20
|
+
* The OxyServices class has these methods but TypeScript can't see them due to the mixin pattern.
|
|
21
|
+
*/
|
|
22
|
+
type OxyServicesAny = any;
|
|
18
23
|
export interface FetchSessionsWithFallbackOptions {
|
|
19
24
|
fallbackDeviceId?: string;
|
|
20
25
|
fallbackUserId?: string;
|
|
@@ -46,7 +51,7 @@ export declare const mapSessionsToClient: (sessions: DeviceSession[], fallbackDe
|
|
|
46
51
|
* @param sessionId - Session identifier to fetch
|
|
47
52
|
* @param options - Optional fallback options
|
|
48
53
|
*/
|
|
49
|
-
export declare const fetchSessionsWithFallback: (oxyServices:
|
|
54
|
+
export declare const fetchSessionsWithFallback: (oxyServices: OxyServicesAny, sessionId: string, { fallbackDeviceId, fallbackUserId, logger, }?: FetchSessionsWithFallbackOptions) => Promise<ClientSession[]>;
|
|
50
55
|
/**
|
|
51
56
|
* Validate multiple sessions concurrently with configurable concurrency.
|
|
52
57
|
*
|
|
@@ -54,6 +59,6 @@ export declare const fetchSessionsWithFallback: (oxyServices: Pick<OxyServices,
|
|
|
54
59
|
* @param sessionIds - Session identifiers to validate
|
|
55
60
|
* @param options - Validation options
|
|
56
61
|
*/
|
|
57
|
-
export declare const validateSessionBatch: (oxyServices:
|
|
62
|
+
export declare const validateSessionBatch: (oxyServices: OxyServicesAny, sessionIds: string[], { useHeaderValidation, maxConcurrency }?: ValidateSessionBatchOptions) => Promise<SessionValidationResult[]>;
|
|
58
63
|
export {};
|
|
59
64
|
//# sourceMappingURL=sessionHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/sessionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sessionHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/sessionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE;YAAE,QAAQ,IAAI,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AAEH,KAAK,cAAc,GAAG,GAAG,CAAC;AAE1B,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,2BAA2B;IAC1C,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,aAAa,EAAE,EACzB,mBAAmB,MAAM,EACzB,iBAAiB,MAAM,KACtB,aAAa,EAgBf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACpC,aAAa,cAAc,EAC3B,WAAW,MAAM,EACjB,gDAIG,gCAAqC,KACvC,OAAO,CAAC,aAAa,EAAE,CAYzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,aAAa,cAAc,EAC3B,YAAY,MAAM,EAAE,EACpB,0CAAoD,2BAAgC,KACnF,OAAO,CAAC,uBAAuB,EAAE,CAuCnC,CAAC"}
|
|
@@ -87,6 +87,8 @@ export declare class RequestQueue {
|
|
|
87
87
|
*/
|
|
88
88
|
runningCount(): number;
|
|
89
89
|
}
|
|
90
|
+
/** Log level type for SimpleLogger */
|
|
91
|
+
export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
90
92
|
/**
|
|
91
93
|
* Simple logger with level support
|
|
92
94
|
*
|
|
@@ -111,7 +113,7 @@ export declare class SimpleLogger {
|
|
|
111
113
|
* @param level Minimum log level
|
|
112
114
|
* @param prefix Prefix for log messages (default: '')
|
|
113
115
|
*/
|
|
114
|
-
constructor(enabled?: boolean, level?:
|
|
116
|
+
constructor(enabled?: boolean, level?: LogLevel, prefix?: string);
|
|
115
117
|
private shouldLog;
|
|
116
118
|
private formatMessage;
|
|
117
119
|
error(...args: any[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/requestUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,eAAe,CAAmC;IAE1D;;;;;OAKG;IACG,WAAW,CAAC,CAAC,EACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC;IAeb;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;CAGf;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;OAIG;gBACS,aAAa,GAAE,MAAW,EAAE,YAAY,GAAE,MAAY;IAKlE;;;;OAIG;IACG,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBzD;;OAEG;YACW,OAAO;IAmBrB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,YAAY,IAAI,MAAM;CAGvB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"requestUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/requestUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,eAAe,CAAmC;IAE1D;;;;;OAKG;IACG,WAAW,CAAC,CAAC,EACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC;IAeb;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;CAGf;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;OAIG;gBACS,aAAa,GAAE,MAAW,EAAE,YAAY,GAAE,MAAY;IAKlE;;;;OAIG;IACG,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBzD;;OAEG;YACW,OAAO;IAmBrB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,YAAY,IAAI,MAAM;CAGvB;AAED,sCAAsC;AACtC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;;OAKG;gBAED,OAAO,GAAE,OAAe,EACxB,KAAK,GAAE,QAAkB,EACzB,MAAM,GAAE,MAAW;IAOrB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,aAAa;IAIrB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAK5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.4",
|
|
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",
|
package/src/core/mixins/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized mixin exports and composition helper
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides a clean way to compose all mixins
|
|
5
5
|
* and ensures consistent ordering for better maintainability
|
|
6
6
|
*/
|
|
@@ -24,54 +24,68 @@ import { OxyServicesSecurityMixin } from './OxyServices.security';
|
|
|
24
24
|
import { OxyServicesUtilityMixin } from './OxyServices.utility';
|
|
25
25
|
import { OxyServicesFeaturesMixin } from './OxyServices.features';
|
|
26
26
|
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
type MixinFunction = (Base: any) => any;
|
|
29
|
+
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
31
|
+
* Mixin pipeline - applied in order from first to last.
|
|
29
32
|
*
|
|
30
|
-
* Order matters for
|
|
31
|
-
*
|
|
33
|
+
* Order matters for dependencies:
|
|
34
|
+
* 1. Base auth mixin first (required by all others)
|
|
35
|
+
* 2. Cross-domain auth mixins (FedCM, Popup, Redirect)
|
|
36
|
+
* 3. User mixin (requires auth)
|
|
37
|
+
* 4. Feature mixins (can depend on user)
|
|
38
|
+
* 5. Utility mixin last (augments all)
|
|
32
39
|
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
* To add a new mixin: insert it at the appropriate position in this array.
|
|
41
|
+
*/
|
|
42
|
+
const MIXIN_PIPELINE: MixinFunction[] = [
|
|
43
|
+
// Base authentication
|
|
44
|
+
OxyServicesAuthMixin,
|
|
45
|
+
|
|
46
|
+
// Cross-domain authentication (web-only)
|
|
47
|
+
// - FedCM: Modern browser-native identity federation (Google-style)
|
|
48
|
+
// - Popup: OAuth2-style popup authentication
|
|
49
|
+
// - Redirect: Traditional redirect-based authentication
|
|
50
|
+
OxyServicesFedCMMixin,
|
|
51
|
+
OxyServicesPopupAuthMixin,
|
|
52
|
+
OxyServicesRedirectAuthMixin,
|
|
53
|
+
|
|
54
|
+
// User management (requires auth)
|
|
55
|
+
OxyServicesUserMixin,
|
|
56
|
+
OxyServicesPrivacyMixin,
|
|
57
|
+
|
|
58
|
+
// Feature mixins
|
|
59
|
+
OxyServicesLanguageMixin,
|
|
60
|
+
OxyServicesPaymentMixin,
|
|
61
|
+
OxyServicesKarmaMixin,
|
|
62
|
+
OxyServicesAssetsMixin,
|
|
63
|
+
OxyServicesDeveloperMixin,
|
|
64
|
+
OxyServicesLocationMixin,
|
|
65
|
+
OxyServicesAnalyticsMixin,
|
|
66
|
+
OxyServicesDevicesMixin,
|
|
67
|
+
OxyServicesSecurityMixin,
|
|
68
|
+
OxyServicesFeaturesMixin,
|
|
69
|
+
|
|
70
|
+
// Utility (last, can use all above)
|
|
71
|
+
OxyServicesUtilityMixin,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Composes all OxyServices mixins using a pipeline pattern.
|
|
76
|
+
*
|
|
77
|
+
* This is equivalent to the nested calls but more readable and maintainable.
|
|
78
|
+
* Adding a new mixin: just add it to MIXIN_PIPELINE at the appropriate position.
|
|
37
79
|
*
|
|
38
80
|
* @returns The fully composed OxyServices class with all mixins applied
|
|
39
81
|
*/
|
|
40
82
|
export function composeOxyServices() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
OxyServicesAnalyticsMixin(
|
|
46
|
-
OxyServicesLocationMixin(
|
|
47
|
-
OxyServicesDeveloperMixin(
|
|
48
|
-
OxyServicesAssetsMixin(
|
|
49
|
-
OxyServicesKarmaMixin(
|
|
50
|
-
OxyServicesPaymentMixin(
|
|
51
|
-
OxyServicesLanguageMixin(
|
|
52
|
-
OxyServicesPrivacyMixin(
|
|
53
|
-
OxyServicesUserMixin(
|
|
54
|
-
// Cross-domain authentication mixins (web-only)
|
|
55
|
-
OxyServicesRedirectAuthMixin(
|
|
56
|
-
OxyServicesPopupAuthMixin(
|
|
57
|
-
OxyServicesFedCMMixin(
|
|
58
|
-
// Base authentication mixin
|
|
59
|
-
OxyServicesAuthMixin(OxyServicesBase)
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
)
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
)
|
|
67
|
-
)
|
|
68
|
-
)
|
|
69
|
-
)
|
|
70
|
-
)
|
|
71
|
-
)
|
|
72
|
-
)
|
|
73
|
-
)
|
|
74
|
-
)
|
|
75
|
-
);
|
|
83
|
+
return MIXIN_PIPELINE.reduce(
|
|
84
|
+
(Base, mixin) => mixin(Base),
|
|
85
|
+
OxyServicesBase as unknown as ReturnType<MixinFunction>
|
|
86
|
+
);
|
|
76
87
|
}
|
|
77
88
|
|
|
89
|
+
// Export the pipeline for testing/debugging
|
|
90
|
+
export { MIXIN_PIPELINE };
|
|
91
|
+
|
package/src/index.ts
CHANGED
|
@@ -31,12 +31,17 @@ export type {
|
|
|
31
31
|
RecoveryPhraseResult
|
|
32
32
|
} from './crypto';
|
|
33
33
|
|
|
34
|
-
// React context
|
|
34
|
+
// React context and auth hooks
|
|
35
35
|
export { useOxy } from './ui/context/OxyContext';
|
|
36
|
+
export { useAuth } from './ui/hooks/useAuth';
|
|
37
|
+
export type { AuthState, AuthActions, UseAuthReturn } from './ui/hooks/useAuth';
|
|
36
38
|
|
|
37
39
|
// Streamlined provider with built-in bottom sheet
|
|
38
40
|
export { default as OxyProvider } from './ui/components/OxyProvider';
|
|
39
41
|
|
|
42
|
+
// Web-only provider (no React Native dependencies)
|
|
43
|
+
export { default as WebOxyProvider } from './ui/components/WebOxyProvider';
|
|
44
|
+
|
|
40
45
|
// Device management
|
|
41
46
|
export { DeviceManager } from './utils/deviceManager';
|
|
42
47
|
export type { DeviceFingerprint, StoredDeviceInfo } from './utils/deviceManager';
|
package/src/ui/client.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-only UI exports (tree-shakeable)
|
|
3
|
+
*
|
|
4
|
+
* Import from this module for client-side bundles where tree-shaking is important.
|
|
5
|
+
* These are direct exports without runtime detection overhead.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import { OxyProvider, useOxy, Avatar } from '@oxyhq/services/ui/client';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Components
|
|
12
|
+
export { default as OxyProvider } from './components/OxyProvider';
|
|
13
|
+
export { default as WebOxyProvider } from './components/WebOxyProvider';
|
|
14
|
+
export { default as OxySignInButton } from './components/OxySignInButton';
|
|
15
|
+
export { default as OxyLogo } from './components/OxyLogo';
|
|
16
|
+
export { default as Avatar } from './components/Avatar';
|
|
17
|
+
export { default as FollowButton } from './components/FollowButton';
|
|
18
|
+
export { default as OxyPayButton } from './components/OxyPayButton';
|
|
19
|
+
export { FontLoader, setupFonts } from './components/FontLoader';
|
|
20
|
+
export { OxyIcon } from './components/icon';
|
|
21
|
+
|
|
22
|
+
// Context
|
|
23
|
+
export { useOxy } from './context/OxyContext';
|
|
24
|
+
|
|
25
|
+
// Hooks
|
|
26
|
+
export { useAuth } from './hooks/useAuth';
|
|
27
|
+
export type { AuthState, AuthActions, UseAuthReturn } from './hooks/useAuth';
|
|
28
|
+
export { useFollow } from './hooks';
|
|
29
|
+
export { useStorage } from './hooks/useStorage';
|
|
30
|
+
export type { UseStorageOptions, UseStorageResult } from './hooks/useStorage';
|
|
31
|
+
|
|
32
|
+
// Screens
|
|
33
|
+
export { default as ProfileScreen } from './screens/ProfileScreen';
|
|
34
|
+
|
|
35
|
+
// Stores
|
|
36
|
+
export { useAuthStore } from './stores/authStore';
|
|
37
|
+
export { useAccountStore } from './stores/accountStore';
|
|
38
|
+
|
|
39
|
+
// Styles
|
|
40
|
+
export { fontFamilies, fontStyles } from './styles/fonts';
|
|
41
|
+
|
|
42
|
+
// Toast
|
|
43
|
+
export { toast } from '../lib/sonner';
|
|
44
|
+
|
|
45
|
+
// Core re-exports for convenience
|
|
46
|
+
export { OxyServices } from '../core';
|
|
47
|
+
export type { User, LoginResponse, ApiError } from '../models/interfaces';
|
|
48
|
+
|
|
49
|
+
// Error handler utilities
|
|
50
|
+
export {
|
|
51
|
+
handleAuthError,
|
|
52
|
+
isInvalidSessionError,
|
|
53
|
+
isTimeoutOrNetworkError,
|
|
54
|
+
extractErrorMessage,
|
|
55
|
+
} from './utils/errorHandlers';
|
|
56
|
+
export type { HandleAuthErrorOptions } from './utils/errorHandlers';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebOxyProvider - OxyProvider for web apps (Next.js, React)
|
|
3
|
+
*
|
|
4
|
+
* This provider is specifically for web environments and doesn't include
|
|
5
|
+
* React Native-specific dependencies. It provides:
|
|
6
|
+
* - Automatic cross-domain SSO via hidden iframe
|
|
7
|
+
* - Session management
|
|
8
|
+
* - All useOxy/useAuth functionality
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { WebOxyProvider, useAuth } from '@oxyhq/services';
|
|
13
|
+
*
|
|
14
|
+
* function App() {
|
|
15
|
+
* return (
|
|
16
|
+
* <WebOxyProvider baseURL="https://api.oxy.so">
|
|
17
|
+
* <YourApp />
|
|
18
|
+
* </WebOxyProvider>
|
|
19
|
+
* );
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { useEffect, useRef, useState, type FC, type ReactNode } from 'react';
|
|
25
|
+
import { OxyContextProvider } from '../context/OxyContext';
|
|
26
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
27
|
+
import { createQueryClient } from '../hooks/queryClient';
|
|
28
|
+
import { createPlatformStorage, type StorageInterface } from '../utils/storageHelpers';
|
|
29
|
+
|
|
30
|
+
export interface WebOxyProviderProps {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
baseURL: string;
|
|
33
|
+
authWebUrl?: string;
|
|
34
|
+
onAuthStateChange?: (user: any) => void;
|
|
35
|
+
storageKeyPrefix?: string;
|
|
36
|
+
queryClient?: ReturnType<typeof createQueryClient>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* OxyProvider for web applications
|
|
41
|
+
*
|
|
42
|
+
* Features:
|
|
43
|
+
* - Automatic cross-domain SSO (checks auth.oxy.so/auth/silent on mount)
|
|
44
|
+
* - Session persistence in localStorage
|
|
45
|
+
* - TanStack Query for data fetching
|
|
46
|
+
* - No React Native dependencies
|
|
47
|
+
*/
|
|
48
|
+
const WebOxyProvider: FC<WebOxyProviderProps> = ({
|
|
49
|
+
children,
|
|
50
|
+
baseURL,
|
|
51
|
+
authWebUrl,
|
|
52
|
+
onAuthStateChange,
|
|
53
|
+
storageKeyPrefix,
|
|
54
|
+
queryClient: providedQueryClient,
|
|
55
|
+
}) => {
|
|
56
|
+
const storageRef = useRef<StorageInterface | null>(null);
|
|
57
|
+
const queryClientRef = useRef<ReturnType<typeof createQueryClient> | null>(null);
|
|
58
|
+
const [queryClient, setQueryClient] = useState<ReturnType<typeof createQueryClient> | null>(null);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (providedQueryClient) {
|
|
62
|
+
queryClientRef.current = providedQueryClient;
|
|
63
|
+
setQueryClient(providedQueryClient);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let mounted = true;
|
|
68
|
+
createPlatformStorage()
|
|
69
|
+
.then((storage) => {
|
|
70
|
+
if (mounted && !queryClientRef.current) {
|
|
71
|
+
storageRef.current = storage;
|
|
72
|
+
const client = createQueryClient(storage);
|
|
73
|
+
queryClientRef.current = client;
|
|
74
|
+
setQueryClient(client);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.catch(() => {
|
|
78
|
+
if (mounted && !queryClientRef.current) {
|
|
79
|
+
const client = createQueryClient(null);
|
|
80
|
+
queryClientRef.current = client;
|
|
81
|
+
setQueryClient(client);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
mounted = false;
|
|
87
|
+
};
|
|
88
|
+
}, [providedQueryClient]);
|
|
89
|
+
|
|
90
|
+
// Wait for query client to be ready
|
|
91
|
+
if (!queryClient) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<QueryClientProvider client={queryClient}>
|
|
97
|
+
<OxyContextProvider
|
|
98
|
+
baseURL={baseURL}
|
|
99
|
+
authWebUrl={authWebUrl}
|
|
100
|
+
storageKeyPrefix={storageKeyPrefix}
|
|
101
|
+
onAuthStateChange={onAuthStateChange}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</OxyContextProvider>
|
|
105
|
+
</QueryClientProvider>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default WebOxyProvider;
|