feat(identity): add browser setup and user accounts
This commit is contained in:
1 parent
cf3455ef2e
commit
aa012a7c6e
91 files changed
+6823
-636
No files matched your search
+13
-3
@@ -1,5 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from "vue";
|
||||
import { computed, onMounted, watch } from "vue";
|
||||
|
||||
import AccountEntry from "@/accounts/AccountEntry.vue";
|
||||
import { useAccountsStore } from "@/accounts/accounts";
|
||||
|
||||
import ChatLauncher from "@/chat/ChatLauncher.vue";
|
||||
import Topbar from "@/components/topbar/Topbar.vue";
|
||||
@@ -9,10 +12,15 @@ import { hiddenPaths } from "@/lib/nav";
|
||||
import { loadTaskMeta } from "@/lib/task-meta";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
|
||||
const reauthenticate=new URLSearchParams(window.location.search).has("reauth");
|
||||
const accounts=useAccountsStore();
|
||||
const session = useSessionStore();
|
||||
const hidden = computed(() => hiddenPaths(session.sections));
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(() => {void accounts.load();});
|
||||
watch(() => accounts.status?.user, (user) => {
|
||||
if (!user || reauthenticate) return;
|
||||
session.initialize();
|
||||
// Asked for once, after the shell is up: the nav paints immediately and
|
||||
// loses the entries this process cannot back a moment later, rather than
|
||||
// holding the page behind a request. A failed read hides nothing.
|
||||
@@ -29,7 +37,9 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TooltipProvider :delay-duration="350">
|
||||
<div v-if="!accounts.status" class="mx-auto max-w-md p-8" role="status"><p>{{accounts.error||'Connecting to Archie…'}}</p><button v-if="accounts.error" class="mt-3 underline" @click="accounts.load">Retry</button></div>
|
||||
<AccountEntry v-else-if="!accounts.status.user || accounts.status.setup_required || reauthenticate" />
|
||||
<TooltipProvider v-else :delay-duration="350">
|
||||
<!--
|
||||
One contained, rounded surface floating on the canvas `body` carries:
|
||||
framing the workspace gives the panels an edge to sit against, and lets
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/lib/api";
|
||||
import { passkeysAvailable, useAccountsStore, usePasskey } from "./accounts";
|
||||
const accounts=useAccountsStore();
|
||||
const step=ref(1);const recovery=ref(false);const recoveryCode=ref("");
|
||||
const organisation=ref("");const workspace=ref("Default");const publicURL=ref(window.location.origin);
|
||||
const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");
|
||||
const setup=computed(()=>accounts.status?.setup_required===true);
|
||||
const passkey=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||
async function submit(){
|
||||
if(setup.value&&step.value===1&&!recovery.value){step.value=2;return}
|
||||
busy.value=true;error.value="";
|
||||
try{
|
||||
if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";error.value="Password changed. Sign in with your new password.";return}
|
||||
if(setup.value)await api.setupAccount({organisation_name:organisation.value,workspace_name:workspace.value,public_url:publicURL.value.replace(/\/$/,""),display_name:name.value,email:email.value,password:password.value});
|
||||
else await api.signIn(email.value,password.value);
|
||||
password.value="";
|
||||
window.location.assign(setup.value?"/account?welcome=1":new URLSearchParams(window.location.search).has("reauth")?"/account":"/");
|
||||
}catch(cause){error.value=String((cause as Error).message||cause);await accounts.load()}
|
||||
finally{busy.value=false}
|
||||
}
|
||||
async function signInPasskey(){busy.value=true;error.value="";try{await usePasskey(false);window.location.assign("/")}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
</script>
|
||||
<template>
|
||||
<main class="mx-auto flex min-h-[90dvh] max-w-md flex-col justify-center px-5 py-10">
|
||||
<div class="rounded-xl border border-border bg-card p-6 shadow-sm">
|
||||
<p class="mb-2 text-xs font-medium tracking-widest text-muted-foreground">ARCHIE</p>
|
||||
<h1 class="text-2xl font-medium">{{setup?(step===1?'Set up your organisation':'Create your admin account'):recovery?'Recover your account':'Sign in'}}</h1>
|
||||
<p class="mt-2 text-sm text-muted-foreground">{{setup?(step===1?'Start with the organisation and workspace this installation will serve.':'This first account administers the installation. You can add people and configure OIDC after setup.'):'Use your account to open your workspace.'}}</p>
|
||||
<form class="mt-6 space-y-4" @submit.prevent="submit">
|
||||
<template v-if="setup&&step===1">
|
||||
<label class="block space-y-1.5 text-sm" for="organisation">Organisation name<Input id="organisation" v-model="organisation" autocomplete="organization" required maxlength="200" /></label>
|
||||
<label class="block space-y-1.5 text-sm" for="workspace">First workspace<Input id="workspace" v-model="workspace" required maxlength="200" /></label>
|
||||
<label class="block space-y-1.5 text-sm" for="public-url">Instance URL<Input id="public-url" v-model="publicURL" type="url" required autocomplete="url" /></label>
|
||||
<p class="text-xs text-muted-foreground">Use the address people will visit. Passkeys require HTTPS and a domain name, or localhost for development.</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<label v-if="setup" class="block space-y-1.5 text-sm" for="account-name">Your name<Input id="account-name" v-model="name" autocomplete="name" required maxlength="200" /></label>
|
||||
<label class="block space-y-1.5 text-sm" for="account-email">Email<Input id="account-email" v-model="email" type="email" autocomplete="username" :spellcheck="false" required /></label>
|
||||
<label v-if="recovery" class="block space-y-1.5 text-sm" for="recovery-code">Recovery code<Input id="recovery-code" v-model="recoveryCode" autocomplete="off" required /></label>
|
||||
<label class="block space-y-1.5 text-sm" for="account-password">{{recovery?"New password":"Password"}}<Input id="account-password" v-model="password" type="password" :autocomplete="setup||recovery?'new-password':'current-password'" :minlength="setup||recovery?15:undefined" maxlength="1024" required /></label>
|
||||
<p v-if="setup" class="text-xs text-muted-foreground">At least 15 characters. You can add a passkey after creating your account.</p>
|
||||
</template>
|
||||
<p v-if="error" role="alert" class="text-sm text-danger">{{error}}</p>
|
||||
<div class="flex gap-2"><Button v-if="setup&&step===2" type="button" variant="outline" :disabled="busy" @click="step=1">Back</Button><Button type="submit" class="flex-1" :disabled="busy">{{busy?'Please wait…':setup?(step===1?'Continue':'Create organisation and admin'):recovery?'Reset password':'Sign in'}}</Button></div>
|
||||
</form>
|
||||
<div v-if="!setup&&!recovery" class="mt-4 flex flex-col gap-2">
|
||||
<Button v-if="passkey" variant="outline" :disabled="busy" @click="signInPasskey">Sign in with a passkey</Button>
|
||||
<Button v-if="accounts.status?.oidc" variant="outline" as-child><a href="/oauth2/login">Sign in with OIDC</a></Button>
|
||||
</div>
|
||||
<Button v-if="!setup" variant="link" class="mt-3" :disabled="busy" @click="recovery=!recovery;error=''">{{recovery?'Back to sign in':'Use a recovery code'}}</Button>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/lib/api";
|
||||
import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts";
|
||||
const recovery=ref("");
|
||||
const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code});
|
||||
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
|
||||
const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause)}}
|
||||
onMounted(load);
|
||||
async function run(action:()=>Promise<unknown>){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
const enroll=()=>run(async()=>{await usePasskey(true,keyName.value);keyName.value="";await load()});
|
||||
const remove=(id:string)=>run(async()=>{await api.deletePasskey(id);await load()});
|
||||
const change=()=>run(async()=>{await api.changePassword(current.value,next.value);current.value=next.value="";window.location.assign("/")});
|
||||
</script>
|
||||
<template>
|
||||
<div class="max-w-2xl space-y-6">
|
||||
<PageHeader title="Your account" />
|
||||
<p class="text-sm">{{accounts.status?.user?.display_name}}</p>
|
||||
<p v-if="$route.query.welcome" class="rounded-lg border border-border bg-card p-4 text-sm">Your organisation and admin account are ready. Add a passkey below, <RouterLink class="underline" to="/org">add accounts</RouterLink>, or <RouterLink class="underline" to="/settings/authentication">configure OIDC</RouterLink>.</p>
|
||||
<p v-if="error" role="alert" class="text-sm text-danger">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
|
||||
<section class="rounded-lg border border-border bg-card p-5">
|
||||
<h2 class="font-medium">Passkeys</h2>
|
||||
<p class="mt-1 text-sm text-muted-foreground">Sign in with your device or security key.</p>
|
||||
<ul class="mt-4 divide-y divide-border"><li v-for="key in keys" :key="key.id" class="flex items-center gap-3 py-2 text-sm"><span class="min-w-0 flex-1 truncate">{{key.name}}</span><Button variant="ghost" size="sm" :disabled="busy" @click="remove(key.id)">Remove</Button></li></ul>
|
||||
<form v-if="eligible" class="mt-3 flex flex-wrap gap-2" @submit.prevent="enroll"><Input v-model="keyName" aria-label="Passkey name" placeholder="Passkey name (optional)" maxlength="200" class="min-w-40 flex-1"/><Button type="submit" :disabled="busy">Add passkey</Button></form>
|
||||
<p v-else class="mt-3 text-sm text-muted-foreground">Open Archie at its configured HTTPS domain, or localhost, in a browser that supports passkeys. The instance URL is managed in <RouterLink class="underline" to="/settings/authentication">Authentication settings</RouterLink>.</p>
|
||||
</section>
|
||||
<section class="rounded-lg border border-border bg-card p-5 space-y-3">
|
||||
<h2 class="font-medium">Recovery code</h2>
|
||||
<p class="text-sm text-muted-foreground">Save this once-only code somewhere safe. It resets your password if you lose access. Generating a new code replaces the previous one.</p>
|
||||
<Button :disabled="busy" @click="makeRecovery">Generate recovery code</Button>
|
||||
<p v-if="recovery" class="break-all rounded border border-border p-3 font-mono text-sm" role="status">{{recovery}}</p>
|
||||
</section>
|
||||
<section class="rounded-lg border border-border bg-card p-5">
|
||||
<h2 class="font-medium">Change password</h2>
|
||||
<form class="mt-4 max-w-sm space-y-3" @submit.prevent="change">
|
||||
<label class="block space-y-1 text-sm" for="current-password">Current password<Input id="current-password" v-model="current" type="password" autocomplete="current-password" required /></label>
|
||||
<label class="block space-y-1 text-sm" for="new-password">New password<Input id="new-password" v-model="next" type="password" autocomplete="new-password" required minlength="15" maxlength="1024" /></label>
|
||||
<p class="text-xs text-muted-foreground">Changing your password signs out all your sessions.</p>
|
||||
<Button type="submit" :disabled="busy">Change password</Button>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/lib/api";
|
||||
interface Settings {public_url:string;oidc_issuer:string;oidc_audience:string;oidc_client_id:string}
|
||||
const value=ref<Settings>({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const busy=ref(false);const saved=ref(false);
|
||||
onMounted(async()=>{try{value.value=await api.authentication<Settings>();loaded.value=true}catch(cause){error.value=String((cause as Error).message||cause)}});
|
||||
async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
</script>
|
||||
<template>
|
||||
<div class="max-w-2xl"><PageHeader title="Authentication"/>
|
||||
<p v-if="error" class="mb-4 text-sm text-danger" role="alert">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
|
||||
<form v-if="loaded" class="space-y-6" @submit.prevent="save">
|
||||
<section class="space-y-3 rounded-lg border border-border bg-card p-5">
|
||||
<h2 class="font-medium">Instance URL</h2>
|
||||
<label for="instance-url" class="block space-y-1 text-sm">Public address<Input id="instance-url" v-model="value.public_url" type="url" required /></label>
|
||||
<p class="text-xs text-muted-foreground">Passkeys require HTTPS and a domain name, or localhost. Once passkeys are enrolled, their domain is fixed.</p>
|
||||
</section>
|
||||
<section class="space-y-3 rounded-lg border border-border bg-card p-5">
|
||||
<h2 class="font-medium">OpenID Connect</h2>
|
||||
<p class="text-sm text-muted-foreground">Register a public client with authorization code flow and PKCE. Local accounts remain available.</p>
|
||||
<label for="oidc-issuer" class="block space-y-1 text-sm">Issuer URL<Input id="oidc-issuer" v-model="value.oidc_issuer" type="url" placeholder="https://identity.example.com" /></label>
|
||||
<label for="oidc-client" class="block space-y-1 text-sm">Client ID<Input id="oidc-client" v-model="value.oidc_client_id" /></label>
|
||||
<label for="oidc-audience" class="block space-y-1 text-sm">Access token audience<Input id="oidc-audience" v-model="value.oidc_audience" /></label>
|
||||
<p class="break-all text-xs text-muted-foreground">Redirect URI: {{value.public_url.replace(/\/$/,'')}}/oauth2/callback</p>
|
||||
<p class="text-xs text-muted-foreground">Add permitted people by their verified email or provider subject in <RouterLink class="underline" to="/org">Organisation members</RouterLink>. Clear the OIDC fields to disable provider sign-in.</p>
|
||||
</section>
|
||||
<p v-if="saved" role="status" class="text-sm">Authentication settings saved.</p>
|
||||
<Button type="submit" :disabled="busy">Save</Button>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
|
||||
import { api } from "@/lib/api";
|
||||
const emit=defineEmits<{created:[]}>();
|
||||
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");
|
||||
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
</script>
|
||||
<template>
|
||||
<section class="mt-6 max-w-md rounded-lg border border-border bg-card p-5">
|
||||
<h2 class="text-sm font-medium">Create a local account</h2>
|
||||
<form class="mt-4 space-y-3" @submit.prevent="create">
|
||||
<label for="new-account-name" class="block space-y-1 text-sm">Name<Input id="new-account-name" v-model="name" required maxlength="200" autocomplete="off" /></label>
|
||||
<label for="new-account-email" class="block space-y-1 text-sm">Email<Input id="new-account-email" v-model="email" type="email" required autocomplete="off" :spellcheck="false" /></label>
|
||||
<label for="new-account-password" class="block space-y-1 text-sm">Initial password<Input id="new-account-password" v-model="password" type="password" required minlength="15" maxlength="1024" autocomplete="new-password" /></label>
|
||||
<label for="new-account-role" class="block space-y-1 text-sm">Role<NativeSelect id="new-account-role" v-model="role"><NativeSelectOption value="viewer">Viewer</NativeSelectOption><NativeSelectOption value="developer">Developer</NativeSelectOption><NativeSelectOption value="admin">Admin</NativeSelectOption></NativeSelect></label>
|
||||
<p v-if="error" role="alert" class="text-sm text-danger">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
|
||||
<Button type="submit" :disabled="busy">Create account</Button>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,41 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { api } from "@/lib/api";
|
||||
|
||||
export interface AccountUser {id:string;display_name:string;kind:string}
|
||||
interface AuthStatus {setup_required:boolean;user:AccountUser|null;oidc:boolean;public_url:string}
|
||||
export const useAccountsStore=defineStore("accounts",()=>{
|
||||
const status=ref<AuthStatus|null>(null);
|
||||
const error=ref("");
|
||||
async function load():Promise<void>{try{status.value=await api.authStatus<AuthStatus>();error.value=""}catch(cause){error.value=String((cause as Error).message||cause)}}
|
||||
async function signOut():Promise<void>{await api.signOut();window.location.assign("/")}
|
||||
return {status,error,load,signOut};
|
||||
});
|
||||
|
||||
export function passkeysAvailable(publicURL:string):boolean{
|
||||
if (!window.isSecureContext || !window.PublicKeyCredential) return false;
|
||||
try{const url=new URL(publicURL);return url.origin===window.location.origin && (url.protocol==="https:"||url.hostname==="localhost")}catch{return false}
|
||||
}
|
||||
|
||||
// WebAuthn JSON conversion is native in current browsers. These conversions
|
||||
// preserve support for browsers that implement credentials but not JSON helpers.
|
||||
function decode(value:string):ArrayBuffer{
|
||||
const bytes=Uint8Array.from(atob(value.replace(/-/g,"+").replace(/_/g,"/")),c=>c.charCodeAt(0));return bytes.buffer;
|
||||
}
|
||||
function encode(value:ArrayBuffer|null):string|null{
|
||||
if(value===null)return null;
|
||||
return btoa(String.fromCharCode(...new Uint8Array(value))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");
|
||||
}
|
||||
export async function usePasskey(registration:boolean,name=""):Promise<void>{
|
||||
const options=await api.beginPasskey<{publicKey:Record<string,unknown>}>(registration);
|
||||
const key=options.publicKey;
|
||||
key.challenge=decode(key.challenge as string);
|
||||
if(registration){const user=key.user as Record<string,unknown>;user.id=decode(user.id as string)}
|
||||
for(const list of ["excludeCredentials","allowCredentials"]){for(const entry of (key[list] as {id:string|ArrayBuffer}[]|undefined)??[]){entry.id=decode(entry.id as string)}}
|
||||
const credential=(registration?await navigator.credentials.create({publicKey:key as unknown as PublicKeyCredentialCreationOptions}):await navigator.credentials.get({publicKey:key as unknown as PublicKeyCredentialRequestOptions})) as PublicKeyCredential|null;
|
||||
if(!credential)throw new Error("No passkey was selected.");
|
||||
const response=credential.response;
|
||||
const common={clientDataJSON:encode(response.clientDataJSON)};
|
||||
const data=response instanceof AuthenticatorAttestationResponse?{...common,attestationObject:encode(response.attestationObject),transports:response.getTransports()}:{...common,authenticatorData:encode((response as AuthenticatorAssertionResponse).authenticatorData),signature:encode((response as AuthenticatorAssertionResponse).signature),userHandle:encode((response as AuthenticatorAssertionResponse).userHandle)};
|
||||
await api.finishPasskey(registration,{id:credential.id,rawId:encode(credential.rawId),type:credential.type,response:data,clientExtensionResults:credential.getClientExtensionResults(),authenticatorAttachment:credential.authenticatorAttachment},name);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useAccountsStore } from "@/accounts/accounts";
|
||||
const accounts=useAccountsStore();
|
||||
import { Avatar, AvatarFallback } from "@/components/ui/avatar";
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -17,18 +19,21 @@ import {
|
||||
aria-label="Operator menu"
|
||||
>
|
||||
<Avatar class="size-7">
|
||||
<AvatarFallback class="text-xs">A</AvatarFallback>
|
||||
<AvatarFallback class="text-xs">{{accounts.status?.user?.display_name.slice(0,1).toUpperCase()}}</AvatarFallback>
|
||||
</Avatar>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" class="w-48">
|
||||
<DropdownMenuLabel class="text-muted-foreground text-xs font-normal">Signed in locally</DropdownMenuLabel>
|
||||
<DropdownMenuLabel class="text-muted-foreground text-xs font-normal">{{accounts.status?.user?.display_name}}</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem as-child><RouterLink to="/account">Your account</RouterLink></DropdownMenuItem>
|
||||
<DropdownMenuItem as-child>
|
||||
<RouterLink to="/settings/appearance" class="w-full cursor-pointer">Appearance</RouterLink>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem as-child>
|
||||
<RouterLink to="/logs" class="w-full cursor-pointer">Logs</RouterLink>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem @select="accounts.signOut">Sign out</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</template>
|
||||
@@ -138,6 +138,20 @@ async function request<T = unknown>(
|
||||
}
|
||||
|
||||
export const api = {
|
||||
recoveryCode: () => request<{code:string}>("/api/account/recovery",{method:"POST",body:{}}),
|
||||
recoverAccount: (email:string,code:string,password:string) => request<void>("/api/auth/recover",{method:"POST",body:{email,code,password},parse:false}),
|
||||
authStatus: <T = unknown>() => request<T>("/api/auth/status"),
|
||||
setupAccount: (body: unknown) => request("/api/auth/setup", {method:"POST",body}),
|
||||
signIn: (email: string,password: string) => request("/api/auth/login",{method:"POST",body:{email,password}}),
|
||||
signOut: () => request<void>("/api/auth/logout",{method:"POST",body:{},parse:false}),
|
||||
createAccount: (body: unknown) => request("/api/accounts",{method:"POST",body}),
|
||||
changePassword: (current_password: string,new_password: string) => request<void>("/api/account/password",{method:"POST",body:{current_password,new_password},parse:false}),
|
||||
authentication: <T = unknown>() => request<T>("/api/authentication"),
|
||||
saveAuthentication: (body: unknown) => request<void>("/api/authentication",{method:"PUT",body,parse:false}),
|
||||
passkeys: () => request<{passkeys:{id:string;name:string}[]}>("/api/account/passkeys"),
|
||||
deletePasskey: (id:string) => request<void>(`/api/account/passkeys/${encodeURIComponent(id)}`,{method:"DELETE",body:{},parse:false}),
|
||||
beginPasskey: <T = unknown>(registration:boolean) => request<T>(registration?"/api/account/passkeys/begin":"/api/auth/passkey/begin",{method:"POST",body:{}}),
|
||||
finishPasskey: (registration:boolean,credential:unknown,name:string) => request(registration?"/api/account/passkeys/finish":"/api/auth/passkey/finish",{method:"POST",body:{credential,name}}),
|
||||
secretEngines: <T = unknown>() => request<T>("/api/secret-engines"),
|
||||
checkSecret: (ref: { engine: string; key: string }) => request<{ resolved: boolean; process: string }>("/api/secret-references/check", { method: "POST", body: ref }),
|
||||
health: <T = unknown>() => request<T>("/health/detailed"),
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ const settings: NavSpec = {
|
||||
"/settings/status",
|
||||
],
|
||||
},
|
||||
{ paths: ["/settings/appearance", "/settings/history"] },
|
||||
{ paths: ["/settings/authentication", "/settings/appearance", "/settings/history"] },
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import App from "./App.vue";
|
||||
import { registerArchieWebMcpTools } from "./lib/archie-webmcp";
|
||||
import router from "./router";
|
||||
import { useAppearanceStore } from "./stores/appearance";
|
||||
import { useSessionStore } from "./stores/session";
|
||||
|
||||
// One stylesheet: the design tokens, and the element defaults that have no
|
||||
// component to live in (the canvas, the focus floor, the motion preference).
|
||||
// Everything else is Tailwind on the component that owns it.
|
||||
@@ -16,7 +16,7 @@ const pinia = createPinia();
|
||||
|
||||
app.use(pinia).use(router);
|
||||
useAppearanceStore(pinia).initialize();
|
||||
useSessionStore(pinia).initialize();
|
||||
|
||||
app.mount("#app");
|
||||
|
||||
// Published after the shell paints: an in-page agent's tools are not worth
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import CreateAccount from "@/accounts/CreateAccount.vue";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
@@ -185,6 +186,7 @@ const remove = (member: Member) =>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<CreateAccount v-if="org?.id===identities.homeOrg" @created="load" />
|
||||
<section class="mt-8 grid gap-6 lg:grid-cols-2" aria-label="Add people">
|
||||
<div>
|
||||
<h2 class="mb-3 text-sm font-medium">Add an identity</h2>
|
||||
|
||||
@@ -42,6 +42,8 @@ import WorkflowsPage from "@/workflows/WorkflowsPage.vue";
|
||||
// route with no section is served in every composition
|
||||
// navPath the navigation entry this route keeps current
|
||||
const routes = [
|
||||
{path:"/account",name:"account",component:()=>import("@/accounts/AccountPage.vue"),meta:{label:"Your account"}},
|
||||
{path:"/settings/authentication",name:"authentication",component:()=>import("@/accounts/AuthenticationPage.vue"),meta:{label:"Authentication",settings:true,navPath:"/settings"}},
|
||||
{
|
||||
path: "/",
|
||||
name: "dashboard",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select"
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { ArrowLeft, Braces, Type } from "@lucide/vue";
|
||||
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
@@ -56,6 +57,7 @@ const rows = ref<Record<string, InputRow>>({});
|
||||
const repositoryPath = ref("");
|
||||
const preview = ref<Preview | null>(null);
|
||||
const saving = ref(false);
|
||||
const confirmRemove=ref(false);
|
||||
const creatingSource = ref(false);
|
||||
const revealed = ref<Source | null>(null);
|
||||
const error = ref("");
|
||||
@@ -221,6 +223,13 @@ async function transition(command: (id: string) => Promise<unknown>, next: strin
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
}
|
||||
async function removeBinding():Promise<void>{
|
||||
if(!props.binding)return;
|
||||
saving.value=true;error.value="";
|
||||
try{await api.bindingDelete(props.binding.id);emit("saved")}
|
||||
catch(cause){error.value=cause instanceof Error?cause.message:String(cause)}
|
||||
finally{saving.value=false}
|
||||
}
|
||||
const approve = () => transition(api.bindingApprove, "armed");
|
||||
const pause = () => transition(api.bindingPause, "paused");
|
||||
const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
@@ -228,6 +237,9 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
|
||||
<template>
|
||||
<div class="flex h-full flex-col">
|
||||
<AlertDialog v-model:open="confirmRemove">
|
||||
<AlertDialogContent><AlertDialogHeader><AlertDialogTitle>Remove event binding?</AlertDialogTitle><AlertDialogDescription>This event will stop starting this workflow. The event source and mapping are kept.</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter><AlertDialogCancel>Cancel</AlertDialogCancel><AlertDialogAction @click="removeBinding">Remove binding</AlertDialogAction></AlertDialogFooter></AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<header class="flex items-center gap-2 border-b border-border px-4 py-3">
|
||||
<Button type="button" variant="ghost" size="icon-sm" aria-label="Back to settings" @click="emit('back')"><ArrowLeft /></Button>
|
||||
<div class="min-w-0 flex-1 truncate text-sm font-medium">{{ binding ? binding.name : "Bind an event" }}</div>
|
||||
@@ -321,11 +333,12 @@ const resume = () => transition(api.bindingResume, "pending_approval");
|
||||
<div class="space-y-2">
|
||||
<p v-if="error" role="alert" class="text-xs text-danger">{{ error }}</p>
|
||||
<p v-else-if="blockers.length" class="text-xs text-fg-subtle">Cannot save: {{ blockers[0] }}</p>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Button type="submit" size="sm" :disabled="saving || !!blockers.length"><Spinner v-if="saving" />Save binding</Button>
|
||||
<Button v-if="binding && status === 'pending_approval'" type="button" size="sm" variant="outline" @click="approve">Approve</Button>
|
||||
<Button v-if="binding && status === 'armed'" type="button" size="sm" variant="outline" @click="pause">Pause</Button>
|
||||
<Button v-if="binding && status === 'paused'" type="button" size="sm" variant="outline" @click="resume">Resume</Button>
|
||||
<Button v-if="binding" type="button" size="sm" variant="destructive" :disabled="saving" @click="confirmRemove=true">Remove binding</Button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -120,7 +120,7 @@ function place(store?: VueFlowStore): void {
|
||||
const reached = graph.value.nodes.find((node) => props.marks?.[node.id]) ?? graph.value.nodes.filter((node) => node.data.run).at(-1);
|
||||
const below = reached && 24 + (reached.position.y + 180) * ZOOM > height;
|
||||
const y = below ? height / 3 - reached.position.y * ZOOM : 24;
|
||||
void flow.setViewport({ x: width / 2 - NODE_WIDTH / 2, y, zoom: ZOOM }, { duration: animate ? 300 : 0 });
|
||||
void flow.setViewport({ x: width / 2 - NODE_WIDTH * ZOOM / 2, y, zoom: ZOOM }, { duration: animate ? 300 : 0 });
|
||||
}
|
||||
|
||||
watch(() => graph.value.nodes.filter((node) => node.data.run).length, () => place());
|
||||
|
||||
@@ -242,8 +242,8 @@ function syncScroll(event: Event): void {
|
||||
<template>
|
||||
<form class="space-y-4" @submit.prevent="saveDraft">
|
||||
<Tabs v-model="view" class="space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<TabsList>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<TabsList class="max-w-full justify-start overflow-x-auto">
|
||||
<TabsTrigger value="canvas">Canvas</TabsTrigger>
|
||||
<TabsTrigger value="yaml">YAML</TabsTrigger>
|
||||
<TabsTrigger v-if="stored !== undefined" value="history">History</TabsTrigger>
|
||||
@@ -318,7 +318,7 @@ function syncScroll(event: Event): void {
|
||||
enter-active-class="transition duration-200"
|
||||
leave-active-class="transition duration-150"
|
||||
>
|
||||
<div v-if="settingsOpen" class="absolute inset-y-0 right-0 overflow-hidden rounded-r-lg">
|
||||
<div v-if="settingsOpen" class="absolute inset-y-0 right-0 max-w-full overflow-hidden rounded-r-lg">
|
||||
<WorkflowSettings v-model:yaml="yaml" :triggers="triggers" @close="settingsOpen = false" @bound="reloadTriggers" />
|
||||
</div>
|
||||
</Transition>
|
||||
@@ -328,7 +328,7 @@ function syncScroll(event: Event): void {
|
||||
enter-active-class="transition duration-200"
|
||||
leave-active-class="transition duration-150"
|
||||
>
|
||||
<div v-if="selectedStep" class="absolute inset-y-0 right-0 flex flex-col overflow-hidden rounded-r-lg border-l border-border bg-card shadow-xl">
|
||||
<div v-if="selectedStep" class="absolute inset-y-0 right-0 flex max-w-full flex-col overflow-hidden rounded-r-lg border-l border-border bg-card shadow-xl">
|
||||
<template v-if="selectedNode?.run && watchedRun">
|
||||
<div class="flex items-center gap-2 border-b border-border px-3 py-2">
|
||||
<Tabs v-model="stepTab"><TabsList><TabsTrigger value="run">Run</TabsTrigger><TabsTrigger value="definition">Definition</TabsTrigger></TabsList></Tabs>
|
||||
|
||||
@@ -84,7 +84,7 @@ function setNeeds(next: { captures?: boolean; gate_retries?: number }): void {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl">
|
||||
<aside class="flex h-full w-[24rem] max-w-full flex-col border-l border-border bg-card shadow-xl">
|
||||
<BindEvent v-if="binding !== undefined" :yaml="yaml" :binding="binding" @back="binding = undefined" @saved="bound" />
|
||||
<template v-else>
|
||||
<header class="flex items-center gap-2 border-b border-border px-4 py-3">
|
||||
@@ -206,8 +206,12 @@ function setNeeds(next: { captures?: boolean; gate_retries?: number }): void {
|
||||
<Badge v-if="trigger.binding.status !== 'armed'" :variant="statusKind(trigger.binding.status)">{{ statusLabel(trigger.binding.status) }}</Badge>
|
||||
<span v-if="trigger.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ trigger.detail }}</span>
|
||||
</button>
|
||||
<div v-else class="flex items-center gap-2 px-3 py-2">
|
||||
<RouterLink v-else-if="trigger.kind==='workflow' || trigger.kind==='playbook'" :to="trigger.kind==='workflow'?{path:'/workflows',query:{workflow:trigger.label}}:{path:'/settings/playbooks'}" class="flex items-center gap-2 px-3 py-2 hover:bg-secondary">
|
||||
<span class="truncate">{{trigger.label}}</span><span class="ml-auto truncate text-xs text-fg-subtle">{{trigger.detail}}</span>
|
||||
</RouterLink>
|
||||
<div v-else class="flex items-center gap-2 px-3 py-2" title="Built-in issue routing. Disable this workflow to stop it running automatically.">
|
||||
<span class="truncate">{{ trigger.label }}</span>
|
||||
<Badge v-if="trigger.kind==='issue'" variant="outline" class="ml-auto">Built-in</Badge>
|
||||
<span v-if="trigger.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ trigger.detail }}</span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -193,8 +193,8 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<p v-if="error" class="mb-4 text-sm text-danger" role="alert">Cannot reach archied: {{ error }}</p>
|
||||
|
||||
<div class="grid items-start gap-6 lg:grid-cols-[24rem_minmax(0,1fr)]">
|
||||
<ul class="flex flex-col gap-0.5" aria-label="Workflows">
|
||||
<li v-for="row in rows" :key="row.id">
|
||||
<ul class="flex gap-1 overflow-x-auto pb-2 lg:flex-col lg:gap-0.5 lg:overflow-visible lg:pb-0" aria-label="Workflows">
|
||||
<li v-for="row in rows" :key="row.id" class="min-w-36 shrink-0 lg:min-w-0">
|
||||
<button
|
||||
type="button"
|
||||
:aria-current="row.id === selected ? 'true' : undefined"
|
||||
@@ -227,7 +227,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</section>
|
||||
<section v-else class="min-w-0 rounded-lg border border-border bg-card px-5 py-4" aria-label="Workflow">
|
||||
<section v-else class="min-w-0 rounded-lg border border-border bg-card px-3 py-4 sm:px-5" aria-label="Workflow">
|
||||
<header class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<h2 class="font-mono text-[15px] font-medium">{{ selected }}</h2>
|
||||
<Badge v-if="provenance" variant="outline">{{ provenance }}</Badge>
|
||||
|
||||
Reference in new issue
Block a user