@restregular/dsh-memory 0.3.0 → 0.4.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.
@@ -1,57 +1,57 @@
1
- /**
2
- * Secret denylist for memory content (design §11): refuse or redact anything
3
- * that looks like a credential before it reaches the store or the embedder.
4
- * Patterns are deliberately conservative — better a false refusal on an
5
- * obvious token shape than a silent key leak into a plaintext JSONL file.
6
- */
1
+ /**
2
+ * Secret denylist for memory content (design §11): refuse or redact anything
3
+ * that looks like a credential before it reaches the store or the embedder.
4
+ * Patterns are deliberately conservative — better a false refusal on an
5
+ * obvious token shape than a silent key leak into a plaintext JSONL file.
6
+ */
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ const RULES = [
20
+ { kind: 'private-key', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g },
21
+ { kind: 'api-key-sk', re: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
22
+ { kind: 'github-token', re: /\bgh[pousr]_[A-Za-z0-9]{20,}\b/g },
23
+ { kind: 'aws-access-key', re: /\bAKIA[0-9A-Z]{16}\b/g },
24
+ { kind: 'slack-token', re: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g },
25
+ { kind: 'bearer-token', re: /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/g },
26
+ {
27
+ kind: 'key-assignment',
28
+ re: /\b(api[_-]?key|secret|token|password|passwd|pwd)\b\s*[:=]\s*['"]?[^\s'"]{8,}/gi,
29
+ },
30
+ ]
31
+
32
+ /** Find credential-shaped spans in free text. */
33
+ export function scanSecrets(text ) {
34
+ const found = []
35
+ for (const { kind, re } of RULES) {
36
+ re.lastIndex = 0
37
+ let m
38
+ while ((m = re.exec(text)) !== null) {
39
+ found.push({ kind, index: m.index, length: m[0].length })
40
+ if (m.index === re.lastIndex) re.lastIndex++ // guard zero-length loops
41
+ }
42
+ }
43
+ return found
44
+ }
45
+
46
+ /** Mask every matched span as [REDACTED:<kind>]; length changes are expected. */
47
+ export function redactSecrets(text ) {
48
+ let out = text
49
+ for (const { kind, re } of RULES) {
50
+ re.lastIndex = 0
51
+ out = out.replace(re, `[REDACTED:${kind}]`)
52
+ }
53
+ return out
54
+ }
7
55
 
8
-
9
-
10
-
11
-
12
-
13
56
 
14
-
15
-
16
-
17
-
18
-
19
- const RULES = [
20
- { kind: 'private-key', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g },
21
- { kind: 'api-key-sk', re: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
22
- { kind: 'github-token', re: /\bgh[pousr]_[A-Za-z0-9]{20,}\b/g },
23
- { kind: 'aws-access-key', re: /\bAKIA[0-9A-Z]{16}\b/g },
24
- { kind: 'slack-token', re: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g },
25
- { kind: 'bearer-token', re: /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/g },
26
- {
27
- kind: 'key-assignment',
28
- re: /\b(api[_-]?key|secret|token|password|passwd|pwd)\b\s*[:=]\s*['"]?[^\s'"]{8,}/gi,
29
- },
30
- ]
31
-
32
- /** Find credential-shaped spans in free text. */
33
- export function scanSecrets(text ) {
34
- const found = []
35
- for (const { kind, re } of RULES) {
36
- re.lastIndex = 0
37
- let m
38
- while ((m = re.exec(text)) !== null) {
39
- found.push({ kind, index: m.index, length: m[0].length })
40
- if (m.index === re.lastIndex) re.lastIndex++ // guard zero-length loops
41
- }
42
- }
43
- return found
44
- }
45
-
46
- /** Mask every matched span as [REDACTED:<kind>]; length changes are expected. */
47
- export function redactSecrets(text ) {
48
- let out = text
49
- for (const { kind, re } of RULES) {
50
- re.lastIndex = 0
51
- out = out.replace(re, `[REDACTED:${kind}]`)
52
- }
53
- return out
54
- }
55
-
56
-
57
- //# sourceURL=D:\.deepseek\memory-plugin\packages\memory-local\src\secrets.ts
57
+ //# sourceURL=source/memory-local/src/secrets.ts