feat: saveToken plugin for app groups on iOS
This will allow the share extension to access the Bearer token to send images to the backend.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
"solid-motionone": "^1.0.3",
|
||||
"solidjs-markdown": "^0.2.0",
|
||||
"tailwind-scrollbar-hide": "^2.0.0",
|
||||
"tauri-plugin-ios-shared-token-api": "file:../tauri-plugin-ios-shared-token",
|
||||
"tauri-plugin-sharetarget-api": "file:../tauri-plugin-sharetarget",
|
||||
"valibot": "^1.0.0-rc.2",
|
||||
},
|
||||
@@ -698,6 +699,8 @@
|
||||
|
||||
"tailwindcss": ["tailwindcss@3.4.0", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", "chokidar": "^3.5.3", "didyoumean": "^1.2.2", "dlv": "^1.1.3", "fast-glob": "^3.3.0", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", "jiti": "^1.19.1", "lilconfig": "^2.1.0", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", "postcss": "^8.4.23", "postcss-import": "^15.1.0", "postcss-js": "^4.0.1", "postcss-load-config": "^4.0.1", "postcss-nested": "^6.0.1", "postcss-selector-parser": "^6.0.11", "resolve": "^1.22.2", "sucrase": "^3.32.0" }, "bin": { "tailwind": "lib/cli.js", "tailwindcss": "lib/cli.js" } }, "sha512-VigzymniH77knD1dryXbyxR+ePHihHociZbXnLZHUyzf2MMs2ZVqlUrZ3FvpXP8pno9JzmILt1sZPD19M3IxtA=="],
|
||||
|
||||
"tauri-plugin-ios-shared-token-api": ["tauri-plugin-ios-shared-token-api@file:../tauri-plugin-ios-shared-token", { "dependencies": { "@tauri-apps/api": ">=2.0.0-beta.6" }, "devDependencies": { "@rollup/plugin-typescript": "^11.1.6", "rollup": "^4.9.6", "tslib": "^2.6.2", "typescript": "^5.3.3" } }],
|
||||
|
||||
"tauri-plugin-sharetarget-api": ["tauri-plugin-sharetarget-api@file:../tauri-plugin-sharetarget", { "dependencies": { "@tauri-apps/api": ">=2.0.0-beta.6" }, "devDependencies": { "@rollup/plugin-typescript": "^11.1.6", "@tauri-apps/cli": "^2.0.4", "rollup": "^4.24.2", "tslib": "^2.6.2", "typescript": "^5.3.3" } }],
|
||||
|
||||
"thenby": ["thenby@1.3.4", "", {}, "sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ=="],
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"solid-motionone": "^1.0.3",
|
||||
"solidjs-markdown": "^0.2.0",
|
||||
"tailwind-scrollbar-hide": "^2.0.0",
|
||||
"tauri-plugin-ios-shared-token-api": "file:../tauri-plugin-ios-shared-token",
|
||||
"tauri-plugin-sharetarget-api": "file:../tauri-plugin-sharetarget",
|
||||
"valibot": "^1.0.0-rc.2"
|
||||
},
|
||||
|
||||
11
frontend/src-tauri/Cargo.lock
generated
11
frontend/src-tauri/Cargo.lock
generated
@@ -18,6 +18,7 @@ dependencies = [
|
||||
"tauri-plugin-fs",
|
||||
"tauri-plugin-global-shortcut",
|
||||
"tauri-plugin-http",
|
||||
"tauri-plugin-ios-shared-token",
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-os",
|
||||
"tauri-plugin-sharetarget",
|
||||
@@ -4113,6 +4114,16 @@ dependencies = [
|
||||
"urlpattern",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-ios-shared-token"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-log"
|
||||
version = "2.4.0"
|
||||
|
||||
@@ -40,3 +40,6 @@ tauri-plugin-global-shortcut = "2"
|
||||
|
||||
[target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies]
|
||||
tauri-plugin-sharetarget = { path = "../../tauri-plugin-sharetarget"}
|
||||
|
||||
[target."cfg(any(target_os = \"ios\"))".dependencies]
|
||||
tauri-plugin-ios-shared-token = { path = "../../tauri-plugin-ios-shared-token"}
|
||||
|
||||
@@ -9,6 +9,7 @@ permissions = [
|
||||
"http:default",
|
||||
"os:default",
|
||||
"sharetarget:default",
|
||||
"ios-shared-token:default",
|
||||
{ identifier = "http:default", allow = [
|
||||
{ url = "https://haystack.johncosta.tech" },
|
||||
{ url = "http://localhost:3040" },
|
||||
|
||||
@@ -58,6 +58,8 @@ pub fn android() {
|
||||
.plugin(tauri_plugin_store::Builder::new().build())
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_sharetarget::init())
|
||||
#[cfg(target_os = "ios")]
|
||||
.plugin(tauri_plugin_ios_shared_token::init())
|
||||
.setup(|app| {
|
||||
log::info!("running things!");
|
||||
setup_window(app)?;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { type Component, type JSX, Show } from "solid-js";
|
||||
import { jwtDecode } from "jwt-decode";
|
||||
import { Navigate } from "@solidjs/router";
|
||||
import { saveToken } from "tauri-plugin-ios-shared-token-api";
|
||||
|
||||
export const isTokenValid = (): boolean => {
|
||||
const token = localStorage.getItem("access");
|
||||
@@ -22,6 +23,15 @@ export const ProtectedRoute: Component<{ children?: JSX.Element }> = (
|
||||
) => {
|
||||
const isValid = isTokenValid();
|
||||
|
||||
if (isValid) {
|
||||
const token = localStorage.getItem("access");
|
||||
if (token == null) {
|
||||
throw new Error("unreachable");
|
||||
}
|
||||
|
||||
saveToken(token);
|
||||
}
|
||||
|
||||
return (
|
||||
<Show when={isValid} fallback={<Navigate href="/login" />}>
|
||||
{props.children}
|
||||
|
||||
Reference in New Issue
Block a user