Skip to content

Commit 62e4aca

Browse files
committed
fix: deeplink stuff
1 parent 6f53fb7 commit 62e4aca

File tree

14 files changed

+1100
-185
lines changed

14 files changed

+1100
-185
lines changed

infrastructure/eid-wallet/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@tauri-apps/api": "^2",
2828
"@tauri-apps/plugin-barcode-scanner": "^2.2.0",
2929
"@tauri-apps/plugin-biometric": "^2.2.0",
30+
"@tauri-apps/plugin-deep-link": "^2.4.1",
3031
"@tauri-apps/plugin-opener": "^2",
3132
"@tauri-apps/plugin-store": "^2.2.0",
3233
"@veriff/incontext-sdk": "^2.4.0",

infrastructure/eid-wallet/src-tauri/Cargo.lock

Lines changed: 103 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/eid-wallet/src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ tauri-build = { version = "2", features = [] }
2020
[dependencies]
2121
tauri = { version = "2", features = [] }
2222
tauri-plugin-opener = "2"
23+
tauri-plugin-deep-link = "2"
2324
serde = { version = "1", features = ["derive"] }
2425
serde_json = "1"
2526
tauri-plugin-store = "2.2.0"
@@ -33,4 +34,3 @@ thiserror = { version = "2.0.11" }
3334
tauri-plugin-barcode-scanner = "2"
3435
tauri-plugin-biometric = "2.2.0"
3536
tauri-plugin-crypto-hw = "0.1.0"
36-

infrastructure/eid-wallet/src-tauri/Info.ios.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,16 @@
1212
<key>NSAllowsArbitraryLoads</key>
1313
<true/>
1414
</dict>
15+
<key>CFBundleURLTypes</key>
16+
<array>
17+
<dict>
18+
<key>CFBundleURLName</key>
19+
<string>foundation.metastate.eid-wallet</string>
20+
<key>CFBundleURLSchemes</key>
21+
<array>
22+
<string>w3ds</string>
23+
</array>
24+
</dict>
25+
</array>
1526
</dict>
1627
</plist>

infrastructure/eid-wallet/src-tauri/capabilities/mobile.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"opener:default",
99
"store:default",
1010
"biometric:default",
11-
"barcode-scanner:default"
11+
"barcode-scanner:default",
12+
"deep-link:default"
1213
],
1314
"platforms": ["iOS", "android"]
1415
}

infrastructure/eid-wallet/src-tauri/gen/android/app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<!-- AndroidTV support -->
2323
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
2424
</intent-filter>
25+
<intent-filter >
26+
<action android:name="android.intent.action.VIEW" />
27+
<category android:name="android.intent.category.DEFAULT" />
28+
<category android:name="android.intent.category.BROWSABLE" />
29+
<data android:scheme="w3ds" />
30+
</intent-filter>
2531
</activity>
2632

2733
<provider

infrastructure/eid-wallet/src-tauri/gen/apple/eid-wallet_iOS/Info.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,16 @@
4949
<string>UIInterfaceOrientationLandscapeLeft</string>
5050
<string>UIInterfaceOrientationLandscapeRight</string>
5151
</array>
52+
<key>CFBundleURLTypes</key>
53+
<array>
54+
<dict>
55+
<key>CFBundleURLName</key>
56+
<string>foundation.metastate.eid-wallet</string>
57+
<key>CFBundleURLSchemes</key>
58+
<array>
59+
<string>w3ds</string>
60+
</array>
61+
</dict>
62+
</array>
5263
</dict>
5364
</plist>

infrastructure/eid-wallet/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub fn run() {
3737
tauri::Builder::default()
3838
.plugin(tauri_plugin_opener::init())
3939
.plugin(tauri_plugin_store::Builder::new().build())
40+
.plugin(tauri_plugin_deep_link::init())
4041
.setup(move |_app| {
4142
#[cfg(mobile)]
4243
{

infrastructure/eid-wallet/src/routes/(app)/+layout.svelte

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,49 @@
11
<script lang="ts">
2-
import { page } from "$app/state";
3-
import type { Snippet } from "svelte";
4-
import type { LayoutData } from "./$types";
2+
import { page } from "$app/state";
3+
import { goto } from "$app/navigation";
4+
import type { Snippet } from "svelte";
5+
import type { LayoutData } from "./$types";
6+
import type { GlobalState } from "$lib/global";
7+
import { getContext, onMount } from "svelte";
58
6-
let { data, children }: { data: LayoutData; children: Snippet } = $props();
9+
let { data, children }: { data: LayoutData; children: Snippet } = $props();
710
8-
let currentRoute = $derived(page.url.pathname.split("/").pop() || "home");
11+
let currentRoute = $derived(page.url.pathname.split("/").pop() || "home");
12+
let globalState: GlobalState | undefined = $state(undefined);
913
10-
$effect(() => {
11-
const isScanPage = currentRoute === "scan-qr";
12-
if (isScanPage) return document.body.classList.add("custom-global-style");
13-
return document.body.classList.remove("custom-global-style");
14-
});
14+
onMount(async () => {
15+
// Get global state
16+
globalState = getContext<() => GlobalState>("globalState")();
17+
18+
// Authentication guard for all app routes
19+
try {
20+
if (!globalState) {
21+
console.log("No global state, redirecting to login");
22+
await goto("/login");
23+
return;
24+
}
25+
26+
const vault = await globalState.vaultController.vault;
27+
if (!vault) {
28+
console.log("User not authenticated, redirecting to login");
29+
await goto("/login");
30+
return;
31+
}
32+
33+
console.log("User authenticated, allowing access to app routes");
34+
} catch (error) {
35+
console.log("Authentication check failed, redirecting to login");
36+
await goto("/login");
37+
return;
38+
}
39+
});
40+
41+
$effect(() => {
42+
const isScanPage = currentRoute === "scan-qr";
43+
if (isScanPage)
44+
return document.body.classList.add("custom-global-style");
45+
return document.body.classList.remove("custom-global-style");
46+
});
1547
</script>
1648

1749
<!-- Dev only: remove this when deploying to production -->

0 commit comments

Comments
 (0)