@abraca/nuxt 2.40.0 → 2.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/ADocSubPageList.vue +8 -6
- package/dist/runtime/components/AKeypairLoginModal.d.vue.ts +30 -0
- package/dist/runtime/components/AKeypairLoginModal.vue +111 -0
- package/dist/runtime/components/AKeypairLoginModal.vue.d.ts +30 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +3 -1
- package/dist/runtime/components/renderers/AMapRenderer.vue +3 -1
- package/dist/runtime/components/renderers/AOverviewRenderer.vue +7 -5
- package/dist/runtime/components/renderers/ATimelineRenderer.vue +3 -1
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +1 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +1 -0
- package/dist/runtime/composables/useDocSnapshots.js +3 -1
- package/dist/runtime/plugin-abracadabra.client.js +61 -0
- package/dist/runtime/plugin-abracadabra.server.js +2 -0
- package/dist/runtime/types.d.ts +19 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -4,6 +4,7 @@ import { useRouter, useRoute, useRuntimeConfig, useToast } from "#imports";
|
|
|
4
4
|
import * as Y from "yjs";
|
|
5
5
|
import { useAbracadabra } from "../composables/useAbracadabra";
|
|
6
6
|
import { useChildTree } from "../composables/useChildTree";
|
|
7
|
+
import { useDocSlugs } from "../composables/useDocSlugs";
|
|
7
8
|
import { useNodePanel } from "../composables/useNodePanel";
|
|
8
9
|
import { useWindowManager } from "../composables/useWindowManager";
|
|
9
10
|
import { useItemPresence, useViewingBroadcast } from "../composables/useItemPresence";
|
|
@@ -71,6 +72,7 @@ const { treeMap } = docTree;
|
|
|
71
72
|
const canWrite = computed(() => props.editable !== false);
|
|
72
73
|
const router = useRouter();
|
|
73
74
|
const route = useRoute();
|
|
75
|
+
const { getDocUrl } = useDocSlugs();
|
|
74
76
|
const toast = useToast();
|
|
75
77
|
const { enqueue: enqueueUpload } = useOfflineUploadQueue();
|
|
76
78
|
const { isFavorite, toggleFavorite } = useFavorites(rootDoc);
|
|
@@ -114,7 +116,7 @@ function pageViewers(pageId) {
|
|
|
114
116
|
}
|
|
115
117
|
function openFull(id, label) {
|
|
116
118
|
emit("open", id, label);
|
|
117
|
-
router.push(
|
|
119
|
+
router.push(getDocUrl(id));
|
|
118
120
|
}
|
|
119
121
|
function onItemActivate(e, id, label) {
|
|
120
122
|
if (e.metaKey || e.ctrlKey) {
|
|
@@ -144,7 +146,7 @@ watch(tiptapDragState, (state, oldState) => {
|
|
|
144
146
|
dropIndicator.value = null;
|
|
145
147
|
const currentDocId = route.params.id;
|
|
146
148
|
if (currentDocId && currentDocId !== dragOriginDocId) {
|
|
147
|
-
router.push(
|
|
149
|
+
router.push(getDocUrl(dragOriginDocId));
|
|
148
150
|
}
|
|
149
151
|
dragOriginDocId = null;
|
|
150
152
|
}
|
|
@@ -261,7 +263,7 @@ async function onTiptapDrop(targetId) {
|
|
|
261
263
|
const fragment = childProv.document.getXmlFragment("default");
|
|
262
264
|
populateYDocFromHtml(fragment, state.html, label);
|
|
263
265
|
state.deleteFromSource();
|
|
264
|
-
router.push(
|
|
266
|
+
router.push(getDocUrl(newId));
|
|
265
267
|
} else {
|
|
266
268
|
if (targetId === state.sourceDocId) return;
|
|
267
269
|
const childProv = await provider.value.loadChild(targetId);
|
|
@@ -504,9 +506,9 @@ async function onExternalFileDrop(e, parentId = null) {
|
|
|
504
506
|
if (firstId === null && id !== null) firstId = id;
|
|
505
507
|
}
|
|
506
508
|
if (parentId) {
|
|
507
|
-
router.push(
|
|
509
|
+
router.push(getDocUrl(parentId));
|
|
508
510
|
} else if (firstId) {
|
|
509
|
-
router.push(
|
|
511
|
+
router.push(getDocUrl(firstId));
|
|
510
512
|
}
|
|
511
513
|
}
|
|
512
514
|
const TEXT_EXTENSIONS = ["md", "mdx", "txt", "html", "htm"];
|
|
@@ -649,7 +651,7 @@ function createChildPage(parentId) {
|
|
|
649
651
|
treeMap.set(id, { label: "", parentId, order: Date.now(), type: "doc" });
|
|
650
652
|
void client.value?.createChild?.(parentId, { child_id: id, kind: "page" })?.catch?.(() => {
|
|
651
653
|
});
|
|
652
|
-
router.push(
|
|
654
|
+
router.push(getDocUrl(id));
|
|
653
655
|
}
|
|
654
656
|
async function duplicateDoc(id) {
|
|
655
657
|
if (!provider.value) return;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
/** Inline error string from the consumer's submit handler. */
|
|
4
|
+
error?: string | null;
|
|
5
|
+
/** Loading flag while consumer handles submit. */
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
/** Title text. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Subtitle text. */
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
submit: (payload: {
|
|
14
|
+
privateKey: string;
|
|
15
|
+
ephemeral: boolean;
|
|
16
|
+
}) => any;
|
|
17
|
+
"update:open": (open: boolean) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onSubmit?: ((payload: {
|
|
20
|
+
privateKey: string;
|
|
21
|
+
ephemeral: boolean;
|
|
22
|
+
}) => any) | undefined;
|
|
23
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
subtitle: string;
|
|
26
|
+
title: string;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, watch } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
open: { type: Boolean, required: false },
|
|
5
|
+
error: { type: [String, null], required: false },
|
|
6
|
+
loading: { type: Boolean, required: false, default: false },
|
|
7
|
+
title: { type: String, required: false, default: "Sign in with a private key" },
|
|
8
|
+
subtitle: { type: String, required: false, default: "Paste a 32-byte Ed25519 private key (base64url) to sign in as the matching identity." }
|
|
9
|
+
});
|
|
10
|
+
const emit = defineEmits(["update:open", "submit"]);
|
|
11
|
+
const open = computed({
|
|
12
|
+
get: () => !!props.open,
|
|
13
|
+
set: (v) => emit("update:open", v)
|
|
14
|
+
});
|
|
15
|
+
const privateKey = ref("");
|
|
16
|
+
const ephemeral = ref(false);
|
|
17
|
+
watch(() => props.open, (v) => {
|
|
18
|
+
if (!v) return;
|
|
19
|
+
privateKey.value = "";
|
|
20
|
+
ephemeral.value = false;
|
|
21
|
+
});
|
|
22
|
+
const SEED_RE = /^[\w-]{43}=?$/;
|
|
23
|
+
const trimmed = computed(() => privateKey.value.trim());
|
|
24
|
+
const looksValid = computed(() => SEED_RE.test(trimmed.value));
|
|
25
|
+
const showError = computed(() => trimmed.value.length > 0 && !looksValid.value);
|
|
26
|
+
const canSubmit = computed(() => looksValid.value && !props.loading);
|
|
27
|
+
function submit() {
|
|
28
|
+
if (!canSubmit.value) return;
|
|
29
|
+
emit("submit", { privateKey: trimmed.value, ephemeral: ephemeral.value });
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<UModal
|
|
35
|
+
v-model:open="open"
|
|
36
|
+
:title="title"
|
|
37
|
+
:ui="{ content: 'sm:max-w-lg' }"
|
|
38
|
+
>
|
|
39
|
+
<template #body>
|
|
40
|
+
<div class="flex flex-col gap-5">
|
|
41
|
+
<p class="text-sm text-(--ui-text-muted) text-center">
|
|
42
|
+
{{ subtitle }}
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
<UAlert
|
|
46
|
+
v-if="error"
|
|
47
|
+
color="error"
|
|
48
|
+
variant="soft"
|
|
49
|
+
icon="i-lucide-triangle-alert"
|
|
50
|
+
:description="error"
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<UAlert
|
|
54
|
+
v-else-if="showError"
|
|
55
|
+
color="warning"
|
|
56
|
+
variant="soft"
|
|
57
|
+
icon="i-lucide-triangle-alert"
|
|
58
|
+
description="That doesn't look like a 32-byte base64url private key."
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
<div class="flex flex-col gap-1">
|
|
62
|
+
<label class="text-xs font-medium text-(--ui-text-muted)">PRIVATE KEY</label>
|
|
63
|
+
<UInput
|
|
64
|
+
v-model="privateKey"
|
|
65
|
+
type="password"
|
|
66
|
+
size="md"
|
|
67
|
+
autofocus
|
|
68
|
+
autocapitalize="off"
|
|
69
|
+
autocomplete="off"
|
|
70
|
+
spellcheck="false"
|
|
71
|
+
placeholder="base64url 32-byte seed"
|
|
72
|
+
icon="i-lucide-key-round"
|
|
73
|
+
class="font-mono"
|
|
74
|
+
:ui="{ base: 'rounded-sm' }"
|
|
75
|
+
@keydown.enter="submit"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<label class="flex items-center gap-2 cursor-pointer text-sm px-1">
|
|
80
|
+
<USwitch
|
|
81
|
+
v-model="ephemeral"
|
|
82
|
+
size="sm"
|
|
83
|
+
/>
|
|
84
|
+
<span>Don't store on this device (ephemeral session)</span>
|
|
85
|
+
</label>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<template #footer>
|
|
90
|
+
<div class="flex items-center justify-end gap-2 w-full">
|
|
91
|
+
<UButton
|
|
92
|
+
variant="ghost"
|
|
93
|
+
color="neutral"
|
|
94
|
+
size="sm"
|
|
95
|
+
label="Cancel"
|
|
96
|
+
@click="open = false"
|
|
97
|
+
/>
|
|
98
|
+
<UButton
|
|
99
|
+
variant="solid"
|
|
100
|
+
color="primary"
|
|
101
|
+
size="sm"
|
|
102
|
+
icon="i-lucide-log-in"
|
|
103
|
+
label="Sign in"
|
|
104
|
+
:loading="loading"
|
|
105
|
+
:disabled="!canSubmit"
|
|
106
|
+
@click="submit"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
</UModal>
|
|
111
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
/** Inline error string from the consumer's submit handler. */
|
|
4
|
+
error?: string | null;
|
|
5
|
+
/** Loading flag while consumer handles submit. */
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
/** Title text. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Subtitle text. */
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
submit: (payload: {
|
|
14
|
+
privateKey: string;
|
|
15
|
+
ephemeral: boolean;
|
|
16
|
+
}) => any;
|
|
17
|
+
"update:open": (open: boolean) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onSubmit?: ((payload: {
|
|
20
|
+
privateKey: string;
|
|
21
|
+
ephemeral: boolean;
|
|
22
|
+
}) => any) | undefined;
|
|
23
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
subtitle: string;
|
|
26
|
+
title: string;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
@@ -3,6 +3,7 @@ import { ref, computed, watch, onBeforeUnmount } from "vue";
|
|
|
3
3
|
import { useRouter } from "vue-router";
|
|
4
4
|
import { useRuntimeConfig, defineShortcuts } from "#imports";
|
|
5
5
|
import { useRendererBase } from "../../composables/useRendererBase";
|
|
6
|
+
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
6
7
|
import { useTouchDrag } from "../../composables/useTouchDrag";
|
|
7
8
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
8
9
|
import { useNodePanelFollow } from "../../composables/useNodePanelFollow";
|
|
@@ -30,6 +31,7 @@ const props = defineProps({
|
|
|
30
31
|
});
|
|
31
32
|
const config = useRuntimeConfig();
|
|
32
33
|
const router = useRouter();
|
|
34
|
+
const { getDocUrl } = useDocSlugs();
|
|
33
35
|
const locale = computed(() => ({
|
|
34
36
|
...DEFAULT_LOCALE.renderers.calendar,
|
|
35
37
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -229,7 +231,7 @@ async function openAsWindow(id, label) {
|
|
|
229
231
|
function eventMenuItems(eventId, label) {
|
|
230
232
|
const items = [
|
|
231
233
|
[
|
|
232
|
-
{ label: "Open", icon: "i-lucide-external-link", onSelect: () => router.push(
|
|
234
|
+
{ label: "Open", icon: "i-lucide-external-link", onSelect: () => router.push(getDocUrl(eventId)) },
|
|
233
235
|
{ label: "Open as slideover", icon: "i-lucide-panel-right", onSelect: () => openNode(eventId, label) },
|
|
234
236
|
...wm.floatWindowsAvailable.value ? [{ label: "Open as window", icon: "i-lucide-picture-in-picture-2", onSelect: () => openAsWindow(eventId, label) }] : [],
|
|
235
237
|
...props.editable ? [
|
|
@@ -4,6 +4,7 @@ import { useRuntimeConfig, useColorMode, useAppConfig, useToast } from "#imports
|
|
|
4
4
|
import { useRouter } from "vue-router";
|
|
5
5
|
import { avatarBorderStyle } from "../../utils/avatarStyle";
|
|
6
6
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
7
|
+
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
7
8
|
import { useRendererBase } from "../../composables/useRendererBase";
|
|
8
9
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
9
10
|
import { useNodePanelFollow } from "../../composables/useNodePanelFollow";
|
|
@@ -25,6 +26,7 @@ const props = defineProps({
|
|
|
25
26
|
const emit = defineEmits(["follow"]);
|
|
26
27
|
const config = useRuntimeConfig();
|
|
27
28
|
const router = useRouter();
|
|
29
|
+
const { getDocUrl } = useDocSlugs();
|
|
28
30
|
const toast = useToast();
|
|
29
31
|
const locale = computed(() => ({
|
|
30
32
|
...DEFAULT_LOCALE.renderers.map,
|
|
@@ -259,7 +261,7 @@ const contextMenuItems = computed(() => {
|
|
|
259
261
|
const w = props.editable;
|
|
260
262
|
const openItems = (id, entry) => [
|
|
261
263
|
{ label: "Open", icon: "i-lucide-external-link", onSelect: () => {
|
|
262
|
-
if (id) router.push(
|
|
264
|
+
if (id) router.push(getDocUrl(id));
|
|
263
265
|
} },
|
|
264
266
|
{ label: locale.value.openInPanel ?? "Open as slideover", icon: "i-lucide-panel-right", onSelect: () => {
|
|
265
267
|
if (id && entry) openNode(id, entry.label);
|
|
@@ -4,6 +4,7 @@ import { useRouter, useRuntimeConfig, useAppConfig } from "#imports";
|
|
|
4
4
|
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
5
5
|
import { DEFAULT_LOCALE } from "../../locale";
|
|
6
6
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
7
|
+
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
7
8
|
import { useRendererBase } from "../../composables/useRendererBase";
|
|
8
9
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
9
10
|
import { useNodePanelFollow } from "../../composables/useNodePanelFollow";
|
|
@@ -67,6 +68,7 @@ const { getViewers: getDocViewers } = useItemPresence();
|
|
|
67
68
|
const { favorites, isFavorite, toggleFavorite, moveFavorite } = useFavorites(rootDoc);
|
|
68
69
|
const { voiceRoomId, voiceStatus, peerCount: voicePeerCount, joinRoom: _joinRoom } = useVoice();
|
|
69
70
|
const router = useRouter();
|
|
71
|
+
const { getDocUrl } = useDocSlugs();
|
|
70
72
|
const { isOpen: searchOpen, searchTerm } = useCommandPalette();
|
|
71
73
|
const appConfig = useAppConfig();
|
|
72
74
|
const neutral = computed(() => appConfig.ui?.colors?.neutral ?? "zinc");
|
|
@@ -190,10 +192,10 @@ const virtualPageRows = computed(() => {
|
|
|
190
192
|
return rows.map((vRow) => ({ vRow, item: flat[vRow.index] }));
|
|
191
193
|
});
|
|
192
194
|
function handleNavigate(entry) {
|
|
193
|
-
router.push(
|
|
195
|
+
router.push(getDocUrl(entry.id));
|
|
194
196
|
}
|
|
195
197
|
function handleJoinCall(docId) {
|
|
196
|
-
router.push(
|
|
198
|
+
router.push(getDocUrl(docId));
|
|
197
199
|
}
|
|
198
200
|
function createTypedPage(type) {
|
|
199
201
|
const label = locale.value.untitled;
|
|
@@ -201,7 +203,7 @@ function createTypedPage(type) {
|
|
|
201
203
|
if (id) {
|
|
202
204
|
const entry = tree.treeMap.get(id);
|
|
203
205
|
if (entry) tree.treeMap.set(id, { ...entry, type });
|
|
204
|
-
router.push(
|
|
206
|
+
router.push(getDocUrl(id));
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
async function duplicateDoc(id) {
|
|
@@ -272,7 +274,7 @@ function pageMenuItems(page) {
|
|
|
272
274
|
const l = locale.value;
|
|
273
275
|
return [
|
|
274
276
|
[
|
|
275
|
-
{ label: l.open, icon: "i-lucide-external-link", onSelect: () => router.push(
|
|
277
|
+
{ label: l.open, icon: "i-lucide-external-link", onSelect: () => router.push(getDocUrl(page.id)) },
|
|
276
278
|
{ label: l.openAsSlideover, icon: "i-lucide-panel-right", onSelect: () => openNode(page.id, page.label) },
|
|
277
279
|
...floatWindowsAvailable.value ? [{ label: l.openAsWindow, icon: "i-lucide-picture-in-picture-2", onSelect: () => openAsWindow(page.id, page.label) }] : [],
|
|
278
280
|
{ label: l.rename, icon: "i-lucide-pencil", onSelect: () => startRename(page.id) },
|
|
@@ -313,7 +315,7 @@ function readOnlyMenuItems(page) {
|
|
|
313
315
|
const l = locale.value;
|
|
314
316
|
return [
|
|
315
317
|
[
|
|
316
|
-
{ label: l.open, icon: "i-lucide-external-link", onSelect: () => router.push(
|
|
318
|
+
{ label: l.open, icon: "i-lucide-external-link", onSelect: () => router.push(getDocUrl(page.id)) },
|
|
317
319
|
{ label: l.openAsSlideover, icon: "i-lucide-panel-right", onSelect: () => openNode(page.id, page.label) },
|
|
318
320
|
{ label: l.openAsWindow, icon: "i-lucide-picture-in-picture-2", onSelect: () => openAsWindow(page.id, page.label) },
|
|
319
321
|
{
|
|
@@ -3,6 +3,7 @@ import { ref, computed, watch, onBeforeUnmount } from "vue";
|
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
4
|
import { useRouter } from "vue-router";
|
|
5
5
|
import { useRendererBase } from "../../composables/useRendererBase";
|
|
6
|
+
import { useDocSlugs } from "../../composables/useDocSlugs";
|
|
6
7
|
import { useTouchDrag } from "../../composables/useTouchDrag";
|
|
7
8
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
8
9
|
import { useNodePanelFollow } from "../../composables/useNodePanelFollow";
|
|
@@ -26,6 +27,7 @@ const props = defineProps({
|
|
|
26
27
|
});
|
|
27
28
|
const config = useRuntimeConfig();
|
|
28
29
|
const router = useRouter();
|
|
30
|
+
const { getDocUrl } = useDocSlugs();
|
|
29
31
|
const locale = computed(() => ({
|
|
30
32
|
...DEFAULT_LOCALE.renderers.timeline,
|
|
31
33
|
...config.public?.abracadabra?.locale?.renderers?.timeline ?? {},
|
|
@@ -392,7 +394,7 @@ const ctxItems = computed(() => {
|
|
|
392
394
|
const isEpic = !entry.parentId;
|
|
393
395
|
const items = [
|
|
394
396
|
[
|
|
395
|
-
{ label: locale.value.open, icon: "i-lucide-external-link", onSelect: () => router.push(
|
|
397
|
+
{ label: locale.value.open, icon: "i-lucide-external-link", onSelect: () => router.push(getDocUrl(ctxEntry.value.id)) },
|
|
396
398
|
{ label: "Open as slideover", icon: "i-lucide-panel-right", onSelect: () => openNode(ctxEntry.value.id, ctxEntry.value.label) },
|
|
397
399
|
...wm.floatWindowsAvailable.value ? [{ label: "Open as window", icon: "i-lucide-picture-in-picture-2", onSelect: () => openAsWindow(ctxEntry.value.id, ctxEntry.value.label) }] : [],
|
|
398
400
|
...props.editable ? [
|
|
@@ -18,6 +18,7 @@ export function useAbracadabraAuth() {
|
|
|
18
18
|
loginWithPassword: abra.loginWithPassword,
|
|
19
19
|
registerWithPassword: abra.registerWithPassword,
|
|
20
20
|
loginWithMnemonic: abra.loginWithMnemonic,
|
|
21
|
+
loginWithKeypair: abra.loginWithKeypair,
|
|
21
22
|
logout: abra.logout,
|
|
22
23
|
logoutServer: abra.logoutServer,
|
|
23
24
|
logoutAll: abra.logoutAll,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed, ref } from "vue";
|
|
2
2
|
import { useToast, useRouter } from "#imports";
|
|
3
3
|
import { useAbracadabra } from "./useAbracadabra.js";
|
|
4
|
+
import { useDocSlugs } from "./useDocSlugs.js";
|
|
4
5
|
import { useAbraLocale } from "./useAbraLocale.js";
|
|
5
6
|
export const DOC_SNAPSHOTS_KEY = Symbol("doc-snapshots");
|
|
6
7
|
export function triggerBadgeColor(trigger) {
|
|
@@ -41,6 +42,7 @@ export function useDocSnapshots(docId, overrides) {
|
|
|
41
42
|
const locale = useAbraLocale("snapshots", overrides);
|
|
42
43
|
const toast = useToast();
|
|
43
44
|
const router = useRouter();
|
|
45
|
+
const { getDocUrl } = useDocSlugs();
|
|
44
46
|
const snapshots = ref([]);
|
|
45
47
|
const loading = ref(false);
|
|
46
48
|
const error = ref(null);
|
|
@@ -204,7 +206,7 @@ export function useDocSnapshots(docId, overrides) {
|
|
|
204
206
|
variant: "outline",
|
|
205
207
|
onClick: (e) => {
|
|
206
208
|
e?.stopPropagation();
|
|
207
|
-
router.push(
|
|
209
|
+
router.push(getDocUrl(res.doc_id));
|
|
208
210
|
}
|
|
209
211
|
}]
|
|
210
212
|
});
|
|
@@ -884,6 +884,66 @@ export default defineNuxtPlugin({
|
|
|
884
884
|
await _initPromise;
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
|
+
async function loginWithKeypair(opts) {
|
|
888
|
+
const raw = (opts.privateKey ?? "").trim();
|
|
889
|
+
if (!raw) throw new Error("Private key is required");
|
|
890
|
+
let seed;
|
|
891
|
+
try {
|
|
892
|
+
seed = fromBase64Url(raw);
|
|
893
|
+
} catch {
|
|
894
|
+
throw new Error("Private key must be base64url-encoded");
|
|
895
|
+
}
|
|
896
|
+
if (seed.length !== 32) {
|
|
897
|
+
seed.fill(0);
|
|
898
|
+
throw new Error("Private key must decode to a 32-byte Ed25519 seed");
|
|
899
|
+
}
|
|
900
|
+
const [edModule, { sha512 }] = await Promise.all([
|
|
901
|
+
import("@noble/ed25519"),
|
|
902
|
+
import("@noble/hashes/sha2.js")
|
|
903
|
+
]);
|
|
904
|
+
const ed = edModule.default ?? edModule;
|
|
905
|
+
if (ed.hashes) {
|
|
906
|
+
ed.hashes.sha512 = sha512;
|
|
907
|
+
ed.hashes.sha512Async = (m) => Promise.resolve(sha512(m));
|
|
908
|
+
}
|
|
909
|
+
const pubKey = toBase64Url(ed.getPublicKey(seed));
|
|
910
|
+
if (opts.ephemeral) {
|
|
911
|
+
_wipeEphemeralSeed();
|
|
912
|
+
_ephemeralSeed = seed;
|
|
913
|
+
localStorage.removeItem("abracadabra_privkey");
|
|
914
|
+
if (typeof window !== "undefined") {
|
|
915
|
+
window.addEventListener("beforeunload", _wipeEphemeralSeed);
|
|
916
|
+
}
|
|
917
|
+
publicKeyB64.value = pubKey;
|
|
918
|
+
identityState.value = "claimed";
|
|
919
|
+
addLog("Ephemeral keypair session", "auth");
|
|
920
|
+
} else {
|
|
921
|
+
_wipeEphemeralSeed();
|
|
922
|
+
try {
|
|
923
|
+
const { softKeystoreAvailable, importSoftKeyFromSeed } = await import("./utils/softKeystore.js");
|
|
924
|
+
if (softKeystoreAvailable()) {
|
|
925
|
+
await importSoftKeyFromSeed(seed);
|
|
926
|
+
} else {
|
|
927
|
+
localStorage.setItem("abracadabra_privkey", toBase64Url(seed));
|
|
928
|
+
}
|
|
929
|
+
} finally {
|
|
930
|
+
seed.fill(0);
|
|
931
|
+
}
|
|
932
|
+
localStorage.setItem(CLAIMED_FLAG_KEY, "1");
|
|
933
|
+
localStorage.setItem(PUBKEY_KEY, pubKey);
|
|
934
|
+
localStorage.removeItem(REQUIRE_PASSKEY_KEY);
|
|
935
|
+
publicKeyB64.value = pubKey;
|
|
936
|
+
identityState.value = "claimed";
|
|
937
|
+
addLog("Authenticated via keypair", "auth");
|
|
938
|
+
}
|
|
939
|
+
const serverUrl = currentServerUrl.value;
|
|
940
|
+
if (client.value || serverUrl) {
|
|
941
|
+
_teardown();
|
|
942
|
+
_initPromise = null;
|
|
943
|
+
_initPromise = init(serverUrl);
|
|
944
|
+
await _initPromise;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
887
947
|
async function confirmPasswordReset(opts) {
|
|
888
948
|
if (!client.value) throw new Error("Not connected");
|
|
889
949
|
await client.value.confirmPasswordReset(opts);
|
|
@@ -1521,6 +1581,7 @@ export default defineNuxtPlugin({
|
|
|
1521
1581
|
loginWithPassword,
|
|
1522
1582
|
registerWithPassword,
|
|
1523
1583
|
loginWithMnemonic,
|
|
1584
|
+
loginWithKeypair,
|
|
1524
1585
|
logout,
|
|
1525
1586
|
reconnect,
|
|
1526
1587
|
logoutServer,
|
|
@@ -68,6 +68,8 @@ export default defineNuxtPlugin({
|
|
|
68
68
|
loginWithHardware: noopAsync,
|
|
69
69
|
loginWithPassword: noopAsync,
|
|
70
70
|
registerWithPassword: noopAsync,
|
|
71
|
+
loginWithMnemonic: noopAsync,
|
|
72
|
+
loginWithKeypair: noopAsync,
|
|
71
73
|
logout: noopAsync,
|
|
72
74
|
logoutServer: noopAsync,
|
|
73
75
|
logoutAll: noopAsync,
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -506,6 +506,25 @@ export interface AbracadabraState {
|
|
|
506
506
|
displayName?: string;
|
|
507
507
|
inviteCode?: string;
|
|
508
508
|
}) => Promise<void>;
|
|
509
|
+
/**
|
|
510
|
+
* Log in with a BIP-39 recovery phrase. Derives the Ed25519 seed, persists it
|
|
511
|
+
* (unless `ephemeral`), marks the identity 'claimed', and re-inits so the WS
|
|
512
|
+
* re-authenticates via challenge-response.
|
|
513
|
+
*/
|
|
514
|
+
loginWithMnemonic: (opts: {
|
|
515
|
+
mnemonic: string;
|
|
516
|
+
passphrase?: string;
|
|
517
|
+
ephemeral?: boolean;
|
|
518
|
+
}) => Promise<void>;
|
|
519
|
+
/**
|
|
520
|
+
* Log in with a raw Ed25519 private key (32-byte base64url seed — the
|
|
521
|
+
* `NUXT_ABRACADABRA_SERVICE_PRIVATE_KEY` shape). Same persistence + re-init
|
|
522
|
+
* path as `loginWithMnemonic`; `ephemeral` keeps the seed in memory only.
|
|
523
|
+
*/
|
|
524
|
+
loginWithKeypair: (opts: {
|
|
525
|
+
privateKey: string;
|
|
526
|
+
ephemeral?: boolean;
|
|
527
|
+
}) => Promise<void>;
|
|
509
528
|
logout: () => Promise<void>;
|
|
510
529
|
/** Revoke the current JWT server-side, then clear local identity. */
|
|
511
530
|
logoutServer: () => Promise<void>;
|