@soffits/dsh-card-board 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - Add `ownerPerson`: with a people mapping, requests DSH lets in with its own login (launch link or API token) rather than through the sign-in plugin count as that person instead of seeing nothing. Without an identity provider the routes still answer 503.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  - First release: boards of `stat`, `line`, `bar`, `donut`, `list`, `timeline` and `status` cards read from a data folder, with per-person access through any `requestIdentity` provider (or everything for a single-person DSH), ETag polling while the page is visible, stale and error cards, light and dark, and phone widths.
package/README.md CHANGED
@@ -32,6 +32,7 @@ Override the row in your profile's `cordis.patch.yml`:
32
32
  | `people` | `{}` | Verified user id → person id, for a DSH several people sign in to. |
33
33
  | `peopleFile` | | A JSON file with more of that mapping, re-read when it changes. `people` wins on a clash. |
34
34
  | `peopleKey` | | The key in `peopleFile` that holds the mapping; empty means the whole file. |
35
+ | `ownerPerson` | | With a mapping, the person id for requests DSH lets in with its own login (its launch link or an API token) rather than through the sign-in plugin. Empty (the default): they see no boards. See the note below before setting it. |
35
36
  | `pollSeconds` | `30` | How often an open, visible page checks for changes. A hidden tab doesn't poll. |
36
37
  | `actionLog` | `<dataDir>/.actions.jsonl` | Where action presses are appended. |
37
38
  | `actionTimeoutSeconds` | `300` | A press nobody handles within this time shows as not handled. |
@@ -40,7 +41,9 @@ Override the row in your profile's `cordis.patch.yml`:
40
41
 
41
42
  With no `people` and no `peopleFile`, the plugin assumes a single-person DSH: everyone DSH lets in sees every board.
42
43
 
43
- With a mapping, each request is checked on the server. The plugin asks the `requestIdentity` service who made the request, maps that user id to a person id, and serves only boards whose `viewers` list that person. A request without a verified identity sees no boards; a board the person may not see answers 403, the same as one that doesn't exist. The tabs in the page come only from the server's list. Person ids compare without regard to case.
44
+ With a mapping, each request is checked on the server. The plugin asks the `requestIdentity` service who made the request, maps that user id to a person id, and serves only boards whose `viewers` list that person. A request without a verified identity sees no boards (or `ownerPerson`'s, if you set it); a board the person may not see answers 403, the same as one that doesn't exist. The tabs in the page come only from the server's list. Person ids compare without regard to case.
45
+
46
+ `ownerPerson` maps every request DSH admits without a sign-in identity to that one person. That's only safe when every outside path to DSH goes through the sign-in gate (a forward-auth proxy or a gateway) and the only way around it is local, such as DSH's own port on a private network. Give that person their own boards rather than adding them to everyone's.
44
47
 
45
48
  `requestIdentity` is a small service any sign-in plugin can provide. [dsh-oidc](https://github.com/soffits/dsh-oidc) (0.3.0-alpha.9 or later) does; another plugin can provide the same interface:
46
49
 
package/index.js CHANGED
@@ -31,6 +31,8 @@ export const Config = z.object({
31
31
  .description('A JSON file with more of the same mapping, re-read when it changes. Entries in people win.'),
32
32
  peopleKey: z.string().default('')
33
33
  .description('The top-level key in peopleFile that holds the mapping. Empty means the whole file is the mapping.'),
34
+ ownerPerson: z.string().default('')
35
+ .description('With a mapping: the person id for requests DSH lets in with its own login (launch link or API token) rather than through the sign-in plugin. Empty means such requests see no boards.'),
34
36
  pollSeconds: z.natural().min(5).max(3600).default(30)
35
37
  .description('How often an open, visible page checks for changes.'),
36
38
  actionLog: z.string().default('')
@@ -41,7 +43,7 @@ export const Config = z.object({
41
43
 
42
44
  /**
43
45
  * @param {import('@deepseek-ai/cordis').Context} ctx
44
- * @param {{ dataDir: string, people: Record<string, string>, peopleFile: string, peopleKey: string, pollSeconds: number }} config
46
+ * @param {{ dataDir: string, people: Record<string, string>, peopleFile: string, peopleKey: string, ownerPerson: string, pollSeconds: number, actionLog: string, actionTimeoutSeconds: number }} config
45
47
  */
46
48
  export function apply(ctx, config) {
47
49
  const logger = ctx.logger('card-board')
@@ -69,6 +71,7 @@ export function apply(ctx, config) {
69
71
  identity: () => ctx.get('requestIdentity'),
70
72
  pollSeconds: config.pollSeconds ?? 30,
71
73
  presses,
74
+ ownerPerson: config.ownerPerson ?? '',
72
75
  version,
73
76
  })
74
77
  for (const route of routes) ctx.connection.fetch.register(route)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A data-driven card board for DeepSeek Harness: scripts write small JSON cards, the Web UI shows each person the boards they may see.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/access.js CHANGED
@@ -76,12 +76,18 @@ export function createPeople({ people = {}, peopleFile = '', peopleKey = '' }, {
76
76
  * `{ mode: 'people', person }` (person may be undefined: sees nothing) or
77
77
  * `{ mode: 'people', unavailable: true }` when a mapping is configured but no
78
78
  * identity provider is installed.
79
+ *
80
+ * `ownerPerson` names the person behind a request the provider can't name:
81
+ * one DSH let in with its own login (its launch link or API token) rather
82
+ * than through the sign-in plugin. Without a provider at all nobody can be
83
+ * told apart, so that stays unavailable.
79
84
  */
80
- export async function viewerOf(people, identityService) {
85
+ export async function viewerOf(people, identityService, ownerPerson = '') {
81
86
  if (!people.enabled) return { mode: 'owner' }
82
87
  if (identityService === undefined || typeof identityService?.current !== 'function') return { mode: 'people', unavailable: true }
83
88
  const identity = identityService.current()
84
- return { mode: 'people', person: await people.personFor(identity?.id) }
89
+ if (identity === null || identity === undefined) return { mode: 'people', person: ownerPerson ? personKey(ownerPerson) : undefined }
90
+ return { mode: 'people', person: await people.personFor(identity.id) }
85
91
  }
86
92
 
87
93
  /** Whether a viewer may see a board (its board.json already validated). */
package/src/routes.js CHANGED
@@ -36,11 +36,12 @@ const NO_PROVIDER = 'This board needs a sign-in plugin that provides requestIden
36
36
  * @param {() => object | undefined} options.identity - the requestIdentity service right now, if any
37
37
  * @param {number} options.pollSeconds
38
38
  * @param {ReturnType<import('./presses.js').createPresses>} options.presses
39
+ * @param {string} [options.ownerPerson] - the person for requests DSH admits without a sign-in identity
39
40
  * @param {string} [options.version] - mixed into ETags, so a plugin update refreshes open pages
40
41
  */
41
- export function createRoutes({ dataDir, people, identity, pollSeconds, presses, version = '' }) {
42
+ export function createRoutes({ dataDir, people, identity, pollSeconds, presses, ownerPerson = '', version = '' }) {
42
43
  async function boards() {
43
- const viewer = await viewerOf(people, identity())
44
+ const viewer = await viewerOf(people, identity(), ownerPerson)
44
45
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
45
46
  const root = await resolveDataDir(dataDir)
46
47
  const visible = root === undefined ? [] : (await listBoards(root)).filter(entry => viewer.mode === 'owner' || maySee(viewer, entry.board))
@@ -54,7 +55,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
54
55
  async function board(request) {
55
56
  const id = new URL(request.url).searchParams.get('id') ?? ''
56
57
  if (!ID_PATTERN.test(id)) return json(400, { error: 'Not a board id.' })
57
- const viewer = await viewerOf(people, identity())
58
+ const viewer = await viewerOf(people, identity(), ownerPerson)
58
59
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
59
60
  const root = await resolveDataDir(dataDir)
60
61
  const entry = root === undefined ? undefined : await readBoard(root, id)
@@ -92,7 +93,7 @@ export function createRoutes({ dataDir, people, identity, pollSeconds, presses,
92
93
  if (row !== undefined && !(Number.isInteger(row) && row >= 0)) return json(400, { error: 'row must be a row index.' })
93
94
  if (until !== undefined && (typeof until !== 'string' || !DATE_TIME.test(until) || Number.isNaN(Date.parse(until))))
94
95
  return json(400, { error: 'until must be an ISO date-time with a zone.' })
95
- const viewer = await viewerOf(people, identity())
96
+ const viewer = await viewerOf(people, identity(), ownerPerson)
96
97
  if (viewer.unavailable) return json(503, { error: NO_PROVIDER })
97
98
  const root = await resolveDataDir(dataDir)
98
99
  const entry = root === undefined ? undefined : await readBoard(root, board)