mirror of
https://github.com/heymoosh/ticktick-quick-add-obsidian.git
synced 2026-07-22 05:43:55 +00:00
- Flip isDesktopOnly to false in manifest.json; the runtime code uses only platform-safe APIs (requestUrl, crypto.subtle, URLSearchParams). - Register obsidian://ticktick-callback protocol handler so the OAuth redirect returns directly into Obsidian on desktop and mobile, removing the manual copy-paste step. - Verify state parameter against tempState to mitigate CSRF, and clear tempCodeVerifier/tempState after a successful exchange. - Update Vercel callback pages (callback.html, index.html) to redirect to the obsidian:// deep link instead of displaying the code as text. Note: the deployed Vercel page must be redeployed for users to see the new behavior. - Drop the now-vestigial "Authorization code" paste field from the settings UI.
35 lines
1.1 KiB
HTML
35 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>TickTick OAuth Callback</title>
|
|
</head>
|
|
<body>
|
|
<h1>Authorization Complete</h1>
|
|
<p id="message">Processing...</p>
|
|
<p id="fallback" style="display:none">
|
|
If Obsidian did not open automatically,
|
|
<a id="deeplink" href="#">tap here to return to Obsidian</a>.
|
|
</p>
|
|
<script>
|
|
const params = new URLSearchParams(window.location.search);
|
|
const code = params.get('code');
|
|
const state = params.get('state');
|
|
const messageEl = document.getElementById('message');
|
|
|
|
if (code && state) {
|
|
const target = 'obsidian://ticktick-callback'
|
|
+ '?code=' + encodeURIComponent(code)
|
|
+ '&state=' + encodeURIComponent(state);
|
|
messageEl.innerText = 'Returning you to Obsidian…';
|
|
const fallback = document.getElementById('fallback');
|
|
const link = document.getElementById('deeplink');
|
|
link.href = target;
|
|
fallback.style.display = 'block';
|
|
window.location.replace(target);
|
|
} else {
|
|
messageEl.innerText = 'Authorization failed or was canceled. Please try again.';
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|