diff --git a/README.md b/README.md index 3d6030f..da359d8 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ FLOW NOTE Sync needs a Flow ID account with a NOTE notepad, and Obsidian 1.11.5 ## Linking 1. Open **Settings → FLOW NOTE Sync** and select **Link**, or run **FLOW NOTE Sync: Link this vault** from the command palette. -2. The plugin shows a code and a 12-digit device code, and opens `note.flow.talk/link` in your browser. -3. On that page, sign in if asked, check the code, type the device code and approve with your passkey. The device code never leaves this device any other way: Flow ID only ever sees a slow hash of it, so it can't swap in keys or a notepad of its own. +2. The plugin shows a Flow ID code and an 8-character device code (`XXXX XXXX`), and opens `note.flow.talk/link` in your default browser. +3. Approve from the browser where you use NOTE. If that's another browser or profile, select **Copy link** and open the link there, such as the browser that set up or recovered your notepad. A browser that has never opened your notepad can't approve, and neither can one that NOTE says can't change who has access to your notepad. On that page, sign in if asked, enter the Flow ID code if the page asks for one, type the device code and approve with your passkey. The device code never leaves this device any other way: Flow ID only ever sees a slow hash of it, so it can't swap in keys or a notepad of its own. 4. Back in Obsidian, the plugin shows the account it was linked to: its DID, and its handle when the handle checks out both ways, with the domain that vouched for it set apart so a lookalike such as `alice-flow.talk.example` reads as `talk.example`. **Nothing syncs until you confirm it is yours.** A code someone else guessed and approved would otherwise bind your vault to their notepad. A link has to be approved within ten minutes. A vault that is still linked can't be linked again: if syncing stopped, settings offer **Retry** and **Unlink**, and you link again only after unlinking. diff --git a/bun.lock b/bun.lock index b2c1016..55bea76 100644 --- a/bun.lock +++ b/bun.lock @@ -5,7 +5,7 @@ "": { "name": "flow-note-sync", "dependencies": { - "@flow-industries/seal": "^0.1.0", + "@flow-industries/seal": "^0.2.0", }, "devDependencies": { "@biomejs/biome": "2.5.8", @@ -87,7 +87,7 @@ "@flow-industries/lint": ["@flow-industries/lint@0.3.1", "", {}, "sha512-oKTw7fMCZBlshRixumpXrUJUmbJx3HqiGs72F43d920yy1fCtOuAjlnbY8SXBZZ7TnEibuYY2FVjAZcQSg6COQ=="], - "@flow-industries/seal": ["@flow-industries/seal@0.1.0", "", { "dependencies": { "@flow-industries/id": "^0.36.0", "@lezer/markdown": "1.8.0", "dexie": "^4.4.6", "fflate": "^0.8.3", "libsodium-wrappers-sumo": "0.8.4", "yaml": "^2.9.1", "zod": "^4.6.5" } }, "sha512-mJEEDpY++rxm1Orjh2kfuzW//+hsPRDRmJ4YpUDjpBNJXrwQSeI5LXAZmpzjEu+26SoPJpEo9EmdPw/m8jV+/g=="], + "@flow-industries/seal": ["@flow-industries/seal@0.2.0", "", { "dependencies": { "@flow-industries/id": "^0.36.0", "@lezer/markdown": "1.8.0", "dexie": "^4.4.6", "fflate": "^0.8.3", "libsodium-wrappers-sumo": "0.8.4", "yaml": "^2.9.1", "zod": "^4.6.5" } }, "sha512-wUdHg7NQC73fxzhxYev0LHgdAIuAwYVTc0m4mm1jvyr/PG6cZdXlfbG67FxWiXPQ+kQjuFYhEOxfcda/3AYx2g=="], "@flow-industries/ui": ["@flow-industries/ui@0.27.0", "", { "dependencies": { "@base-ui/react": "^1.3.0", "@hookform/resolvers": "^5.2.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^0.562.0", "motion": "^12.24.0", "react-hook-form": "^7.70.0", "react-resizable-panels": "^4.9.0", "recharts": "3.8.0", "tailwind-merge": "^3.4.0", "tw-animate-css": "^1.4.0", "zod": "^4.3.5" }, "peerDependencies": { "@flow-industries/id": ">=0.22.0", "react": ">=19.0.0", "react-dom": ">=19.0.0", "tailwindcss": ">=4.0.0" }, "optionalPeers": ["@flow-industries/id"] }, "sha512-lTrfDnt8B1o2c/ny3lst3b8sjYWmluo6T7jVGtjKpwxsxzCdiVapqcF80lIkuUeqytdaXkhm8H7+//KCF9+crQ=="], diff --git a/manifest.json b/manifest.json index b9be327..25a4f9a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "flow-note", "name": "FLOW NOTE Sync", - "version": "0.1.0", + "version": "0.1.1", "minAppVersion": "1.11.5", "description": "Sync your vault both ways with your end-to-end encrypted NOTE notepad, linked once through your browser.", "author": "Flow Industries", diff --git a/package.json b/package.json index 16b2148..1dab6ea 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "flow-note-sync", "private": true, - "version": "0.1.0", + "version": "0.1.1", "description": "FLOW NOTE Sync for Obsidian", "license": "MIT", "type": "module", @@ -30,6 +30,6 @@ "typescript-eslint": "8.72.1" }, "dependencies": { - "@flow-industries/seal": "^0.1.0" + "@flow-industries/seal": "^0.2.0" } } diff --git a/src/obsidian/modals.ts b/src/obsidian/modals.ts index 096491f..6033aab 100644 --- a/src/obsidian/modals.ts +++ b/src/obsidian/modals.ts @@ -59,6 +59,8 @@ export class LinkModal extends Modal { private label: string; private error: string | null = null; private opened = false; + private copyFailed = false; + private linkField: HTMLInputElement | null = null; constructor( app: App, @@ -85,6 +87,7 @@ export class LinkModal extends Modal { const { contentEl } = this; const { phase } = this.controller; contentEl.empty(); + this.linkField = null; if (this.error) contentEl.createEl("p", { cls: "mod-warning", text: this.error }); if (phase.kind === "linking") return this.renderPrompt(phase.prompt); @@ -131,10 +134,10 @@ export class LinkModal extends Modal { } contentEl.createEl("p", { text: page - ? "Your browser opened NOTE's link page. Sign in there if asked, check the code matches, and type the device code below." - : `Open ${NOTE_ORIGIN}/link in your browser, enter the code below, and type the device code.`, + ? "NOTE's link page opened in your default browser. Approve from the browser where you use NOTE: if that's another browser or profile, copy the link and open it there. Sign in if asked, enter the Flow ID code if the page asks for it, then type the device code below." + : `Open ${NOTE_ORIGIN}/link in the browser where you use NOTE, enter the Flow ID code below, and type the device code.`, }); - new Setting(contentEl).setName("Code").setDesc(prompt.userCode); + new Setting(contentEl).setName("Flow ID code").setDesc(prompt.userCode); const secret = new Setting(contentEl) .setName("Device code") .setDesc( @@ -146,14 +149,47 @@ export class LinkModal extends Modal { }); const row = new Setting(contentEl); if (page) - row.addButton((button) => - button - .setButtonText("Open link page again") - .onClick(() => window.open(page)), - ); + row + .addButton((button) => + button + .setButtonText("Copy link") + .onClick(() => void this.copyLink(page)), + ) + .addButton((button) => + button + .setButtonText("Open link page again") + .onClick(() => window.open(page)), + ); row.addButton((button) => button.setButtonText("Cancel").onClick(() => this.close()), ); + if (page && this.copyFailed) + new Setting(contentEl) + .setName("Link") + .setDesc( + "Copying failed. Copy the link from here and open it in the browser where you use NOTE.", + ) + .addText((text) => { + text.setValue(page); + text.inputEl.readOnly = true; + this.linkField = text.inputEl; + }); + } + + private async copyLink(page: string) { + try { + await navigator.clipboard.writeText(page); + new Notice("Link copied. Open it in the browser where you use NOTE."); + } catch { + new Notice( + `Couldn't copy the link. Open ${page} in the browser where you use NOTE.`, + 0, + ); + this.copyFailed = true; + this.render(); + this.linkField?.focus(); + this.linkField?.select(); + } } private renderConfirm(account: LinkedAccount) { diff --git a/tests/e2e.test.ts b/tests/e2e.test.ts index da9a5c2..3a0d9a3 100644 --- a/tests/e2e.test.ts +++ b/tests/e2e.test.ts @@ -117,7 +117,9 @@ async function link(admin: AdminBrowser, vault: Obsidian) { await new Promise((resolve) => setTimeout(resolve, 10)); const [prompt] = vault.prompts; if (!prompt) throw new Error("No prompt"); - expect(prompt.pairingCode).toMatch(/^\d{4} \d{4} \d{4}$/); + expect(prompt.pairingCode).toMatch( + /^[0-9A-HJKMNP-TV-Z]{4} [0-9A-HJKMNP-TV-Z]{4}$/, + ); await approveLink(admin, prompt); return linking; } diff --git a/versions.json b/versions.json index b4b4ffc..118aa46 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ { - "0.1.0": "1.11.5" + "0.1.0": "1.11.5", + "0.1.1": "1.11.5" }