oblien 1.0.6 → 1.0.7
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 +1 -1
- package/src/chat/index.js +3 -0
- package/src/chat/session.js +9 -0
- package/src/utils/guest-manager.js +3 -3
package/package.json
CHANGED
package/src/chat/index.js
CHANGED
package/src/chat/session.js
CHANGED
|
@@ -13,6 +13,9 @@ export class ChatSession {
|
|
|
13
13
|
* @param {boolean} [options.isGuest] - Is this a guest session
|
|
14
14
|
* @param {string} [options.namespace] - Guest namespace for rate limiting
|
|
15
15
|
* @param {Object} [options.workspace] - Workspace configuration
|
|
16
|
+
* @param {string} [options.ipAddress] - IP address of the user
|
|
17
|
+
* @param {string} [options.userAgent] - User agent of the user
|
|
18
|
+
* @param {string} [options.fingerprint] - Fingerprint of the user
|
|
16
19
|
*/
|
|
17
20
|
constructor(options) {
|
|
18
21
|
if (!options.client) {
|
|
@@ -32,6 +35,9 @@ export class ChatSession {
|
|
|
32
35
|
this.workspace = options.workspace;
|
|
33
36
|
this.token = null;
|
|
34
37
|
this.data = null;
|
|
38
|
+
this.ipAddress = options.ipAddress || null;
|
|
39
|
+
this.userAgent = options.userAgent || null;
|
|
40
|
+
this.fingerprint = options.fingerprint || null;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
/**
|
|
@@ -45,6 +51,9 @@ export class ChatSession {
|
|
|
45
51
|
is_guest: this.isGuest,
|
|
46
52
|
namespace: this.namespace,
|
|
47
53
|
workspace: this.workspace,
|
|
54
|
+
ip_address: this.ipAddress,
|
|
55
|
+
user_agent: this.userAgent,
|
|
56
|
+
fingerprint: this.fingerprint,
|
|
48
57
|
};
|
|
49
58
|
|
|
50
59
|
this.data = await this.client.post('ai/session/create', payload);
|
|
@@ -129,10 +129,10 @@ export class GuestManager {
|
|
|
129
129
|
const guestIdByIp = await this.storage.get(`ip:${ip}`);
|
|
130
130
|
if (guestIdByIp) {
|
|
131
131
|
const guest = await this.getGuest(guestIdByIp);
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
if (guest) {
|
|
133
|
+
guest.lastSeen = new Date().toISOString();
|
|
134
134
|
await this.storage.set(`guest:${guest.id}`, guest, this.ttl);
|
|
135
|
-
|
|
135
|
+
return guest;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|