@speechos/core 0.2.7 → 0.2.9
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/dist/config.d.cts +11 -0
- package/dist/config.d.ts +11 -0
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +18 -2
- package/dist/types.d.ts +18 -2
- package/package.json +1 -1
package/dist/config.d.cts
CHANGED
|
@@ -16,6 +16,8 @@ interface ResolvedConfig {
|
|
|
16
16
|
debug: boolean;
|
|
17
17
|
/** Custom WebSocket factory (undefined means use native WebSocket) */
|
|
18
18
|
webSocketFactory: WebSocketFactory | undefined;
|
|
19
|
+
/** JWT token for server-side settings persistence (undefined means no sync) */
|
|
20
|
+
settingsToken: string | undefined;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Validates and merges user config with defaults
|
|
@@ -41,6 +43,15 @@ export declare function resetConfig(): void;
|
|
|
41
43
|
* @param userId - The user identifier to set
|
|
42
44
|
*/
|
|
43
45
|
export declare function updateUserId(userId: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the settings token from the current configuration
|
|
48
|
+
* @returns The settings token or undefined if not configured
|
|
49
|
+
*/
|
|
50
|
+
export declare function getSettingsToken(): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Clear the settings token (e.g., when it expires)
|
|
53
|
+
*/
|
|
54
|
+
export declare function clearSettingsToken(): void;
|
|
44
55
|
/**
|
|
45
56
|
* Get or generate a persistent anonymous ID for Mixpanel tracking.
|
|
46
57
|
*
|
package/dist/config.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ interface ResolvedConfig {
|
|
|
16
16
|
debug: boolean;
|
|
17
17
|
/** Custom WebSocket factory (undefined means use native WebSocket) */
|
|
18
18
|
webSocketFactory: WebSocketFactory | undefined;
|
|
19
|
+
/** JWT token for server-side settings persistence (undefined means no sync) */
|
|
20
|
+
settingsToken: string | undefined;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Validates and merges user config with defaults
|
|
@@ -41,6 +43,15 @@ export declare function resetConfig(): void;
|
|
|
41
43
|
* @param userId - The user identifier to set
|
|
42
44
|
*/
|
|
43
45
|
export declare function updateUserId(userId: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the settings token from the current configuration
|
|
48
|
+
* @returns The settings token or undefined if not configured
|
|
49
|
+
*/
|
|
50
|
+
export declare function getSettingsToken(): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Clear the settings token (e.g., when it expires)
|
|
53
|
+
*/
|
|
54
|
+
export declare function clearSettingsToken(): void;
|
|
44
55
|
/**
|
|
45
56
|
* Get or generate a persistent anonymous ID for Mixpanel tracking.
|
|
46
57
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,8 @@ const defaultConfig = {
|
|
|
36
36
|
userId: "",
|
|
37
37
|
host: DEFAULT_HOST,
|
|
38
38
|
debug: false,
|
|
39
|
-
webSocketFactory: void 0
|
|
39
|
+
webSocketFactory: void 0,
|
|
40
|
+
settingsToken: void 0
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
42
43
|
* Validates and merges user config with defaults
|
|
@@ -44,13 +45,14 @@ const defaultConfig = {
|
|
|
44
45
|
* @returns Validated and merged configuration
|
|
45
46
|
*/
|
|
46
47
|
function validateConfig(userConfig) {
|
|
47
|
-
if (!userConfig.apiKey) throw new Error("SpeechOS requires an apiKey. Get one from your team dashboard at /a
|
|
48
|
+
if (!userConfig.apiKey) throw new Error("SpeechOS requires an apiKey. Get one from your team dashboard at /a/.");
|
|
48
49
|
return {
|
|
49
50
|
apiKey: userConfig.apiKey,
|
|
50
51
|
userId: userConfig.userId ?? defaultConfig.userId,
|
|
51
52
|
host: userConfig.host ?? defaultConfig.host,
|
|
52
53
|
debug: userConfig.debug ?? defaultConfig.debug,
|
|
53
|
-
webSocketFactory: userConfig.webSocketFactory ?? defaultConfig.webSocketFactory
|
|
54
|
+
webSocketFactory: userConfig.webSocketFactory ?? defaultConfig.webSocketFactory,
|
|
55
|
+
settingsToken: userConfig.settingsToken ?? defaultConfig.settingsToken
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
@@ -87,6 +89,22 @@ function updateUserId(userId) {
|
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
92
|
+
* Get the settings token from the current configuration
|
|
93
|
+
* @returns The settings token or undefined if not configured
|
|
94
|
+
*/
|
|
95
|
+
function getSettingsToken() {
|
|
96
|
+
return currentConfig.settingsToken;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Clear the settings token (e.g., when it expires)
|
|
100
|
+
*/
|
|
101
|
+
function clearSettingsToken() {
|
|
102
|
+
currentConfig = {
|
|
103
|
+
...currentConfig,
|
|
104
|
+
settingsToken: void 0
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
90
108
|
* LocalStorage key for anonymous ID persistence
|
|
91
109
|
*/
|
|
92
110
|
const ANONYMOUS_ID_KEY = "speechos_anonymous_id";
|
|
@@ -2270,10 +2288,12 @@ exports.DEFAULT_HOST = DEFAULT_HOST;
|
|
|
2270
2288
|
exports.Deferred = Deferred;
|
|
2271
2289
|
exports.SpeechOSEventEmitter = SpeechOSEventEmitter;
|
|
2272
2290
|
exports.VERSION = VERSION;
|
|
2291
|
+
exports.clearSettingsToken = clearSettingsToken;
|
|
2273
2292
|
exports.createStateManager = createStateManager;
|
|
2274
2293
|
exports.events = events;
|
|
2275
2294
|
exports.getBackend = getBackend;
|
|
2276
2295
|
exports.getConfig = getConfig;
|
|
2296
|
+
exports.getSettingsToken = getSettingsToken;
|
|
2277
2297
|
exports.livekit = livekit;
|
|
2278
2298
|
exports.resetConfig = resetConfig;
|
|
2279
2299
|
exports.setConfig = setConfig;
|