From 6b85ebd4d42852ffd42d258d1f42ccc2ef09cafb Mon Sep 17 00:00:00 2001 From: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:47:10 +0300 Subject: [PATCH] Working Social Login buttons in prod For google at least. --- Cargo.lock | Bin 304524 -> 306716 bytes apps/desktop/package.json | 1 + apps/desktop/src-tauri/Cargo.toml | 1 + .../src-tauri/capabilities/default.json | 20 ++++++++++++++++-- apps/desktop/src-tauri/src/main.rs | 1 + apps/desktop/src/App.tsx | 4 ++++ core/src/node/hardware.rs | 1 + .../Layout/Sidebar/DebugPopover.tsx | 15 +++++++------ .../app/$libraryId/{ => Layout}/auth.tsx | 5 +++-- interface/app/$libraryId/index.tsx | 2 +- .../settings/client/account/Tabs.tsx | 2 +- packages/client/src/core.ts | 8 ++++--- pnpm-lock.yaml | Bin 1053825 -> 1054371 bytes 13 files changed, 44 insertions(+), 16 deletions(-) rename interface/app/$libraryId/{ => Layout}/auth.tsx (94%) diff --git a/Cargo.lock b/Cargo.lock index 8b5deaa492e4f0303caafef8ccd349ab9f7325ae..6c68fb83c1d9bf374dc550fc7a358b9b69208658 100644 GIT binary patch delta 1119 zcmZXTOK6-`6vw&WH{{h|lh`JMMIA?owV2_)9}6?6X{FUgo32EO+^0?wJ7Z=Nt)l40 zkW``YE$+e+AzM+5Qa;6vB6ML9Be+ly>kF}>po=bC=}l5aadpo*_j2wz=l?q|Umm;g z)!18~trwrJ9f)&HFx#Zg`9O#!L}`V*mMR!V5JSd6O}SJySdRr{%wmOH&|E3Xs9+9b zD`?z00mh5<_4|j~3oZX>x7S|s#i2h;lPW?zH^NJb6r$2_9~f5*IxK_^l5qq%G>q%u znDSU_7nC$irSG`W#puQaZSUl)!3L5IRKIJeR&Tj8I{B;tciqMIW4mW(*(|nfcR7UC z)5X@@!T8B0sP@(Bz19;x-ZPxli;vIkf9LDJJmhgjoS}^o64US zvM-NTyNgr3vmM{953Ts6ZmWH!c6Y6g8!(POnVp^{)?h`0ms|^KjSWd%N+~l$I4yXp zQ8B8#@m>>((v+=8)e`}OVO;*)EV{*FhoILFsfCl!RV^Uq@*+bVgj@H^s;(Jz3rbe8SgPopXkOYy8TTK z;{?X(Z;Kg~x39@#lxCk^RL3Ycy`zMYclv}3$)0!NPR zeFaQEUANorV47_XHe@=`5Yfr+4FtDKePHTfn!MJ4V|pDQqu}&+pP0BHW@~(AiejAp z)rVPN`|2-DJ{Ibxi7Bb62Fb}LM#+{&X33To#%W0g1}WxdX{L!LNhyhGMi#~?Cg#%x zOIXCF`};9*Z@1TF4iwtH%$~WYZu^D(%q6|k&$BRbOwadc(b`_-%kq&C%-;^=Z()K< MX>Sh;VmTHK03GXQX#fBK diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 9a12d60bb..82ab9b2b6 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -22,6 +22,7 @@ "@tanstack/react-query": "^4.36.1", "@tauri-apps/api": "=2.0.0-rc.0", "@tauri-apps/plugin-dialog": "=2.0.0-rc.0", + "@tauri-apps/plugin-http": "2.0.0-rc.1", "@tauri-apps/plugin-os": "=2.0.0-rc.0", "@tauri-apps/plugin-shell": "=2.0.0-rc.0", "consistent-hash": "^1.2.2", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 84d9cc29f..aff69b5e3 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -41,6 +41,7 @@ tauri-plugin-os = "=2.0.0-rc.0" tauri-plugin-shell = "=2.0.0-rc.0" tauri-plugin-updater = "=2.0.0-rc.0" tauri-plugin-deep-link = "=2.0.0-rc.0" +tauri-plugin-http = "2.0.0-rc.0" [dependencies.tauri] features = ["linux-libxdo", "macos-private-api", "native-tls-vendored", "unstable"] diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.json index 0ee040e59..20e0aa609 100644 --- a/apps/desktop/src-tauri/capabilities/default.json +++ b/apps/desktop/src-tauri/capabilities/default.json @@ -2,7 +2,9 @@ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", - "windows": ["main"], + "windows": [ + "main" + ], "permissions": [ "core:app:default", "core:event:default", @@ -25,6 +27,20 @@ "core:window:allow-minimize", "core:window:allow-toggle-maximize", "core:window:allow-start-dragging", - "core:webview:allow-internal-toggle-devtools" + "core:webview:allow-internal-toggle-devtools", + { + "identifier": "http:default", + "allow": [ + { + "url": "https://**" + }, + { + "url": "http://**" + }, + { + "url": "http://localhost:9420/" + } + ] + } ] } diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index dfb4af182..58e781fd6 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -363,6 +363,7 @@ async fn main() -> tauri::Result<()> { .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_shell::init()) + .plugin(tauri_plugin_http::init()) // TODO: Bring back Tauri Plugin Window State - it was buggy so we removed it. .plugin(tauri_plugin_updater::Builder::new().build()) .plugin(updater::plugin()) diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index cd777d3d4..db633ccc8 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -18,6 +18,7 @@ import { RouteTitleContext } from '@sd/interface/hooks/useRouteTitle'; import '@sd/ui/style/style.scss'; +import { fetch } from '@tauri-apps/plugin-http'; import SuperTokens from 'supertokens-web-js'; import EmailPassword from 'supertokens-web-js/recipe/emailpassword'; import Session from 'supertokens-web-js/recipe/session'; @@ -58,6 +59,9 @@ SuperTokens.init({ const startupError = (window as any).__SD_ERROR__ as string | undefined; +//Set global fetch to use tauri fetch +globalThis.fetch = fetch; + export default function App() { useEffect(() => { // This tells Tauri to show the current window because it's finished loading diff --git a/core/src/node/hardware.rs b/core/src/node/hardware.rs index be0370e00..1af50b530 100644 --- a/core/src/node/hardware.rs +++ b/core/src/node/hardware.rs @@ -7,6 +7,7 @@ use strum_macros::{Display, EnumIter}; #[repr(i32)] #[derive(Debug, Clone, Display, Copy, EnumIter, Type, Serialize, Deserialize, Eq, PartialEq)] +#[specta(rename = "core_HardwareModel")] pub enum HardwareModel { Other, MacStudio, diff --git a/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx b/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx index 10cc65173..60a46fb70 100644 --- a/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx @@ -174,12 +174,14 @@ export default () => { {/* */} {/* */} - - +
+ + +
{/* {platform.showDevtools && ( { diff --git a/interface/app/$libraryId/index.tsx b/interface/app/$libraryId/index.tsx index 2f0df905c..6be3b0dd3 100644 --- a/interface/app/$libraryId/index.tsx +++ b/interface/app/$libraryId/index.tsx @@ -79,7 +79,7 @@ export default (platform: Platform) => }, { path: 'auth', - lazy: () => import('./auth'), + lazy: () => import('./Layout/auth'), children: [] }, { path: '*', lazy: () => import('./404') } diff --git a/interface/app/$libraryId/settings/client/account/Tabs.tsx b/interface/app/$libraryId/settings/client/account/Tabs.tsx index e04f90615..890565c64 100644 --- a/interface/app/$libraryId/settings/client/account/Tabs.tsx +++ b/interface/app/$libraryId/settings/client/account/Tabs.tsx @@ -56,7 +56,7 @@ const Tabs = () => { // This is where Google should redirect the user back after login or error. // This URL goes on the Google's dashboard as well. - frontendRedirectURI: 'http://localhost:9420/api/auth/callback/google' + frontendRedirectURI: 'spacedrive://-/auth' }); /* diff --git a/packages/client/src/core.ts b/packages/client/src/core.ts index 4bc80ad02..00b339a1a 100644 --- a/packages/client/src/core.ts +++ b/packages/client/src/core.ts @@ -231,7 +231,7 @@ export type CursorOrderItem = { order: SortOrder; data: T } export type DefaultLocations = { desktop: boolean; documents: boolean; downloads: boolean; pictures: boolean; music: boolean; videos: boolean } -export type Device = { pub_id: DevicePubId; name: string; os: DeviceOS; storage_size: bigint; connection_id: string; created_at: string; updated_at: string } +export type Device = { pub_id: DevicePubId; name: string; os: DeviceOS; storage_size: bigint; used_storage: bigint; connection_id: string; created_at: string; updated_at: string; hardware_model: HardwareModel } export type DeviceDeleteRequest = { access_token: AccessToken; pub_id: DevicePubId } @@ -505,7 +505,7 @@ export type MediaLocation = { latitude: number; longitude: number; pluscode: Plu export type Metadata = { album: string | null; album_artist: string | null; artist: string | null; comment: string | null; composer: string | null; copyright: string | null; creation_time: string | null; date: string | null; disc: number | null; encoder: string | null; encoded_by: string | null; filename: string | null; genre: string | null; language: string | null; performer: string | null; publisher: string | null; service_name: string | null; service_provider: string | null; title: string | null; track: number | null; variant_bit_rate: number | null; custom: { [key in string]: string } } -export type MockDevice = { pub_id: DevicePubId; name: string; os: DeviceOS; used_storage: bigint; storage_size: bigint; created_at: string; updated_at: string; device_model: HardwareModel } +export type MockDevice = { pub_id: DevicePubId; name: string; os: DeviceOS; used_storage: bigint; storage_size: bigint; created_at: string; updated_at: string; device_model: core_HardwareModel } export type NodeConfigP2P = { discovery?: P2PDiscoveryState; port: Port; disabled: boolean; disable_ipv6: boolean; disable_relay: boolean; enable_remote_access: boolean; /** @@ -602,7 +602,7 @@ export type P2PDiscoveryState = "Everyone" | "ContactsOnly" | "Disabled" export type P2PEvent = { type: "PeerChange"; identity: RemoteIdentity; connection: ConnectionMethod; discovery: DiscoveryMethod; metadata: PeerMetadata; addrs: string[] } | { type: "PeerDelete"; identity: RemoteIdentity } | { type: "SpacedropRequest"; id: string; identity: RemoteIdentity; peer_name: string; files: string[] } | { type: "SpacedropProgress"; id: string; percent: number } | { type: "SpacedropTimedOut"; id: string } | { type: "SpacedropRejected"; id: string } -export type PeerMetadata = { name: string; operating_system: OperatingSystem | null; device_model: HardwareModel | null; version: string | null } +export type PeerMetadata = { name: string; operating_system: OperatingSystem | null; device_model: core_HardwareModel | null; version: string | null } export type PlusCode = string @@ -702,3 +702,5 @@ export type UpdateThumbnailerPreferences = Record export type VideoProps = { pixel_format: string | null; color_range: string | null; bits_per_channel: number | null; color_space: string | null; color_primaries: string | null; color_transfer: string | null; field_order: string | null; chroma_location: string | null; width: number; height: number; aspect_ratio_num: number | null; aspect_ratio_den: number | null; properties: string[] } export type Volume = { name: string; mount_points: string[]; total_capacity: string; available_capacity: string; disk_type: DiskType; file_system: string | null; is_root_filesystem: boolean } + +export type core_HardwareModel = "Other" | "MacStudio" | "MacBookAir" | "MacBookPro" | "MacBook" | "MacMini" | "MacPro" | "IMac" | "IMacPro" | "IPad" | "IPhone" | "Simulator" | "Android" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4255f3198b53e825e3d8a5fd954347ebe8a0341b..ed3e6a5a7eef8c367c127deec3667ac2e15d0023 100644 GIT binary patch delta 422 zcmZo%>9BaM!-ft%mW+~;g2@Xx#5j!f4D<|ii;^dQR1=vj;LXYkWa}ADHw@ws_@P%FE%YVcGdPyHz{^1DKGM{FwMyFtt<>N2u^nl4NDBo zwu}ficXLWNPPetKo$epXBf4EEgLwfLFUX+|a7Qv8)(Fiq2~P=e^{y~*c1tuXwJ1%> zPBqBQH#aSCF3Kx4izq2_D=Et=&d{#PD)oy@_jT9LG0=82EYA;*@W?ecPBZdJEi2B> zDAx8)@=o>%bkxr)vdA`?ZdJ@IGhHMS=rF9%m&2lK+FNeoIuRA z{b>>RiwEGKU^7y;QmBTwc{PkNFsZm}&cCKIXQ_=@UYEl%{1f%WwC{WKQOqZWhfWGJQ@u zvwV9?2{RD005K~NvjH(X5OV-AClGUOZz