typevault 0.1.0 → 0.2.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.
Files changed (72) hide show
  1. package/README.md +156 -115
  2. package/package.json +14 -2
  3. package/src/access/env.ts +77 -17
  4. package/src/access/keys.ts +14 -14
  5. package/src/access/schemas.ts +6 -12
  6. package/src/access/scope.ts +7 -7
  7. package/src/access/scoped.ts +100 -44
  8. package/src/access/sealed-access.ts +45 -23
  9. package/src/access/sealed.ts +33 -21
  10. package/src/access/types.ts +25 -30
  11. package/src/admin.ts +68 -0
  12. package/src/audit/log.ts +14 -9
  13. package/src/cli/commands/admin.ts +87 -47
  14. package/src/cli/commands/daemon.ts +33 -15
  15. package/src/cli/commands/entries.ts +166 -55
  16. package/src/cli/commands/grant.ts +12 -20
  17. package/src/cli/commands/members.ts +281 -0
  18. package/src/cli/commands/run.ts +61 -24
  19. package/src/cli/context.ts +155 -15
  20. package/src/cli/index.ts +27 -4
  21. package/src/cli/password.ts +74 -0
  22. package/src/cli/web-prompt.ts +65 -0
  23. package/src/core/admin.ts +125 -74
  24. package/src/core/adopt.ts +40 -9
  25. package/src/core/crypto.ts +6 -4
  26. package/src/core/doctor.ts +9 -9
  27. package/src/core/entries.ts +66 -52
  28. package/src/core/errors.ts +6 -0
  29. package/src/core/fsx.ts +7 -3
  30. package/src/core/holder.ts +84 -0
  31. package/src/core/identity.ts +130 -0
  32. package/src/core/init.ts +73 -23
  33. package/src/core/keyring.ts +100 -56
  34. package/src/core/layout.ts +145 -26
  35. package/src/core/lock.ts +128 -16
  36. package/src/core/naming.ts +146 -49
  37. package/src/core/password.ts +111 -0
  38. package/src/core/payload.ts +42 -38
  39. package/src/core/revisions.ts +8 -4
  40. package/src/core/rotate.ts +59 -42
  41. package/src/core/state.ts +88 -48
  42. package/src/core/txn.ts +5 -4
  43. package/src/core/vault.ts +108 -46
  44. package/src/core/worktrees.ts +39 -0
  45. package/src/daemon/admin-routes.ts +33 -21
  46. package/src/daemon/agent-routes.ts +29 -11
  47. package/src/daemon/client.ts +15 -0
  48. package/src/daemon/daemon.ts +210 -32
  49. package/src/daemon/grants.ts +21 -4
  50. package/src/daemon/http.ts +3 -0
  51. package/src/daemon/live-access.ts +4 -4
  52. package/src/daemon/protocol.ts +17 -12
  53. package/src/daemon/requests.ts +17 -22
  54. package/src/daemon/spawn.ts +188 -9
  55. package/src/export/1password.ts +157 -0
  56. package/src/import/1password-live.ts +399 -0
  57. package/src/import/1password.ts +26 -5
  58. package/src/import/bitwarden.ts +3 -3
  59. package/src/import/csv.ts +1 -1
  60. package/src/import/dotenv.ts +2 -2
  61. package/src/import/index.ts +1 -0
  62. package/src/import/keepass.ts +2 -2
  63. package/src/import/lastpass.ts +2 -2
  64. package/src/import/shared.ts +67 -10
  65. package/src/import/typeclaw.ts +2 -2
  66. package/src/import/types.ts +1 -1
  67. package/src/index.ts +58 -0
  68. package/src/owner.ts +156 -0
  69. package/src/prompt/browser.ts +48 -15
  70. package/src/prompt/page.ts +19 -11
  71. package/src/prompt/styles.ts +64 -34
  72. package/src/prompt/types.ts +3 -3
package/src/index.ts ADDED
@@ -0,0 +1,58 @@
1
+ import type { Access } from './access/types'
2
+ import { type Env, resolveAccess } from './cli/context'
3
+ import { TypeVaultError } from './core/errors'
4
+
5
+ export type { Access, EntrySummary, EntryValue, SetInput } from './access/types'
6
+ export { type ErrorCode, TypeVaultError } from './core/errors'
7
+ export {
8
+ type EntryName,
9
+ type EntryRef,
10
+ type FieldType,
11
+ type Field,
12
+ type Preset,
13
+ PRESETS,
14
+ defaultField,
15
+ resolveField,
16
+ parseEntryName,
17
+ parseEntryRef,
18
+ parsePreset,
19
+ } from './core/naming'
20
+
21
+ export type ClientOptions = {
22
+ /** A live (`tvl1.…`), sealed (`tvg1:…`) or `@path` grant. Defaults to `TYPEVAULT_GRANT`. */
23
+ readonly grant?: string
24
+ /** The global vault's directory. Defaults to `TYPEVAULT_DIR`; without one the vault is chosen like the CLI's. */
25
+ readonly dir?: string
26
+ /** Use the global vault instead of the project's, like the CLI's `-g`. Defaults to `TYPEVAULT_GLOBAL`. */
27
+ readonly global?: boolean
28
+ /** Without a grant, open the vault with this machine's own keys (owner, issuers). Off by default. */
29
+ readonly direct?: boolean
30
+ /** The vault's private state (trust pin, audit, run). Defaults to `TYPEVAULT_STATE_DIR`, else this user's config. */
31
+ readonly stateDir?: string
32
+ /** Where the daemon's sockets live, for a `stateDir` too deep for one. Defaults to `TYPEVAULT_RUN_DIR`. */
33
+ readonly runDir?: string
34
+ /** Where the defaults above are read from. Defaults to `process.env`. */
35
+ readonly env?: Env
36
+ }
37
+
38
+ /**
39
+ * The same access the CLI has: a live grant goes through the daemon (started if needed), a sealed grant is read
40
+ * in-process. Values returned here are not redacted anywhere: pass `readValues()` to `typevault/redact` if they
41
+ * can reach output.
42
+ */
43
+ export async function createClient(options: ClientOptions = {}): Promise<Access> {
44
+ const base = options.env ?? process.env
45
+ const grant = (options.grant ?? base['TYPEVAULT_GRANT'])?.trim()
46
+ if ((grant === undefined || grant === '') && options.direct !== true) {
47
+ throw new TypeVaultError('denied', 'no grant given (pass `grant`, set TYPEVAULT_GRANT, or opt into `direct`)')
48
+ }
49
+ const env: Env = {
50
+ ...base,
51
+ TYPEVAULT_GRANT: grant,
52
+ ...(options.dir === undefined ? {} : { TYPEVAULT_DIR: options.dir }),
53
+ ...(options.global === undefined ? {} : { TYPEVAULT_GLOBAL: options.global ? '1' : '' }),
54
+ ...(options.stateDir === undefined ? {} : { TYPEVAULT_STATE_DIR: options.stateDir }),
55
+ ...(options.runDir === undefined ? {} : { TYPEVAULT_RUN_DIR: options.runDir }),
56
+ }
57
+ return (await resolveAccess(env)).access
58
+ }
package/src/owner.ts ADDED
@@ -0,0 +1,156 @@
1
+ import { existsSync } from 'node:fs'
2
+
3
+ import { ScopedVault } from './access/scoped'
4
+ import type { Access } from './access/types'
5
+ import { Admin } from './core/admin'
6
+ import { decodeSecretKey, encodeSecretKey } from './core/crypto'
7
+ import { TypeVaultError } from './core/errors'
8
+ import { claimDaemon } from './core/holder'
9
+ import { createIdentity, decodeMemberPublic, encodeMemberPublic, memberPublicOfIdentity } from './core/identity'
10
+ import { initLocalVault } from './core/init'
11
+ import { localLayout } from './core/layout'
12
+ import { holdLock } from './core/lock'
13
+ import type { MemberKind } from './core/state'
14
+ import { Vault } from './core/vault'
15
+
16
+ export type { Access, EntrySummary, EntryValue, SetInput } from './access/types'
17
+ export { type ErrorCode, TypeVaultError } from './core/errors'
18
+
19
+ /** A machine member: no password, its key held by whoever runs it. */
20
+ export type MachineIdentity = {
21
+ readonly name: string
22
+ /** The secret member key (what `TYPEVAULT_KEY` takes). Keep it private. */
23
+ readonly key: string
24
+ /** The `tvp1:` public key an owner adds as a member. */
25
+ readonly publicKey: string
26
+ }
27
+
28
+ /** Where a vault and its private state live. Nothing is read from or written to this user's config. */
29
+ export type VaultLocation = {
30
+ /** The vault directory, e.g. `<project>/.typevault`. */
31
+ readonly dir: string
32
+ /** The vault's private state (trust pin, audit, run). One machine at a time may use it. */
33
+ readonly stateDir: string
34
+ /** Where the daemon's sockets live, for a `stateDir` too deep for a socket path. */
35
+ readonly runDir?: string
36
+ }
37
+
38
+ export type TierInfo = { readonly name: string; readonly gen: number; readonly includes: readonly string[] }
39
+ export type MemberInfo = {
40
+ readonly name: string
41
+ readonly kind: MemberKind
42
+ readonly owner: boolean
43
+ readonly tiers: readonly string[]
44
+ }
45
+
46
+ export type OwnerVault = {
47
+ readonly member: string
48
+ readonly tiers: {
49
+ add(name: string): Promise<void>
50
+ /** `tier` reaches everything `included` reaches. */
51
+ include(tier: string, included: string): Promise<void>
52
+ list(): Promise<readonly TierInfo[]>
53
+ }
54
+ readonly ceilings: {
55
+ /** The most the admin socket `name` may grant. */
56
+ set(name: string, tier: string): Promise<void>
57
+ }
58
+ readonly members: {
59
+ list(): Promise<readonly MemberInfo[]>
60
+ }
61
+ /** Entries, read and written with this member's own keys (direct mode, audited). */
62
+ readonly entries: Access
63
+ }
64
+
65
+ /** A new machine identity, returned only: no file is written. */
66
+ export async function createMachineIdentity(options: { readonly name: string }): Promise<MachineIdentity> {
67
+ const { identity, key } = await createIdentity(options.name, 'machine')
68
+ return {
69
+ name: identity.name,
70
+ key: encodeSecretKey(key),
71
+ publicKey: encodeMemberPublic(memberPublicOfIdentity(identity)),
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Creates an empty vault at `dir` owned by a machine `founder`. Fails with `conflict` when a vault is already there
77
+ * (it never initializes over one) or a daemon is using `stateDir`, and `in_use` when one on another machine is.
78
+ */
79
+ export async function initVault(
80
+ options: VaultLocation & { readonly founder: Pick<MachineIdentity, 'name' | 'publicKey'> },
81
+ ): Promise<void> {
82
+ const member = decodeMemberPublic(options.founder.publicKey)
83
+ if (member.kind !== 'machine') throw new TypeVaultError('invalid', 'the founder must be a machine identity')
84
+ const env = envOf(options)
85
+ const layout = localLayout(options.dir, env)
86
+ // Initializing resets the state directory's runtime state: no daemon may be using it, here or on another machine.
87
+ const release = holdLock(layout.daemonLock)
88
+ if (release === undefined) {
89
+ throw new TypeVaultError('conflict', `a typevault daemon is using ${options.stateDir}; stop it first`)
90
+ }
91
+ try {
92
+ const claim = claimDaemon(layout, env)
93
+ try {
94
+ await initLocalVault(options.dir, { name: options.founder.name, member }, env)
95
+ } finally {
96
+ claim.release()
97
+ }
98
+ } finally {
99
+ release()
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Opens the vault at `dir` with a member key held in memory. Fails with `no_vault` when there is no vault at `dir`,
105
+ * and `not_member` when there is one but `key` is not among its members. Tier and ceiling changes need an owner.
106
+ */
107
+ export async function openVault(options: VaultLocation & { readonly key: string }): Promise<OwnerVault> {
108
+ const env = envOf(options)
109
+ const layout = localLayout(options.dir, env)
110
+ if (!existsSync(layout.ownerFile)) throw new TypeVaultError('no_vault', `no vault at ${options.dir}`)
111
+ const key = decodeSecretKey(options.key)
112
+ if (key.role.kind !== 'member') throw new TypeVaultError('invalid', 'the key must be a member key')
113
+ const vault = await Vault.open(layout, [key], env)
114
+ const member = vault.member
115
+ if (member === undefined) {
116
+ throw new TypeVaultError('not_member', `"${key.role.name}" is not a member of the vault at ${options.dir}`)
117
+ }
118
+ const admin = (): Admin => new Admin(vault)
119
+ const current = async () => {
120
+ vault.refresh()
121
+ return vault.state
122
+ }
123
+ return {
124
+ member,
125
+ tiers: {
126
+ add: (name) => admin().addTier(name),
127
+ include: (tier, included) => admin().include(tier, included),
128
+ list: async () =>
129
+ Object.entries((await current()).tiers).map(([name, tier]) => ({
130
+ name,
131
+ gen: tier.gen,
132
+ includes: tier.includes,
133
+ })),
134
+ },
135
+ ceilings: { set: (name, tier) => admin().setCeiling(name, tier) },
136
+ members: {
137
+ list: async () =>
138
+ Object.entries((await current()).members).map(([name, m]) => ({
139
+ name,
140
+ kind: m.kind,
141
+ owner: m.owner,
142
+ tiers: m.tiers,
143
+ })),
144
+ },
145
+ entries: new ScopedVault(vault, [], { mode: 'direct', ownTiers: vault.state.members[member]?.tiers ?? [] }),
146
+ }
147
+ }
148
+
149
+ function envOf(location: VaultLocation): Readonly<Record<string, string | undefined>> {
150
+ if (location.stateDir === '') throw new TypeVaultError('invalid', 'stateDir is required')
151
+ return {
152
+ TYPEVAULT_STATE_DIR: location.stateDir,
153
+ ...(location.runDir === undefined ? {} : { TYPEVAULT_RUN_DIR: location.runDir }),
154
+ ...(process.env['TYPEVAULT_HOST_ID'] === undefined ? {} : { TYPEVAULT_HOST_ID: process.env['TYPEVAULT_HOST_ID'] }),
155
+ }
156
+ }
@@ -2,12 +2,13 @@ import { Encrypter } from 'age-encryption'
2
2
  import { z } from 'zod'
3
3
 
4
4
  import { TypeVaultError } from '../core/errors'
5
- import { ENTRY_TYPES, parseEntryName, parseEntryType } from '../core/naming'
5
+ import { PRESETS, parseEntryName, parsePreset, type Field, type FieldType } from '../core/naming'
6
+ import { FieldSchema } from '../core/payload'
6
7
  import type { EntryPayload } from '../core/payload'
7
8
 
8
9
  const ViewSchema = z.object({
9
10
  name: z.string(),
10
- type: z.string(),
11
+ preset: z.string().optional(),
11
12
  recipients: z.array(z.string()).min(1),
12
13
  })
13
14
 
@@ -17,6 +18,8 @@ function requiredElement<T extends HTMLElement>(selector: string, kind: { new ()
17
18
  throw new TypeVaultError('invalid', 'The request page is incomplete. Open a new request.')
18
19
  }
19
20
 
21
+ const ACRONYMS = new Set(['url', 'totp', 'id', 'api', 'ssh'])
22
+
20
23
  const form = requiredElement('#prompt', HTMLFormElement)
21
24
  const fieldsRoot = requiredElement('#fields', HTMLDivElement)
22
25
  const status = requiredElement('#status', HTMLParagraphElement)
@@ -26,27 +29,44 @@ const success = requiredElement('#success', HTMLElement)
26
29
  function initialize(): void {
27
30
  const data = requiredElement('#tv-data', HTMLScriptElement)
28
31
  const view = ViewSchema.parse(JSON.parse(data.textContent ?? ''))
29
- const type = parseEntryType(view.type)
32
+ const preset =
33
+ view.preset === undefined
34
+ ? { fields: { $default: 'secret' } as const, input: '$default' }
35
+ : PRESETS[parsePreset(view.preset)]
30
36
  const name = parseEntryName(view.name)
31
37
  const inputs: (HTMLInputElement | HTMLTextAreaElement)[] = []
32
- const publicFields = new Set(['username', 'url', 'expires_at', 'token_url', 'client_id', 'public_key', 'text'])
33
- for (const field of ENTRY_TYPES[type].fields) {
34
- const secret = !publicFields.has(field)
38
+ const types: Readonly<Record<string, FieldType>> = preset.fields
39
+ for (const [field, type] of Object.entries(types)) {
40
+ const secret = type !== 'text'
35
41
  const wrapper = document.createElement('div')
36
42
  wrapper.className = 'field'
37
43
  const label = document.createElement('label')
38
44
  label.htmlFor = `field-${field}`
39
- label.textContent = field.replaceAll('_', ' ').replace(/^./, (char) => char.toUpperCase())
45
+ const fieldName = (field === '$default' ? (type === 'oauth' ? 'OAuth JSON' : 'Secret') : field)
46
+ .split('_')
47
+ .map((word) => (ACRONYMS.has(word) ? word.toUpperCase() : word))
48
+ .join(' ')
49
+ .replace(/^./, (char) => char.toUpperCase())
50
+ label.textContent = fieldName
40
51
  const row = document.createElement('div')
41
52
  row.className = 'input-row'
42
- const input = ['text', 'private_key', 'public_key'].includes(field)
43
- ? document.createElement('textarea')
44
- : document.createElement('input')
53
+ const input =
54
+ type === 'oauth' ||
55
+ (field === '$default' && view.preset === 'note') ||
56
+ ['text', 'private_key', 'public_key'].includes(field)
57
+ ? document.createElement('textarea')
58
+ : document.createElement('input')
45
59
  input.id = label.htmlFor
46
60
  input.name = field
47
61
  input.autocomplete = 'off'
48
62
  input.spellcheck = false
49
- input.required = field === ENTRY_TYPES[type].primary
63
+ input.required = field === preset.input
64
+ if (!input.required) {
65
+ const optional = document.createElement('span')
66
+ optional.className = 'optional'
67
+ optional.textContent = 'Optional'
68
+ label.append(optional)
69
+ }
50
70
  if (input instanceof HTMLInputElement) input.type = secret ? 'password' : 'text'
51
71
  else if (secret) input.classList.add('concealed')
52
72
  inputs.push(input)
@@ -56,14 +76,14 @@ function initialize(): void {
56
76
  toggle.type = 'button'
57
77
  toggle.className = 'toggle'
58
78
  toggle.textContent = 'Show'
59
- toggle.setAttribute('aria-label', `Show ${label.textContent.toLowerCase()}`)
79
+ toggle.setAttribute('aria-label', `Show ${fieldName.toLowerCase()}`)
60
80
  toggle.setAttribute('aria-pressed', 'false')
61
81
  toggle.addEventListener('click', () => {
62
82
  const show = toggle.getAttribute('aria-pressed') !== 'true'
63
83
  if (input instanceof HTMLInputElement) input.type = show ? 'text' : 'password'
64
84
  else input.classList.toggle('concealed', !show)
65
85
  toggle.setAttribute('aria-pressed', String(show))
66
- toggle.setAttribute('aria-label', `${show ? 'Hide' : 'Show'} ${label.textContent?.toLowerCase()}`)
86
+ toggle.setAttribute('aria-label', `${show ? 'Hide' : 'Show'} ${fieldName.toLowerCase()}`)
67
87
  toggle.textContent = show ? 'Hide' : 'Show'
68
88
  })
69
89
  row.append(toggle)
@@ -83,9 +103,22 @@ function initialize(): void {
83
103
  const payload: EntryPayload = {
84
104
  v: 1,
85
105
  name,
86
- type,
87
106
  fields: Object.fromEntries(
88
- inputs.filter((input) => input.value !== '').map((input) => [input.name, input.value]),
107
+ inputs
108
+ .filter((input) => input.value !== '')
109
+ .map((input): [string, Field] => {
110
+ const type = types[input.name] ?? 'secret'
111
+ switch (type) {
112
+ case 'oauth':
113
+ return [input.name, FieldSchema.parse({ type, value: JSON.parse(input.value) })]
114
+ case 'secret':
115
+ case 'text':
116
+ case 'totp':
117
+ return [input.name, { type, value: input.value }]
118
+ default:
119
+ throw new TypeVaultError('invalid', `unexpected field type ${type satisfies never}`)
120
+ }
121
+ }),
89
122
  ),
90
123
  tags: [],
91
124
  created: now,
@@ -1,4 +1,5 @@
1
1
  import { createHash } from 'node:crypto'
2
+ import { fileURLToPath } from 'node:url'
2
3
 
3
4
  import { TypeVaultError } from '../core/errors'
4
5
  import { styles } from './styles'
@@ -13,7 +14,7 @@ export function pageAssets(): ReturnType<typeof buildAssets> {
13
14
 
14
15
  async function buildAssets() {
15
16
  const result = await Bun.build({
16
- entrypoints: [new URL('./browser.ts', import.meta.url).pathname],
17
+ entrypoints: [fileURLToPath(new URL('./browser.ts', import.meta.url))],
17
18
  target: 'browser',
18
19
  minify: true,
19
20
  })
@@ -35,6 +36,11 @@ async function buildAssets() {
35
36
  }
36
37
  }
37
38
 
39
+ const LOCK_ICON =
40
+ '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>'
41
+ const CHECK_ICON =
42
+ '<svg width="44" height="44" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m8 12.5 2.5 2.5L16 9.5"/></svg>'
43
+
38
44
  function escapeHtml(value: string): string {
39
45
  return value.replace(/[&<>"']/g, (char) => {
40
46
  const entities: Readonly<Record<string, string>> = {
@@ -60,17 +66,19 @@ export function promptPage(view: PromptView, script: string): string {
60
66
  return shell(
61
67
  'Secret request',
62
68
  `
69
+ <header><p class="eyebrow">Secret request</p>
63
70
  <h1>${escapeHtml(view.name)}</h1>
64
- <p class="muted">Readable by: ${escapeHtml(view.group)}</p>
65
- <div class="context"><p class="reason">${escapeHtml(view.reason)}</p>
66
- <p class="muted">Requested by: ${escapeHtml(view.requester)}</p></div>
67
- <section class="match" aria-label="Match code"><p class="code">${escapeHtml(view.code)}</p>
68
- <p class="hint">Compare this code with the one in your chat before entering a secret.</p></section>
71
+ <p class="reason">${escapeHtml(view.reason)}</p>
72
+ <dl class="meta"><div><dt>Requested by</dt><dd>${escapeHtml(view.requester)}</dd></div>
73
+ <div><dt>Readable by</dt><dd>${escapeHtml(view.tier)}</dd></div></dl></header>
74
+ <section class="match" aria-label="Match code"><div class="match-text"><p class="match-label">Match code</p>
75
+ <p class="hint">Make sure your chat shows the same code.</p></div>
76
+ <p class="code">${escapeHtml(view.code)}</p></section>
69
77
  <form id="prompt"><div id="fields"></div>
70
- <p class="hint">Encrypted in your browser. Only the selected group's recipients can read this secret.</p>
78
+ <div class="actions"><p id="status" role="alert"></p>
71
79
  <button id="submit" type="submit">Encrypt and submit</button>
72
- <p id="status" role="alert"></p></form>
73
- <section id="success" hidden role="status" tabindex="-1"><h2>Secret submitted</h2>
80
+ <p class="note">${LOCK_ICON}<span>Encrypted in your browser. Only the selected tier's recipients can read this secret.</span></p></div></form>
81
+ <section id="success" class="done" hidden role="status" tabindex="-1">${CHECK_ICON}<h2>Secret submitted</h2>
74
82
  <p>Your encrypted secret was delivered. You can close this page.</p></section>
75
83
  <noscript>JavaScript is required to encrypt your secret before it leaves this browser.</noscript>
76
84
  <script type="application/json" id="tv-data">${data}</script><script type="module">${script}</script>`,
@@ -80,7 +88,7 @@ export function promptPage(view: PromptView, script: string): string {
80
88
  export function expiredPage(): string {
81
89
  return shell(
82
90
  'Request unavailable',
83
- `<h1>Expired or already used</h1>
84
- <p>This one-time request is no longer available. Ask the agent for a new link and match code.</p>`,
91
+ `<p class="eyebrow">Secret request</p><h1>Expired or already used</h1>
92
+ <p class="reason">This one-time request is no longer available. Ask the agent for a new link and match code.</p>`,
85
93
  )
86
94
  }
@@ -1,57 +1,87 @@
1
1
  export const styles = `
2
2
  :root {
3
3
  color-scheme: light dark;
4
- --canvas: #f4f5f2; --surface: #ffffff; --ink: #202c29; --muted: #52635c;
5
- --line: #82938b; --soft: #eaf0ec; --accent: #235a46; --on-accent: #ffffff;
6
- --hover: #194735; --error: #a52b32; --focus: #236448;
4
+ --canvas: #f5f6fa; --surface: #ffffff; --ink: #141a2e; --muted: #575f7c;
5
+ --line: #e1e6f4; --field: #8d98c4; --soft: #f1f3fa; --accent: #4f5ed7; --on-accent: #ffffff;
6
+ --hover: #3f4ec4; --error: #b42335; --error-soft: #fcf0f1; --focus: #4f5ed7;
7
+ --ring: rgb(79 94 215 / .18); --shadow: 0 1px 2px rgb(13 23 54 / .05), 0 12px 32px rgb(13 23 54 / .08);
7
8
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
8
- scrollbar-color: var(--line) var(--canvas);
9
+ scrollbar-color: var(--field) var(--canvas);
9
10
  }
10
11
  @media (prefers-color-scheme: dark) {
11
12
  :root {
12
- --canvas: #141b18; --surface: #1e2823; --ink: #edf3ee; --muted: #b3c4b9;
13
- --line: #7b9183; --soft: #2a3830; --accent: #aad7bb; --on-accent: #14251b;
14
- --hover: #c4e8d0; --error: #ffabb0; --focus: #aad7bb;
13
+ --canvas: #0a0f1f; --surface: #121a31; --ink: #eef1fb; --muted: #a9b2d6;
14
+ --line: #232d4d; --field: #4d5d9e; --soft: #1a2343; --accent: #9da7d2; --on-accent: #0d1736;
15
+ --hover: #c3cae6; --error: #ffabb5; --error-soft: #3a1d2a; --focus: #9da7d2;
16
+ --ring: rgb(157 167 210 / .22); --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px rgb(0 0 0 / .3);
15
17
  }
16
18
  }
17
19
  * { box-sizing: border-box; }
18
- body { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px;
19
- background: var(--canvas); color: var(--ink); }
20
- main { width: min(100%, 528px); background: var(--surface); border-radius: 20px; padding: 40px;
21
- overflow-wrap: anywhere; }
22
- h1 { font-size: 32px; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 12px; }
20
+ body { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: 40px 16px;
21
+ background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
22
+ main { width: min(100%, 480px); background: var(--surface); border: 1px solid var(--line);
23
+ border-radius: 20px; padding: 36px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
24
+ h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.02em; margin: 0; }
25
+ h2 { font-size: 20px; line-height: 1.3; margin: 0 0 6px; }
23
26
  p { margin: 0; }
24
- .muted, .hint { color: var(--muted); }
25
- .context { display: grid; gap: 8px; margin: 24px 0; }
26
- .reason { white-space: pre-wrap; }
27
- .match { padding: 20px 0; border-block: 1px solid var(--line); margin-bottom: 28px; }
28
- .code { font: 600 28px/1.4 ui-monospace, monospace; letter-spacing: .05em; font-variant-numeric: tabular-nums; }
29
- .hint { font-size: 14px; margin-top: 8px; }
30
- form, #fields { display: grid; gap: 24px; }
31
- .field { display: grid; gap: 8px; }
32
- label { font-weight: 600; }
33
- .input-row { display: flex; gap: 8px; align-items: start; }
34
- input, textarea { width: 100%; min-width: 0; min-height: 48px; border: 1px solid var(--line);
35
- border-radius: 8px; padding: 12px; background: var(--surface); color: var(--ink); font: inherit;
36
- caret-color: var(--accent); }
37
- textarea { min-height: 144px; resize: vertical; }
27
+ .eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
28
+ color: var(--accent); margin-bottom: 6px; }
29
+ .reason { white-space: pre-wrap; margin-top: 12px; }
30
+ .meta { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 16px 0 0; font-size: 14px; }
31
+ .meta div { display: flex; gap: 6px; min-width: 0; }
32
+ .meta dt { color: var(--muted); }
33
+ .meta dd { margin: 0; font-weight: 500; }
34
+ .match { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
35
+ margin: 28px 0; padding: 16px 20px; background: var(--soft); border-radius: 12px; }
36
+ .match-text { flex: 1 1 200px; }
37
+ .match-label { font-weight: 600; font-size: 14px; }
38
+ .code { font: 600 26px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em;
39
+ font-variant-numeric: tabular-nums; }
40
+ .hint, .note { font-size: 14px; color: var(--muted); }
41
+ .match .hint { margin-top: 2px; }
42
+ form, #fields { display: grid; gap: 20px; }
43
+ form { gap: 24px; }
44
+ .field { display: grid; gap: 6px; }
45
+ label { font-weight: 600; font-size: 15px; }
46
+ .optional { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
47
+ .input-row { position: relative; }
48
+ input, textarea { display: block; width: 100%; min-width: 0; min-height: 46px; border: 1px solid var(--field);
49
+ border-radius: 10px; padding: 11px 12px; background: var(--surface); color: var(--ink); font: inherit;
50
+ caret-color: var(--accent); transition: border-color .15s, box-shadow .15s; }
51
+ input:hover, textarea:hover { border-color: var(--muted); }
52
+ input:focus, textarea:focus { outline: 2px solid transparent; outline-offset: 2px; border-color: var(--focus); box-shadow: 0 0 0 4px var(--ring); }
53
+ .input-row:has(.toggle) input, .input-row:has(.toggle) textarea { padding-right: 76px;
54
+ font-family: ui-monospace, "SF Mono", Menlo, monospace; }
55
+ textarea { min-height: 128px; resize: vertical; }
38
56
  .concealed { -webkit-text-security: disc; }
39
- button { min-height: 48px; border: 0; border-radius: 8px; padding: 12px 16px; cursor: pointer;
40
- font: 600 16px/1.5 system-ui, sans-serif; color: var(--on-accent); background: var(--accent); }
57
+ button { min-height: 48px; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
58
+ font: 600 16px/1.5 system-ui, sans-serif; color: var(--on-accent); background: var(--accent);
59
+ transition: background-color .15s; }
41
60
  button:hover { background: var(--hover); }
42
61
  button:active { opacity: .85; }
43
62
  button:disabled { cursor: default; opacity: .65; }
44
- .toggle { width: 80px; flex-shrink: 0; background: var(--soft); color: var(--ink); }
45
- .toggle:hover { background: var(--canvas); }
63
+ .toggle { position: absolute; top: 7px; right: 7px; min-height: 32px; width: 60px; padding: 4px 0;
64
+ font-size: 13px; border-radius: 7px; background: var(--soft); color: var(--ink); }
65
+ .toggle:hover { background: var(--line); }
46
66
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
47
67
  ::selection { background: var(--accent); color: var(--on-accent); }
68
+ .actions { display: grid; gap: 12px; }
69
+ .note { display: flex; gap: 8px; align-items: flex-start; }
70
+ .note svg, .done svg { flex-shrink: 0; }
71
+ .note svg { margin-top: 2px; }
48
72
  #submit { width: 100%; }
49
- #status { color: var(--error); }
73
+ #status { color: var(--error); background: var(--error-soft); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
50
74
  #status:empty { display: none; }
51
- #success { margin-top: 24px; }
75
+ #success { margin-top: 4px; }
76
+ .done { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 12px 0 4px; }
77
+ .done svg { color: var(--accent); margin-bottom: 8px; }
78
+ .done p { color: var(--muted); }
79
+ noscript { display: block; margin-top: 16px; color: var(--error); }
52
80
  [hidden] { display: none !important; }
53
81
  @media (max-width: 480px) {
54
- body { padding: 16px; }
55
- main { padding: 28px 24px; border-radius: 16px; }
82
+ body { padding: 12px; place-items: start center; }
83
+ main { padding: 24px 20px; border-radius: 16px; }
84
+ h1 { font-size: 23px; }
85
+ .match { padding: 14px 16px; }
56
86
  }
57
87
  `
@@ -1,9 +1,9 @@
1
- import type { EntryType } from '../core/naming'
1
+ import type { Preset } from '../core/naming'
2
2
 
3
3
  export type PromptView = {
4
4
  readonly name: string
5
- readonly type: EntryType
6
- readonly group: string
5
+ readonly preset?: Preset | undefined
6
+ readonly tier: string
7
7
  readonly reason: string
8
8
  readonly requester: string
9
9
  readonly code: string