@yeaft/webchat-agent 0.1.901 → 0.1.902

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.901",
3
+ "version": "0.1.902",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -78,9 +78,10 @@ export class AmsRegistry {
78
78
  /**
79
79
  * Resolve the on-disk path for a group's ams.json.
80
80
  *
81
- * `sessionId` is trusted: `nextSessionId()` (groups/ids.js) emits ids matching
82
- * `grp_[a-z0-9_-]+`, and the single-VP path uses the literal
83
- * `DEFAULT_GROUP_KEY`. No defensive escaping is needed.
81
+ * `sessionId` is trusted: `nextSessionId()` (sessions/ids.js) emits ids matching
82
+ * `grp_[a-z0-9_-]+_[0-9A-HJKMNP-TV-Z]{8}` (slug + 8-char crockford suffix),
83
+ * and the single-VP path uses the literal `DEFAULT_GROUP_KEY`. No defensive
84
+ * escaping is needed.
84
85
  *
85
86
  * @param {string} sessionId
86
87
  * @returns {string}
@@ -38,9 +38,15 @@ export function nextMsgId() {
38
38
  }
39
39
 
40
40
  export function nextSessionId(slug = 'default') {
41
- // Slug-tolerant: lowercase a-z0-9_- only.
42
- const safe = String(slug).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').slice(0, 32) || 'group';
43
- return `grp_${safe}`;
41
+ // Slug-tolerant: lowercase a-z0-9_- only, capped at 24 chars so the
42
+ // total id stays compact after the suffix is appended.
43
+ const safe = String(slug).toLowerCase().replace(/[^a-z0-9_-]+/g, '-').slice(0, 24) || 'group';
44
+ // Append 8 crockford-base32 chars (~40 bits) so re-creating a session
45
+ // with the same display name yields a fresh id instead of throwing
46
+ // `duplicate` on the existsSync check in session-crud.js. The
47
+ // `duplicate` branch is now a true defensive guard rather than the
48
+ // first-collision footgun it used to be.
49
+ return `grp_${safe}_${randEncoded(8)}`;
44
50
  }
45
51
 
46
52
  /**