@karmaniverous/jeeves-server 3.1.1 → 3.1.3

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.
@@ -27,13 +27,22 @@ import type {
27
27
  */
28
28
  export function normalizeScopes(raw: unknown): NormalizedScopes | null {
29
29
  if (raw === undefined || raw === null) return null;
30
- if (typeof raw === 'string') return { allow: [raw], deny: [] };
31
- if (Array.isArray(raw)) return { allow: raw as string[], deny: [] };
30
+ if (typeof raw === 'string')
31
+ return { allow: [raw], deny: [], explicitAllow: [], explicitDeny: [] };
32
+ if (Array.isArray(raw))
33
+ return {
34
+ allow: raw as string[],
35
+ deny: [],
36
+ explicitAllow: [],
37
+ explicitDeny: [],
38
+ };
32
39
  if (typeof raw === 'object') {
33
40
  const obj = raw as { allow?: string[]; deny?: string[] };
34
41
  return {
35
42
  allow: obj.allow ?? ['/**'],
36
43
  deny: obj.deny ?? [],
44
+ explicitAllow: [],
45
+ explicitDeny: [],
37
46
  };
38
47
  }
39
48
  return null;
@@ -56,6 +65,8 @@ export function resolveNamedScopes(
56
65
  return {
57
66
  allow: overrides.allow ?? ['/**'],
58
67
  deny: overrides.deny ?? [],
68
+ explicitAllow: overrides.allow ?? [],
69
+ explicitDeny: overrides.deny ?? [],
59
70
  };
60
71
  }
61
72
  return null;
@@ -91,6 +102,8 @@ export function resolveNamedScopes(
91
102
  return {
92
103
  allow: allow.length > 0 ? allow : ['/**'],
93
104
  deny,
105
+ explicitAllow: overrides?.allow ?? [],
106
+ explicitDeny: overrides?.deny ?? [],
94
107
  };
95
108
  }
96
109
 
@@ -99,6 +112,8 @@ export function resolveNamedScopes(
99
112
  if (!normalized) return null;
100
113
  if (overrides?.allow) normalized.allow.push(...overrides.allow);
101
114
  if (overrides?.deny) normalized.deny.push(...overrides.deny);
115
+ normalized.explicitAllow = overrides?.allow ?? [];
116
+ normalized.explicitDeny = overrides?.deny ?? [];
102
117
  return normalized;
103
118
  }
104
119
 
@@ -11,10 +11,19 @@ export type { AuthMode, JeevesConfig };
11
11
  /**
12
12
  * Normalized scopes — always resolved to \{ allow, deny \} form.
13
13
  * null = unrestricted access.
14
+ *
15
+ * Explicit overrides take precedence over named scope patterns:
16
+ * 1. If explicitDeny matches → DENIED (overrides named allow)
17
+ * 2. If explicitAllow matches → ALLOWED (overrides named deny)
18
+ * 3. Otherwise: normal allow AND NOT deny evaluation
14
19
  */
15
20
  export interface NormalizedScopes {
16
21
  allow: string[];
17
22
  deny: string[];
23
+ /** Explicit allow patterns from the insider/key entry — override named scope denies. */
24
+ explicitAllow: string[];
25
+ /** Explicit deny patterns from the insider/key entry — override named scope allows. */
26
+ explicitDeny: string[];
18
27
  }
19
28
 
20
29
  /**
@@ -4,6 +4,7 @@
4
4
 
5
5
  import fs from 'node:fs';
6
6
 
7
+ import type { Token } from 'marked';
7
8
  import { marked } from 'marked';
8
9
 
9
10
  import { registerDiagram } from './embeddedDiagrams.js';
@@ -105,12 +106,25 @@ export function parseMarkdown(
105
106
  const renderer = new marked.Renderer();
106
107
 
107
108
  renderer.heading = function (
108
- args: string | { text: string; raw?: string; depth: number },
109
+ args:
110
+ | string
111
+ | {
112
+ text: string;
113
+ raw?: string;
114
+ depth: number;
115
+ tokens?: Token[];
116
+ },
109
117
  ) {
110
118
  const text = typeof args === 'object' ? args.text : args;
111
119
  const raw = typeof args === 'object' && args.raw ? args.raw : text;
112
120
  const level = typeof args === 'object' ? args.depth : 1;
113
121
 
122
+ // Parse inline tokens to render code spans, bold, italic, links, etc.
123
+ const renderedText =
124
+ typeof args === 'object' && args.tokens
125
+ ? this.parser.parseInline(args.tokens)
126
+ : text;
127
+
114
128
  const slug = raw
115
129
  .toLowerCase()
116
130
  .replace(/<[^>]+>/g, '')
@@ -119,9 +133,13 @@ export function parseMarkdown(
119
133
  .replace(/-+/g, '-')
120
134
  .replace(/^-|-$/g, '');
121
135
 
122
- headings.push({ level, text: text.replace(/<[^>]+>/g, ''), slug });
136
+ headings.push({
137
+ level,
138
+ text: renderedText.replace(/<[^>]+>/g, ''),
139
+ slug,
140
+ });
123
141
 
124
- return `<h${String(level)} id="${slug}">${text} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
142
+ return `<h${String(level)} id="${slug}">${renderedText} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
125
143
  };
126
144
 
127
145
  // Rewrite relative image src to /path/ URLs