sideora 0.0.1-alpha.0 → 0.1.0-alpha.2

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 (221) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +57 -6
  3. package/assets/sounds/freesound_community-mail-40275.mp3 +0 -0
  4. package/assets/sounds/mixkit-clear-announce-tones-2861.wav +0 -0
  5. package/assets/sounds/mixkit-happy-bells-notification-937.wav +0 -0
  6. package/assets/sounds/mixkit-musical-alert-notification-2309.wav +0 -0
  7. package/assets/sounds/nice-chime.mp3 +0 -0
  8. package/bin/sideora.js +2430 -12
  9. package/extension/dist/assets/background.ts-NW8YqAlO.js +1 -0
  10. package/extension/dist/assets/fillCode-Ci8IkBvY.js +1 -0
  11. package/extension/dist/assets/index.html-DrrPha1M.js +2 -0
  12. package/extension/dist/assets/modulepreload-polyfill-DcjICKwh.js +1 -0
  13. package/extension/dist/assets/shell-82MNMljp.css +1 -0
  14. package/extension/dist/assets/shell-QYBN1bx1.js +1 -0
  15. package/extension/dist/icons/icon-128.png +0 -0
  16. package/extension/dist/icons/icon-16.png +0 -0
  17. package/extension/dist/icons/icon-32.png +0 -0
  18. package/extension/dist/icons/icon-48.png +0 -0
  19. package/extension/dist/manifest.json +40 -0
  20. package/extension/dist/service-worker-loader.js +1 -0
  21. package/extension/dist/src/newtab/index.html +14 -0
  22. package/extension/dist/src/panel/index.html +15 -0
  23. package/extension/dist-web/assets/abnfDiagram-WEYOIA3C-CoXOc872.js +1 -0
  24. package/extension/dist-web/assets/apple-touch-icon-DSgRQASq.png +0 -0
  25. package/extension/dist-web/assets/architecture-WOLXFQ4H-BkJ4AerO.js +1 -0
  26. package/extension/dist-web/assets/architectureDiagram-ZHVYKT53-aPkSDlxA.js +36 -0
  27. package/extension/dist-web/assets/blockDiagram-RJAE7QA3-CH1G4NBZ.js +140 -0
  28. package/extension/dist-web/assets/c4Diagram-XDPPPE54-Baum1zDu.js +38 -0
  29. package/extension/dist-web/assets/channel-PsQg-mnK.js +1 -0
  30. package/extension/dist-web/assets/chunk-2E7WHVMD-CKvLrWRa.js +88 -0
  31. package/extension/dist-web/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  32. package/extension/dist-web/assets/chunk-4EMNKR2T-6fjnroCZ.js +1 -0
  33. package/extension/dist-web/assets/chunk-55XCU76K-Ygs3sNpi.js +1 -0
  34. package/extension/dist-web/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  35. package/extension/dist-web/assets/chunk-7S6XSTFO-iX5xYzfP.js +2 -0
  36. package/extension/dist-web/assets/chunk-AQDTSKZB-D9zwhFI8.js +72 -0
  37. package/extension/dist-web/assets/chunk-DSNLSHJZ-siGS-4qu.js +129 -0
  38. package/extension/dist-web/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  39. package/extension/dist-web/assets/chunk-HAGFOTED-_3dtnWXn.js +62 -0
  40. package/extension/dist-web/assets/chunk-HNE4Q36P-BPzRHi72.js +1 -0
  41. package/extension/dist-web/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  42. package/extension/dist-web/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  43. package/extension/dist-web/assets/chunk-NGNAAXSQ-DI_UYJZ4.js +136 -0
  44. package/extension/dist-web/assets/chunk-NQOKRVIF-AXbmOBjs.js +213 -0
  45. package/extension/dist-web/assets/chunk-UHW7PFBP-B3xrZ8sD.js +1 -0
  46. package/extension/dist-web/assets/chunk-VQ5W62QI-D_k7Pa6b.js +1 -0
  47. package/extension/dist-web/assets/chunk-WQQL4CDK-BBIrWwoZ.js +10 -0
  48. package/extension/dist-web/assets/chunk-XXDRQBXY-i7MKP1NY.js +1 -0
  49. package/extension/dist-web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  50. package/extension/dist-web/assets/chunk-YZO67HFG-Z7qp5QAI.js +1 -0
  51. package/extension/dist-web/assets/chunk-ZAUX2LTX-CSt3c0Rb.js +1 -0
  52. package/extension/dist-web/assets/chunk-ZCHMQSOR-g8XRABGK.js +2 -0
  53. package/extension/dist-web/assets/classDiagram-v2-4MYWR3UA-BL706wzc.js +217 -0
  54. package/extension/dist-web/assets/cose-bilkent-JH36ORCC-C6J2IoHg.js +1 -0
  55. package/extension/dist-web/assets/cynefin-EF2NZ3EQ-DLhQOiAy.js +1 -0
  56. package/extension/dist-web/assets/cynefinDiagram-WF24UDRP-Cv9Lx6_l.js +62 -0
  57. package/extension/dist-web/assets/cytoscape.esm-nTrd5EVq.js +321 -0
  58. package/extension/dist-web/assets/d3-scale-CElPUUud.js +1 -0
  59. package/extension/dist-web/assets/d3-selection-COWvaQNI.js +1 -0
  60. package/extension/dist-web/assets/dagre-NK4GIZVX-ngM-w2EC.js +4 -0
  61. package/extension/dist-web/assets/diagram-CBK3MWTC-kp8sayNG.js +24 -0
  62. package/extension/dist-web/assets/diagram-I5XIIV2D-BZ_Dgs6K.js +24 -0
  63. package/extension/dist-web/assets/diagram-ODIL2UCW-DWhUyArG.js +30 -0
  64. package/extension/dist-web/assets/diagram-PFBEJUXE-CBAdEK7l.js +3 -0
  65. package/extension/dist-web/assets/diagram-RJA3I4VV-kOdIr_3K.js +41 -0
  66. package/extension/dist-web/assets/diagram-TYUNFSNR-BrWGa0x5.js +200 -0
  67. package/extension/dist-web/assets/dist-DdXDFcej.js +1 -0
  68. package/extension/dist-web/assets/docx-preview-D1zbEiLy.js +20 -0
  69. package/extension/dist-web/assets/earth-Ce3xs8Cb.webp +0 -0
  70. package/extension/dist-web/assets/ebnfDiagram-V4P3TTPT-0r3weWmj.js +1 -0
  71. package/extension/dist-web/assets/elk-QONTBCTQ-D3oElRZ3.js +27 -0
  72. package/extension/dist-web/assets/erDiagram-KYQIGQAA-B9oU7_j_.js +99 -0
  73. package/extension/dist-web/assets/eventmodeling-K75KTNOO-CMKgc1nP.js +1 -0
  74. package/extension/dist-web/assets/favicon-D_X6tUVf.svg +5 -0
  75. package/extension/dist-web/assets/flowDiagram-IUGLLWBU-yRwks0Mw.js +1 -0
  76. package/extension/dist-web/assets/ganttDiagram-R7GPNTJY-cJqD1qwQ.js +292 -0
  77. package/extension/dist-web/assets/gitGraph-VSP46ZUC-CuBQqkbr.js +1 -0
  78. package/extension/dist-web/assets/gitGraphDiagram-PDYL7XHY-D7bHnQXC.js +106 -0
  79. package/extension/dist-web/assets/graphlib-DS17s2tU.js +1 -0
  80. package/extension/dist-web/assets/home-CV7-8Trs.js +1 -0
  81. package/extension/dist-web/assets/index-CQvw7Wy_.js +7 -0
  82. package/extension/dist-web/assets/index-CVKnZ21i.css +1 -0
  83. package/extension/dist-web/assets/info-OHQRW6UA-B8kyzV4O.js +1 -0
  84. package/extension/dist-web/assets/infoDiagram-MVDRKAX5-CEm6lezX.js +2 -0
  85. package/extension/dist-web/assets/ishikawaDiagram-HPEHV2GE-Ce3uv2wr.js +70 -0
  86. package/extension/dist-web/assets/journeyDiagram-BOSHW7O7-QgdahHCP.js +139 -0
  87. package/extension/dist-web/assets/jszip.min-3XXygzvy.js +2 -0
  88. package/extension/dist-web/assets/kanban-definition-FNSA4HC5-DPuTtWgR.js +89 -0
  89. package/extension/dist-web/assets/katex-MEuSR36T.js +257 -0
  90. package/extension/dist-web/assets/mermaid-parser.core-h7U7YGn_.js +7 -0
  91. package/extension/dist-web/assets/mermaid.core-DkGhophj.js +44 -0
  92. package/extension/dist-web/assets/mindmap-definition-6OY57UG3-D7VQxbda.js +98 -0
  93. package/extension/dist-web/assets/mount-CBzzf6KQ.js +195 -0
  94. package/extension/dist-web/assets/mount-DtvYnQXt.css +1 -0
  95. package/extension/dist-web/assets/officeparser.browser.slim-kEjhTrQ1.js +1989 -0
  96. package/extension/dist-web/assets/packet-JDAUHWVQ-oafHgw6X.js +1 -0
  97. package/extension/dist-web/assets/pegDiagram-ECIUJNBX-C3zo1naj.js +1 -0
  98. package/extension/dist-web/assets/peoria-B5TBlKDG.jpg +0 -0
  99. package/extension/dist-web/assets/peoria-thumb-CN8upAdZ.jpg +0 -0
  100. package/extension/dist-web/assets/pie-XZMESJXO-DXzeBQqF.js +1 -0
  101. package/extension/dist-web/assets/pieDiagram-GNMPY74T-S5NzPthl.js +39 -0
  102. package/extension/dist-web/assets/quadrantDiagram-D57K4MC3-C9glHQmk.js +7 -0
  103. package/extension/dist-web/assets/radar-ABXABTNO-CWTNqtbu.js +1 -0
  104. package/extension/dist-web/assets/railroad-I3PHUGI6-BTpD5_Bu.js +1 -0
  105. package/extension/dist-web/assets/railroad-abnf-LNEFI6M7-bWyxoXQG.js +1 -0
  106. package/extension/dist-web/assets/railroad-ebnf-DWYD2UWJ-ri5733DQ.js +1 -0
  107. package/extension/dist-web/assets/railroad-peg-JR7BVNR7-CmGfTubP.js +1 -0
  108. package/extension/dist-web/assets/railroadDiagram-Y72NRBL7-DTfe6Dh1.js +1 -0
  109. package/extension/dist-web/assets/requirementDiagram-EQYSW5RA-DQDzcS3L.js +84 -0
  110. package/extension/dist-web/assets/rolldown-runtime-COiEfhsA.js +1 -0
  111. package/extension/dist-web/assets/rough.esm-Dy-Kn_BL.js +1 -0
  112. package/extension/dist-web/assets/sankeyDiagram-SY24JHO5-DyMKWxdB.js +40 -0
  113. package/extension/dist-web/assets/sequenceDiagram-BLEHNHQU-dIkB1mCn.js +169 -0
  114. package/extension/dist-web/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  115. package/extension/dist-web/assets/stateDiagram-v2-A6IESKWZ-Bj_vxEVF.js +291 -0
  116. package/extension/dist-web/assets/swimlanes-B3ENRKFQ-BSkWEwHR.js +1 -0
  117. package/extension/dist-web/assets/swimlanesDiagram-AYQRV4AK-BTzSDlSM.js +8 -0
  118. package/extension/dist-web/assets/timeline-definition-JXYKGLGB-TwfWS0pw.js +120 -0
  119. package/extension/dist-web/assets/treeView-D4JQ5SDB-BzA_8YYb.js +1 -0
  120. package/extension/dist-web/assets/treemap-SAJKECNS-BI9d6--2.js +1 -0
  121. package/extension/dist-web/assets/usecaseDiagram-WPOLBNNX-BOVbAUPk.js +328 -0
  122. package/extension/dist-web/assets/vennDiagram-Q3Y3IDCW-X2kYAWaj.js +34 -0
  123. package/extension/dist-web/assets/wardley-7MLQ67FV-CItxqJ8G.js +1 -0
  124. package/extension/dist-web/assets/wardleyDiagram-IVAIDKWA-BnUXvKD_.js +78 -0
  125. package/extension/dist-web/assets/xychartDiagram-4URNHDU4-ysvBXvyE.js +7 -0
  126. package/extension/dist-web/icon-192.png +0 -0
  127. package/extension/dist-web/icon-512.png +0 -0
  128. package/extension/dist-web/index.html +25 -0
  129. package/extension/dist-web/manifest.webmanifest +14 -0
  130. package/package.json +64 -12
  131. package/plugin/.claude-plugin/icon.png +0 -0
  132. package/plugin/.claude-plugin/plugin.json +6 -0
  133. package/plugin/.mcp.json +8 -0
  134. package/plugin/README.md +72 -0
  135. package/plugin/mcp-launcher.mjs +48 -0
  136. package/src/account-probe.js +45 -0
  137. package/src/accounts.js +687 -0
  138. package/src/ai.js +269 -0
  139. package/src/assistant-runs.js +32 -0
  140. package/src/attached-mail.js +76 -0
  141. package/src/auth-gate.js +70 -0
  142. package/src/backup-cli.js +158 -0
  143. package/src/backup.js +329 -0
  144. package/src/bimi.js +233 -0
  145. package/src/bridge.js +101 -0
  146. package/src/calendar-alerts.js +56 -0
  147. package/src/chats.js +27 -0
  148. package/src/compose-editor.js +58 -0
  149. package/src/config.js +420 -0
  150. package/src/connections.d.ts +24 -0
  151. package/src/connections.js +37 -0
  152. package/src/core/agent.js +92 -0
  153. package/src/core/assistant.d.ts +13 -0
  154. package/src/core/assistant.js +790 -0
  155. package/src/core/chats.js +323 -0
  156. package/src/core/markdown.d.ts +8 -0
  157. package/src/core/markdown.js +239 -0
  158. package/src/core/notes.js +445 -0
  159. package/src/core/otp.js +152 -0
  160. package/src/core/rules.js +196 -0
  161. package/src/core/runs.d.ts +9 -0
  162. package/src/core/runs.js +211 -0
  163. package/src/core/thread.js +526 -0
  164. package/src/core/write.js +247 -0
  165. package/src/core-db.js +131 -0
  166. package/src/core.js +174 -0
  167. package/src/credentials.js +320 -0
  168. package/src/daemon.js +564 -0
  169. package/src/events.js +213 -0
  170. package/src/extension-id.d.ts +2 -0
  171. package/src/extension-id.js +5 -0
  172. package/src/file-lock.js +27 -0
  173. package/src/files-index.js +154 -0
  174. package/src/google-contacts.js +315 -0
  175. package/src/google-signin.js +306 -0
  176. package/src/host/assistant-html.js +44 -0
  177. package/src/host/chats-files.js +137 -0
  178. package/src/host/file-prep.js +122 -0
  179. package/src/host/notes-files.js +158 -0
  180. package/src/host/office-text.js +224 -0
  181. package/src/host/office-worker.js +8 -0
  182. package/src/host/rules-file.js +20 -0
  183. package/src/host/secrets-file.js +91 -0
  184. package/src/host/systemd.js +90 -0
  185. package/src/hub.js +245 -0
  186. package/src/identity.js +316 -0
  187. package/src/labels.js +5 -0
  188. package/src/mail-port.d.ts +79 -0
  189. package/src/mail-port.js +148 -0
  190. package/src/mcp-server.js +747 -0
  191. package/src/microsoft-app.js +20 -0
  192. package/src/microsoft-signin.js +194 -0
  193. package/src/migrate.js +327 -0
  194. package/src/notes-html.js +450 -0
  195. package/src/notes.js +19 -0
  196. package/src/notify.js +105 -0
  197. package/src/onepassword.js +223 -0
  198. package/src/op-registry.d.ts +14 -0
  199. package/src/op-registry.js +150 -0
  200. package/src/ops.js +1251 -0
  201. package/src/otp.js +6 -0
  202. package/src/panel-ops.js +273 -0
  203. package/src/pictures.js +735 -0
  204. package/src/postinstall.js +25 -0
  205. package/src/relay-passkey.js +122 -0
  206. package/src/relay-request.js +155 -0
  207. package/src/relay-seal.js +56 -0
  208. package/src/relay-settings.js +139 -0
  209. package/src/relay.js +876 -0
  210. package/src/render.js +82 -0
  211. package/src/rules-store.js +8 -0
  212. package/src/safe-fetch.js +215 -0
  213. package/src/sender-auth.js +270 -0
  214. package/src/site-match.js +77 -0
  215. package/src/tui-agenda.js +266 -0
  216. package/src/tui.js +670 -0
  217. package/src/vmc.js +376 -0
  218. package/src/wake.js +96 -0
  219. package/src/web-access.js +185 -0
  220. package/src/web-server.js +241 -0
  221. package/src/web-service.js +152 -0
@@ -0,0 +1,223 @@
1
+ // The 1Password CLI (`op`): secret references read with `op read`, items
2
+ // looked up (never revealed) with `op item get` / `op item list`.
3
+ //
4
+ // Two ways in: the desktop app's integration (the app asks for Touch ID when
5
+ // needed: Settings → Developer → Integrate with 1Password CLI), or a service
6
+ // account, whose token is handed to `op` in its environment
7
+ // (OP_SERVICE_ACCOUNT_TOKEN) for that one call: never in its arguments, never
8
+ // in a message. A secret read here is returned, never logged; what `op`
9
+ // says when it fails is turned into a reason of our own (OpError.code).
10
+ //
11
+ // A secret reference: op://<vault>/<item>[/<section>]/<field>. Kept by IDs
12
+ // (op://<vaultId>/<itemId>/password), it survives the item or the vault being
13
+ // renamed; one pasted with names (1Password's "Copy Secret Reference") is
14
+ // resolved to IDs once, when it is saved.
15
+
16
+ import { execFile } from 'node:child_process';
17
+ import fs from 'node:fs';
18
+ import path from 'node:path';
19
+
20
+ /** SIDEORA_OP_BIN: the one `op` to run (tests point it at a stand-in); otherwise PATH's, then Homebrew's. */
21
+ const candidates = () => (process.env.SIDEORA_OP_BIN ? [process.env.SIDEORA_OP_BIN] : ['op', '/opt/homebrew/bin/op', '/usr/local/bin/op']);
22
+ /**
23
+ * Whether the 1Password CLI is on this computer at all (found, as runOp would look for it; not run: running it may
24
+ * ask for Touch ID). Not there, a 1Password item is not offered as where a password comes from.
25
+ */
26
+ export function opInstalled() {
27
+ return candidates().some((c) => {
28
+ const where = c.includes('/') ? [c] : (process.env.PATH || '').split(path.delimiter).map((d) => path.join(d || '.', c));
29
+ return where.some((f) => { try { fs.accessSync(f, fs.constants.X_OK); return fs.statSync(f).isFile(); } catch { return false; } });
30
+ });
31
+ }
32
+ const TIMEOUT_MS = 120_000; // a Touch ID prompt waits for the person
33
+ /** A 1Password ID (vault, item): 26 lowercase letters and digits. */
34
+ export const OP_ID = /^[a-z0-9]{26}$/;
35
+
36
+ export class OpError extends Error {
37
+ constructor(code, message) { super(message); this.code = code; this.name = 'OpError'; }
38
+ }
39
+
40
+ // what to do about each reason, said once
41
+ export const OP_FIX = {
42
+ NOT_INSTALLED: 'install the 1Password CLI: brew install 1password-cli',
43
+ LOCKED: 'unlock 1Password (and allow the request when it asks)',
44
+ UNAVAILABLE: 'open and unlock 1Password; Settings → Developer → Integrate with 1Password CLI',
45
+ NOT_FOUND: 'the item, its vault or its field is gone or was moved: link the item again (sideora setup)',
46
+ NO_TOKEN: 'store the service account token: sideora op-token set',
47
+ TOKEN: 'the service account token was refused: store a valid one with sideora op-token set',
48
+ BAD_REF: 'a secret reference reads op://<vault>/<item>/<field>',
49
+ TIMEOUT: '1Password did not answer in time (a prompt left open?): try again',
50
+ ERROR: 'run: sideora doctor'
51
+ };
52
+
53
+ // what each reason is said as: op's own words are never repeated (they can quote what it was given)
54
+ export const OP_SAID = {
55
+ NOT_INSTALLED: 'the 1Password CLI (op) is not installed',
56
+ LOCKED: '1Password is locked, or the request was not allowed',
57
+ UNAVAILABLE: '1Password could not be reached',
58
+ NOT_FOUND: 'the item, its vault or its field was not found',
59
+ NO_TOKEN: 'no service account token is stored',
60
+ TOKEN: 'the service account token was refused',
61
+ BAD_REF: 'that is not a secret reference',
62
+ TIMEOUT: '1Password did not answer in time',
63
+ ERROR: 'op failed'
64
+ };
65
+ /** The reasons that mean 1Password is out of reach for now: a password kept from before may stand in meanwhile. */
66
+ export const OP_TRANSIENT = ['LOCKED', 'UNAVAILABLE', 'TIMEOUT', 'NOT_INSTALLED'];
67
+
68
+ /**
69
+ * Why op failed, from what it printed. What is quoted in it (an item's title,
70
+ * a reference) is taken out first: a title with "locked" in it says nothing.
71
+ * Not found is looked for before anything said in free text.
72
+ */
73
+ export function classify(stderr) {
74
+ const s = String(stderr || '').replace(/"[^"\n]*"|'[^'\n]*'|“[^”\n]*”/g, '""');
75
+ if (/isn'?t (an item|a vault|a field)|\bnot found\b|\bno item\b|could(?: not|n'?t) find|does not exist|no such|more than one item/i.test(s)) return 'NOT_FOUND';
76
+ if (/parsing secret reference|invalid secret reference|not a valid secret reference/i.test(s)) return 'BAD_REF';
77
+ if (/OP_SERVICE_ACCOUNT_TOKEN|service account|invalid token|token is invalid|DecodeSACredentials|unauthori[sz]ed|\b401\b/i.test(s)) return 'TOKEN';
78
+ if (/authoriz\w*(?: prompt)? (?:was )?(?:dismissed|denied|timeout|timed out)|\bapp is locked\b|\b1Password is locked\b|\bvault is locked\b/i.test(s)) return 'LOCKED';
79
+ if (/desktop app|not currently signed in|no accounts? (configured|found)|couldn'?t connect|cannot connect|could not connect|connection (reset|refused)|integrat/i.test(s)) return 'UNAVAILABLE';
80
+ return 'ERROR';
81
+ }
82
+
83
+ /** An error of a reason, in fixed words. */
84
+ export const opError = (code) => new OpError(code, `${OP_SAID[code] || OP_SAID.ERROR} — ${OP_FIX[code] || OP_FIX.ERROR}`);
85
+
86
+ /**
87
+ * Run op with these arguments. `token`: a service account's (its environment,
88
+ * this call only); without one, the desktop app's integration is used, and a
89
+ * token set in this process's environment is not passed on. Resolves to stdout.
90
+ */
91
+ export function runOp(args, { token = null, timeout = TIMEOUT_MS } = {}) {
92
+ const env = { ...process.env };
93
+ delete env.OP_SERVICE_ACCOUNT_TOKEN;
94
+ if (token) env.OP_SERVICE_ACCOUNT_TOKEN = token;
95
+ const bins = candidates();
96
+ return new Promise((resolve, reject) => {
97
+ const tryBin = (i) => {
98
+ if (i >= bins.length) return reject(opError('NOT_INSTALLED'));
99
+ // stdin closed at once: op reads item specifiers from a piped stdin, and must never wait on one
100
+ const child = execFile(bins[i], args, { env, timeout, maxBuffer: 16 * 1024 * 1024, encoding: 'utf8' }, (err, stdout, stderr) => {
101
+ if (!err) return resolve(stdout);
102
+ if (err.code === 'ENOENT') return tryBin(i + 1);
103
+ if (err.killed || err.signal) return reject(opError('TIMEOUT'));
104
+ reject(opError(classify(stderr)));
105
+ });
106
+ child.stdin?.on('error', () => {}).end();
107
+ };
108
+ tryBin(0);
109
+ });
110
+ }
111
+
112
+ const badRef = () => opError('BAD_REF');
113
+
114
+ /** op://vault/item[/section]/field[?query] → its parts; throws (BAD_REF) when it is not one. */
115
+ export function parseRef(ref) {
116
+ const m = /^op:\/\/([^?]+)(?:\?(.*))?$/.exec(String(ref ?? '').trim());
117
+ if (!m) throw badRef(ref);
118
+ const parts = m[1].split('/');
119
+ if (parts.length < 3 || parts.length > 4 || parts.some((p) => !p.trim() || /[\x00-\x1f]/.test(p))) throw badRef(ref);
120
+ const [vault, item, ...rest] = parts;
121
+ return { vault, item, section: rest.length === 2 ? rest[0] : null, field: rest[rest.length - 1], query: m[2] ?? null };
122
+ }
123
+
124
+ export const formatRef = ({ vault, item, section = null, field, query = null }) => `op://${vault}/${item}/${section ? `${section}/` : ''}${field}${query ? `?${query}` : ''}`;
125
+
126
+ /** A reference whose vault and item are IDs: what is stored. */
127
+ export const isIdRef = (ref) => { try { const r = parseRef(ref); return OP_ID.test(r.vault) && OP_ID.test(r.item); } catch { return false; } };
128
+
129
+ /** The secret a reference names. Never logged; a trailing newline of op's is not part of it. */
130
+ export async function opRead(ref, { token = null } = {}) {
131
+ parseRef(ref);
132
+ const out = await runOp(['read', '--no-newline', ref], { token });
133
+ return out.replace(/\r?\n$/, '');
134
+ }
135
+
136
+ /** What is kept of an item: no field values, only whether a field holds one. */
137
+ function summary(it) {
138
+ return {
139
+ id: String(it?.id || ''),
140
+ title: String(it?.title || ''),
141
+ category: String(it?.category || '').toUpperCase(),
142
+ vault: { id: String(it?.vault?.id || ''), name: String(it?.vault?.name || '') },
143
+ urls: (Array.isArray(it?.urls) ? it.urls : []).map((u) => String(u?.href || '')).filter(Boolean),
144
+ ...(Array.isArray(it?.fields) ? {
145
+ fields: it.fields.map((f) => ({ id: String(f?.id || ''), label: String(f?.label || ''), purpose: String(f?.purpose || ''), section: f?.section?.id || null, filled: typeof f?.value === 'string' && f.value !== '' }))
146
+ } : {})
147
+ };
148
+ }
149
+
150
+ const unreadable = () => new OpError('ERROR', '1Password: its answer could not be read');
151
+
152
+ /**
153
+ * One item by its IDs, revealed, as one snapshot: what it is (as getItem) and
154
+ * the value of its password field. For linking: the websites checked and the
155
+ * password used are the same item's at the same moment. The value is never logged.
156
+ */
157
+ export async function getItemRevealed(itemId, vaultId) {
158
+ const out = await runOp(['item', 'get', String(itemId), '--vault', String(vaultId), '--reveal', '--format', 'json']);
159
+ let it;
160
+ try { it = JSON.parse(out); } catch { throw unreadable(); }
161
+ const fields = Array.isArray(it?.fields) ? it.fields : [];
162
+ const pw = fields.find((f) => (f?.id === 'password' || f?.purpose === 'PASSWORD' || String(f?.label || '').toLowerCase() === 'password') && !f?.section)
163
+ || fields.find((f) => f?.id === 'password' || f?.purpose === 'PASSWORD' || String(f?.label || '').toLowerCase() === 'password');
164
+ // another field's value of the same snapshot (a username reference's), by its ID or label
165
+ const value = (name) => { const f = fields.find((x) => x?.id === name || String(x?.label || '').toLowerCase() === String(name).toLowerCase()); return typeof f?.value === 'string' ? f.value : ''; };
166
+ return { item: summary(it), password: typeof pw?.value === 'string' ? pw.value : '', value };
167
+ }
168
+
169
+ /** One item, by ID or title (in a vault, by ID or name): its IDs, title, vault, websites and fields, no secret. */
170
+ export async function getItem(item, { vault = null, token = null } = {}) {
171
+ const args = ['item', 'get', String(item), '--format', 'json'];
172
+ if (vault) args.push('--vault', String(vault));
173
+ const out = await runOp(args, { token });
174
+ try { return summary(JSON.parse(out)); } catch { throw unreadable(); }
175
+ }
176
+
177
+ /** The Login and Password items (no field, no secret): IDs, title, vault, websites. */
178
+ export async function listItems({ token = null, categories = ['Login', 'Password'] } = {}) {
179
+ const out = await runOp(['item', 'list', '--categories', categories.join(','), '--format', 'json'], { token });
180
+ let list;
181
+ try { list = JSON.parse(out || '[]'); } catch { throw unreadable(); }
182
+ return (Array.isArray(list) ? list : []).map((it) => { const { fields: _f, ...rest } = summary(it); return rest; });
183
+ }
184
+
185
+ /** Whether an item (looked up with its fields) has a field of this name or ID. */
186
+ export const hasField = (item, name) => !item.fields || item.fields.some((f) => fieldIs(f, name));
187
+ const fieldIs = (f, name) => f.id === name || f.label.toLowerCase() === name.toLowerCase() || f.purpose === name.toUpperCase();
188
+ /** The name of a field in a reference: its ID when it is a plain one, else its label. */
189
+ const fieldName = (f) => (/^[\w-]+$/.test(f.id) ? f.id : f.label);
190
+
191
+ /**
192
+ * The references of an item's password (and, `username: true`, of its
193
+ * username when it holds one), by IDs. Throws NOT_FOUND when it has no password.
194
+ */
195
+ export function itemRefs(item, { username = true } = {}) {
196
+ const fields = item.fields || [];
197
+ const pw = fields.find((f) => fieldIs(f, 'password') && !f.section) || fields.find((f) => fieldIs(f, 'password'));
198
+ if (!pw) throw new OpError('NOT_FOUND', `the 1Password item "${item.title}" has no password field`);
199
+ const user = username ? fields.find((f) => fieldIs(f, 'username') && f.filled) : null;
200
+ const ref = (f) => formatRef({ vault: item.vault.id, item: item.id, section: f.section && /^[\w-]+$/.test(f.section) ? f.section : null, field: fieldName(f) });
201
+ return { password: ref(pw), ...(user ? { username: ref(user) } : {}) };
202
+ }
203
+
204
+ /**
205
+ * A reference as typed or pasted (names or IDs), checked against 1Password
206
+ * (the item is looked up, never revealed): the same reference by IDs, and the
207
+ * item it names. { ref, item }
208
+ */
209
+ export async function resolveRef(ref, { token = null } = {}) {
210
+ const r = parseRef(ref);
211
+ const it = await getItem(r.item, { vault: r.vault, token });
212
+ if (!it.id || !it.vault.id) throw new OpError('NOT_FOUND', `1Password did not say which item "${r.item}" is`);
213
+ if (!hasField(it, r.field)) throw new OpError('NOT_FOUND', `the 1Password item "${it.title}" has no field "${r.field}"`);
214
+ return { ref: formatRef({ ...r, vault: it.vault.id, item: it.id }), item: it };
215
+ }
216
+
217
+ /** What to show for a linked item: { item, vault } (a reference by names says them; by IDs, nothing more is known). */
218
+ export function refLabel(ref) {
219
+ try {
220
+ const r = parseRef(ref);
221
+ return { item: OP_ID.test(r.item) ? '' : r.item, vault: OP_ID.test(r.vault) ? '' : r.vault };
222
+ } catch { return { item: '', vault: '' }; }
223
+ }
@@ -0,0 +1,14 @@
1
+ // The op registry's types, for the extension's TypeScript (src/op-registry.js is plain JavaScript, shared with the daemon's side).
2
+ export interface OpEntry { panel: boolean; web: 'yes' | 'admin' | 'no'; relay: 'yes' | 'full' | 'no'; touch?: 'fresh' | 'each' }
3
+ export const OP_REGISTRY: Record<string, OpEntry>;
4
+ export const PANEL_OPS: Set<string>;
5
+ export const WEB_OPS: Set<string>;
6
+ export const ADMIN_OPS: Set<string>;
7
+ export const NOT_ON_WEB: Set<string>;
8
+ export const WEB_ONLY: Set<string>;
9
+ export const RELAY_OPS: Set<string>;
10
+ export const FULL_OPS: Set<string>;
11
+ export const NOT_FROM_AFAR: Set<string>;
12
+ export const AT_THE_MAC: Set<string>;
13
+ export const TOUCH_OPS: Set<string>;
14
+ export const EACH_OPS: Set<string>;
@@ -0,0 +1,150 @@
1
+ // Every op of the panel, named once, with where it may be asked from and what asking it takes. The lists the bridge,
2
+ // the web app's server and the relay keep (and the extension's worker) are read from here: an op is added in one
3
+ // place, and an op missing here is served nowhere (test/op-registry.test.js fails until each op of src/panel-ops.js
4
+ // has its entry).
5
+ //
6
+ // panel the extension's side panel may ask it, through the bridge (src/bridge.js, extension/src/background.ts).
7
+ // The AI ops are the hub's alone (HUB_ONLY, src/hub.js): the daemon holds what they keep (src/ai.js).
8
+ // web the web app's server (src/web-server.js): 'yes' served to a paired browser; 'admin' unless the server
9
+ // was started with --no-admin (what changes this Mac's accounts and where their passwords come from: a page in
10
+ // a browser is not kept apart as an extension is); 'no' never ('hello' and 'subscribe' are the bridge's own).
11
+ // relay a device far away, through the relay (src/relay.js): 'yes' any paired device; 'full' only a device given
12
+ // full access at the Mac (rules, a sound played at the Mac, the accounts; a rule may run a command here, so
13
+ // one is not switched on, moved or removed from afar otherwise); 'no' never (Google answers the Mac's own
14
+ // browser, at an address of the Mac's: a sign-in begun from afar would end nowhere). Never more than the
15
+ // web app itself serves.
16
+ // touch with a passkey: 'fresh' a touch no older than TOUCH_MS (what reaches other people now, or goes out
17
+ // later under the owner's name: a mail sent, an invitation answered, a signature, a contact added to
18
+ // Google); 'each' a touch made for that very asking, good once (what changes this Mac's rules and
19
+ // accounts). An op given only by full access takes a fresh touch besides (src/relay.js).
20
+
21
+ /** @type {Record<string, { panel: boolean, web: 'yes' | 'admin' | 'no', relay: 'yes' | 'full' | 'no', touch?: 'fresh' | 'each' }>} */
22
+ export const OP_REGISTRY = {
23
+ hello: { panel: false, web: 'no', relay: 'no' },
24
+ subscribe: { panel: false, web: 'no', relay: 'no' }, // (the bridge's own: its event stream, not an op of src/panel-ops.js)
25
+ accounts: { panel: true, web: 'yes', relay: 'yes' },
26
+ list: { panel: true, web: 'yes', relay: 'yes' },
27
+ search: { panel: true, web: 'yes', relay: 'yes' },
28
+ read: { panel: true, web: 'yes', relay: 'yes' },
29
+ thread: { panel: true, web: 'yes', relay: 'yes' },
30
+ attachment: { panel: true, web: 'yes', relay: 'yes' },
31
+ attachedMail: { panel: true, web: 'yes', relay: 'yes' },
32
+ attachmentAt: { panel: true, web: 'yes', relay: 'yes' },
33
+ whoami: { panel: true, web: 'yes', relay: 'yes' },
34
+ contacts: { panel: true, web: 'yes', relay: 'yes' },
35
+ contactBooks: { panel: true, web: 'yes', relay: 'yes' },
36
+ addContact: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
37
+ files: { panel: true, web: 'yes', relay: 'yes' },
38
+ events: { panel: true, web: 'yes', relay: 'yes' },
39
+ event: { panel: true, web: 'yes', relay: 'yes' },
40
+ respondToEvent: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
41
+ saveEvent: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
42
+ deleteEvent: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
43
+ markRead: { panel: true, web: 'yes', relay: 'yes' },
44
+ flag: { panel: true, web: 'yes', relay: 'yes' },
45
+ move: { panel: true, web: 'yes', relay: 'yes' },
46
+ saveDraft: { panel: true, web: 'yes', relay: 'yes' },
47
+ draft: { panel: true, web: 'yes', relay: 'yes' },
48
+ addAttachment: { panel: true, web: 'yes', relay: 'yes' },
49
+ removeAttachment: { panel: true, web: 'yes', relay: 'yes' },
50
+ sendDraft: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
51
+ deleteDraft: { panel: true, web: 'yes', relay: 'yes' },
52
+ rules: { panel: true, web: 'yes', relay: 'yes' },
53
+ saveRule: { panel: true, web: 'yes', relay: 'full', touch: 'each' },
54
+ removeRule: { panel: true, web: 'yes', relay: 'full', touch: 'each' },
55
+ moveRule: { panel: true, web: 'yes', relay: 'full', touch: 'each' },
56
+ setQuietHours: { panel: true, web: 'yes', relay: 'yes' },
57
+ playSound: { panel: true, web: 'yes', relay: 'full' },
58
+ myDay: { panel: true, web: 'yes', relay: 'yes' },
59
+ people: { panel: true, web: 'yes', relay: 'yes' },
60
+ person: { panel: true, web: 'yes', relay: 'yes' },
61
+ accountSettings: { panel: true, web: 'yes', relay: 'yes' },
62
+ testAccount: { panel: true, web: 'admin', relay: 'full' },
63
+ addAccount: { panel: true, web: 'admin', relay: 'full', touch: 'each' },
64
+ editAccount: { panel: true, web: 'admin', relay: 'full', touch: 'each' },
65
+ onePasswordItems: { panel: true, web: 'admin', relay: 'full' },
66
+ removeAccount: { panel: true, web: 'admin', relay: 'full', touch: 'each' },
67
+ setDefaultAccount: { panel: true, web: 'admin', relay: 'full', touch: 'each' },
68
+ googleSignInStart: { panel: true, web: 'admin', relay: 'no' },
69
+ googleSignInStatus: { panel: true, web: 'admin', relay: 'full' },
70
+ googleSignInCancel: { panel: true, web: 'admin', relay: 'full' },
71
+ // a Microsoft 365 or Outlook.com mailbox, signed in at the computer Sideora runs on (Microsoft answers its own browser)
72
+ microsoftSignInStart: { panel: true, web: 'admin', relay: 'full', touch: 'each' }, // (from afar, Microsoft answers at the relay)
73
+ microsoftSignInStatus: { panel: true, web: 'admin', relay: 'full' },
74
+ microsoftSignInCancel: { panel: true, web: 'admin', relay: 'full' },
75
+ // the relay, from Settings on this computer (src/relay-settings.js): never from afar (a device could join this
76
+ // computer elsewhere, or make links that pair more devices)
77
+ relaySettings: { panel: true, web: 'admin', relay: 'no' },
78
+ relayJoin: { panel: true, web: 'admin', relay: 'no' },
79
+ relayPairLink: { panel: true, web: 'admin', relay: 'no' },
80
+ relayPairStatus: { panel: true, web: 'admin', relay: 'no' },
81
+ relayPairCancel: { panel: true, web: 'admin', relay: 'no' },
82
+ relayForget: { panel: true, web: 'admin', relay: 'no' },
83
+ relayAdmin: { panel: true, web: 'admin', relay: 'no' },
84
+ relayMove: { panel: true, web: 'admin', relay: 'no' },
85
+ relayLeave: { panel: true, web: 'admin', relay: 'no' },
86
+ relayRequest: { panel: true, web: 'admin', relay: 'no' },
87
+ relayRequestConfirm: { panel: true, web: 'admin', relay: 'no' },
88
+ relayRequestResend: { panel: true, web: 'admin', relay: 'no' },
89
+ relayRequestCheck: { panel: true, web: 'admin', relay: 'no' },
90
+ relayRequestCancel: { panel: true, web: 'admin', relay: 'no' },
91
+ signatures: { panel: true, web: 'yes', relay: 'yes' },
92
+ saveSignature: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
93
+ removeSignature: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
94
+ setSignatureDetails: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
95
+ setIdentity: { panel: true, web: 'yes', relay: 'yes', touch: 'fresh' },
96
+ senderPictures: { panel: true, web: 'yes', relay: 'yes' },
97
+ pictureSettings: { panel: true, web: 'yes', relay: 'yes' },
98
+ setPictureSettings: { panel: true, web: 'yes', relay: 'yes' },
99
+ calendarView: { panel: true, web: 'yes', relay: 'yes' },
100
+ setCalendarView: { panel: true, web: 'yes', relay: 'yes' },
101
+ notes: { panel: true, web: 'yes', relay: 'yes' },
102
+ note: { panel: true, web: 'yes', relay: 'yes' },
103
+ saveNote: { panel: true, web: 'yes', relay: 'yes' },
104
+ addToNote: { panel: true, web: 'yes', relay: 'yes' },
105
+ tickNote: { panel: true, web: 'yes', relay: 'yes' },
106
+ unlinkNote: { panel: true, web: 'yes', relay: 'yes' },
107
+ noteChanges: { panel: true, web: 'yes', relay: 'yes' },
108
+ removeNote: { panel: true, web: 'yes', relay: 'yes' },
109
+ restoreNote: { panel: true, web: 'yes', relay: 'yes' },
110
+ addNotePicture: { panel: true, web: 'yes', relay: 'yes' },
111
+ notePicture: { panel: true, web: 'yes', relay: 'yes' },
112
+ fetchNotePicture: { panel: true, web: 'yes', relay: 'yes' },
113
+ chats: { panel: true, web: 'yes', relay: 'yes' },
114
+ chat: { panel: true, web: 'yes', relay: 'yes' },
115
+ saveChat: { panel: true, web: 'yes', relay: 'yes' },
116
+ removeChat: { panel: true, web: 'yes', relay: 'yes' },
117
+ addChatFile: { panel: true, web: 'yes', relay: 'yes' },
118
+ chatFile: { panel: true, web: 'yes', relay: 'yes' },
119
+ aiMessage: { panel: true, web: 'yes', relay: 'yes' },
120
+ aiChat: { panel: true, web: 'yes', relay: 'yes' },
121
+ webEntry: { panel: true, web: 'no', relay: 'no' },
122
+ assistantStart: { panel: true, web: 'yes', relay: 'yes' },
123
+ assistantWait: { panel: true, web: 'yes', relay: 'yes' },
124
+ assistantAnswer: { panel: true, web: 'yes', relay: 'yes' },
125
+ assistantStop: { panel: true, web: 'yes', relay: 'yes' },
126
+ };
127
+
128
+ for (const entry of Object.values(OP_REGISTRY)) Object.freeze(entry);
129
+ Object.freeze(OP_REGISTRY);
130
+
131
+ const named = (test) => new Set(Object.keys(OP_REGISTRY).filter((op) => test(OP_REGISTRY[op])));
132
+
133
+ /** What the extension's side panel may ask, through the bridge. */
134
+ export const PANEL_OPS = named((o) => o.panel);
135
+ /** What a paired browser is served by the web app's server; what a --no-admin server does not serve; what it never does. */
136
+ export const WEB_OPS = named((o) => o.web === 'yes');
137
+ export const ADMIN_OPS = named((o) => o.web === 'admin');
138
+ export const NOT_ON_WEB = named((o) => o.web === 'no');
139
+ /** The web app's alone: served on the web, not by the bridge. */
140
+ export const WEB_ONLY = named((o) => o.web === 'yes' && !o.panel);
141
+ /** What any paired device may ask through the relay; what only a device given full access may. */
142
+ export const RELAY_OPS = named((o) => o.relay === 'yes');
143
+ export const FULL_OPS = named((o) => o.relay === 'full');
144
+ /** The web app's, but never from afar to a device without full access (a sound at the Mac; changing the rules). */
145
+ export const NOT_FROM_AFAR = named((o) => o.web === 'yes' && o.relay === 'full');
146
+ /** The web app's accounts (not a --no-admin server's), never from afar at all. */
147
+ export const AT_THE_MAC = named((o) => o.web === 'admin' && o.relay === 'no');
148
+ /** With a passkey: a touch no older than TOUCH_MS; a touch for that very asking. */
149
+ export const TOUCH_OPS = named((o) => o.touch === 'fresh');
150
+ export const EACH_OPS = named((o) => o.touch === 'each');