@oxvo/ai-live-assist 7.4.24 → 7.4.37
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/cjs/AiLiveAssist.d.ts +26 -2
- package/cjs/AiLiveAssist.js +645 -142
- package/cjs/avatarUrl.d.ts +2 -0
- package/cjs/avatarUrl.js +64 -0
- package/cjs/client.d.ts +1 -1
- package/cjs/client.js +14 -1
- package/cjs/index.js +2 -2
- package/cjs/locales/index.d.ts +10 -0
- package/cjs/locales/index.js +49 -0
- package/cjs/locales/resources.d.ts +3 -0
- package/cjs/locales/resources.js +4807 -0
- package/cjs/locales/supported.d.ts +2 -0
- package/cjs/locales/supported.js +47 -0
- package/cjs/media.d.ts +6 -3
- package/cjs/media.js +60 -45
- package/cjs/messages.js +9 -4
- package/cjs/preview.d.ts +4 -3
- package/cjs/preview.js +76 -20
- package/cjs/types.d.ts +13 -1
- package/cjs/types.js +121 -0
- package/cjs/ui.d.ts +40 -0
- package/cjs/ui.js +1067 -275
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/cjs/voicePresenceUi.d.ts +2 -1
- package/cjs/voicePresenceUi.js +115 -96
- package/lib/AiLiveAssist.d.ts +26 -2
- package/lib/AiLiveAssist.js +643 -141
- package/lib/avatarUrl.d.ts +2 -0
- package/lib/avatarUrl.js +60 -0
- package/lib/client.d.ts +1 -1
- package/lib/client.js +14 -1
- package/lib/index.js +2 -2
- package/lib/locales/index.d.ts +10 -0
- package/lib/locales/index.js +42 -0
- package/lib/locales/resources.d.ts +3 -0
- package/lib/locales/resources.js +4804 -0
- package/lib/locales/supported.d.ts +2 -0
- package/lib/locales/supported.js +44 -0
- package/lib/media.d.ts +6 -3
- package/lib/media.js +60 -45
- package/lib/messages.js +9 -4
- package/lib/preview.d.ts +4 -3
- package/lib/preview.js +76 -20
- package/lib/types.d.ts +13 -1
- package/lib/types.js +120 -1
- package/lib/ui.d.ts +40 -0
- package/lib/ui.js +1067 -275
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/voicePresenceUi.d.ts +2 -1
- package/lib/voicePresenceUi.js +116 -97
- package/package.json +5 -3
package/cjs/avatarUrl.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAvatarUrl = exports.MAX_AVATAR_URL_LENGTH = void 0;
|
|
4
|
+
exports.MAX_AVATAR_URL_LENGTH = 2048;
|
|
5
|
+
const LOOPBACK_HTTP_HOSTS = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
6
|
+
const containsControlCharacters = (value) => Array.from(value).some((character) => {
|
|
7
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
8
|
+
return codePoint <= 31 || (codePoint >= 127 && codePoint <= 159);
|
|
9
|
+
});
|
|
10
|
+
const hasExactLoopbackHttpAuthority = (value) => {
|
|
11
|
+
const authority = /^http:\/\/([^/?#]*)/iu.exec(value)?.[1];
|
|
12
|
+
if (!authority || authority.includes("@"))
|
|
13
|
+
return false;
|
|
14
|
+
if (authority.startsWith("[")) {
|
|
15
|
+
const closingBracket = authority.indexOf("]");
|
|
16
|
+
if (closingBracket < 0)
|
|
17
|
+
return false;
|
|
18
|
+
const hostname = authority.slice(1, closingBracket).toLocaleLowerCase("en");
|
|
19
|
+
const port = authority.slice(closingBracket + 1);
|
|
20
|
+
return hostname === "::1" && (port === "" || /^:\d{1,5}$/u.test(port));
|
|
21
|
+
}
|
|
22
|
+
const separator = authority.indexOf(":");
|
|
23
|
+
const hostname = (separator < 0 ? authority : authority.slice(0, separator)).toLocaleLowerCase("en");
|
|
24
|
+
const port = separator < 0 ? "" : authority.slice(separator);
|
|
25
|
+
return (LOOPBACK_HTTP_HOSTS.has(hostname) &&
|
|
26
|
+
hostname !== "::1" &&
|
|
27
|
+
(port === "" || /^:\d{1,5}$/u.test(port)));
|
|
28
|
+
};
|
|
29
|
+
const normalizeAvatarUrl = (value, requiredHttpOrigin) => {
|
|
30
|
+
if (typeof value !== "string" ||
|
|
31
|
+
value.length > exports.MAX_AVATAR_URL_LENGTH ||
|
|
32
|
+
containsControlCharacters(value)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const normalized = value.trim();
|
|
36
|
+
if (!normalized)
|
|
37
|
+
return null;
|
|
38
|
+
try {
|
|
39
|
+
const url = new URL(normalized);
|
|
40
|
+
if (!url.hostname ||
|
|
41
|
+
url.username ||
|
|
42
|
+
url.password ||
|
|
43
|
+
url.hash ||
|
|
44
|
+
(url.protocol !== "https:" && url.protocol !== "http:")) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (url.protocol === "https:")
|
|
48
|
+
return url.href;
|
|
49
|
+
if (!hasExactLoopbackHttpAuthority(normalized))
|
|
50
|
+
return null;
|
|
51
|
+
if (requiredHttpOrigin !== undefined) {
|
|
52
|
+
if (!requiredHttpOrigin)
|
|
53
|
+
return null;
|
|
54
|
+
const expectedOrigin = new URL(requiredHttpOrigin).origin;
|
|
55
|
+
if (url.origin !== expectedOrigin)
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return url.href;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.normalizeAvatarUrl = normalizeAvatarUrl;
|
package/cjs/client.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare class RuntimeClient {
|
|
|
86
86
|
private readonly clientVersion;
|
|
87
87
|
readonly baseUrl: string;
|
|
88
88
|
constructor(runtimeUrl: string, clientVersion: string);
|
|
89
|
-
bootstrap(siteKey: string, path: string, anonymousId: string, signal: AbortSignal): Promise<BootstrapConfig>;
|
|
89
|
+
bootstrap(siteKey: string, path: string, anonymousId: string, locale: string, signal: AbortSignal): Promise<BootstrapConfig>;
|
|
90
90
|
launch(input: LaunchInput, signal: AbortSignal): Promise<LaunchResult>;
|
|
91
91
|
resume(sessionId: string, credential: string, path: string, protocolVersion: 1 | 2, signal: AbortSignal): Promise<LaunchResult>;
|
|
92
92
|
resumePendingHandoff(sessionId: string, credential: string, path: string, protocolVersion: 1 | 2, messengerBindingChallengeId: string, signal: AbortSignal): Promise<HandoffRecoveryResult>;
|
package/cjs/client.js
CHANGED
|
@@ -14,7 +14,19 @@ class RuntimeClientError extends Error {
|
|
|
14
14
|
exports.RuntimeClientError = RuntimeClientError;
|
|
15
15
|
const MAX_SIGNED_INT64 = "9223372036854775807";
|
|
16
16
|
const CONTROL_OPERATION_ID_PATTERN = /^[A-Za-z0-9_.:-]{8,128}$/;
|
|
17
|
+
const MAX_LOCALE_TAG_LENGTH = 64;
|
|
17
18
|
exports.MAX_ASSIST_SESSION_GRANT_LENGTH = 4096;
|
|
19
|
+
const boundedLocale = (value) => {
|
|
20
|
+
const normalized = value.trim().replace(/_/g, "-");
|
|
21
|
+
if (!normalized || normalized.length > MAX_LOCALE_TAG_LENGTH)
|
|
22
|
+
return "en";
|
|
23
|
+
try {
|
|
24
|
+
return Intl.getCanonicalLocales(normalized)[0] ?? "en";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "en";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
18
30
|
const isValidReplaySessionId = (value) => {
|
|
19
31
|
if (typeof value !== "string" || !/^[1-9]\d{0,18}$/.test(value)) {
|
|
20
32
|
return false;
|
|
@@ -54,10 +66,11 @@ class RuntimeClient {
|
|
|
54
66
|
}
|
|
55
67
|
this.baseUrl = url.origin + url.pathname.replace(/\/$/, "");
|
|
56
68
|
}
|
|
57
|
-
async bootstrap(siteKey, path, anonymousId, signal) {
|
|
69
|
+
async bootstrap(siteKey, path, anonymousId, locale, signal) {
|
|
58
70
|
const url = new URL(`${this.baseUrl}/ai-live-assist/v1/public/bootstrap`);
|
|
59
71
|
url.searchParams.set("siteKey", siteKey);
|
|
60
72
|
url.searchParams.set("path", path);
|
|
73
|
+
url.searchParams.set("locale", boundedLocale(locale));
|
|
61
74
|
const response = await fetch(url, {
|
|
62
75
|
method: "GET",
|
|
63
76
|
mode: "cors",
|
package/cjs/index.js
CHANGED
|
@@ -18,8 +18,8 @@ function aiLiveAssist(options = {}) {
|
|
|
18
18
|
if (document.querySelector('[data-oxvo-ai-live-assist-root]')) {
|
|
19
19
|
return undefined;
|
|
20
20
|
}
|
|
21
|
-
if (!app.checkRequiredVersion?.('7.4.
|
|
22
|
-
console.warn('OXVO AI Guide requires @oxvo/browser version 7.4.
|
|
21
|
+
if (!app.checkRequiredVersion?.('7.4.37')) {
|
|
22
|
+
console.warn('OXVO AI Guide requires @oxvo/browser version 7.4.37 or newer.');
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
25
25
|
const instance = new AiLiveAssist_js_1.default(app, options);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WidgetMessageKey } from "../types.js";
|
|
2
|
+
import { type SupportedWidgetLocale } from "./supported.js";
|
|
3
|
+
export declare const resolveSupportedWidgetLocale: (value: unknown) => SupportedWidgetLocale;
|
|
4
|
+
export declare const widgetLocaleAttributes: (value: unknown) => {
|
|
5
|
+
lang: string;
|
|
6
|
+
dir: "ltr" | "rtl";
|
|
7
|
+
};
|
|
8
|
+
export declare const resolveWidgetMessages: (overrides?: Partial<Record<WidgetMessageKey, string>>, localizedMessages?: Partial<Record<WidgetMessageKey, string>>) => Record<WidgetMessageKey, string>;
|
|
9
|
+
export { SUPPORTED_WIDGET_LOCALES } from "./supported.js";
|
|
10
|
+
export type { SupportedWidgetLocale } from "./supported.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_WIDGET_LOCALES = exports.resolveWidgetMessages = exports.widgetLocaleAttributes = exports.resolveSupportedWidgetLocale = void 0;
|
|
4
|
+
const messages_js_1 = require("../messages.js");
|
|
5
|
+
const supported_js_1 = require("./supported.js");
|
|
6
|
+
const MAX_LOCALE_TAG_LENGTH = 64;
|
|
7
|
+
const supportedLocaleSet = new Set(supported_js_1.SUPPORTED_WIDGET_LOCALES);
|
|
8
|
+
const RTL_WIDGET_LANGUAGES = new Set(["ar", "fa", "he", "ur"]);
|
|
9
|
+
const canonicalLocale = (value) => {
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
return null;
|
|
12
|
+
const normalized = value.trim().replace(/_/g, "-");
|
|
13
|
+
if (!normalized || normalized.length > MAX_LOCALE_TAG_LENGTH)
|
|
14
|
+
return null;
|
|
15
|
+
try {
|
|
16
|
+
return Intl.getCanonicalLocales(normalized)[0] ?? null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const isSupportedLocale = (value) => supportedLocaleSet.has(value);
|
|
23
|
+
const resolveSupportedWidgetLocale = (value) => {
|
|
24
|
+
const canonical = canonicalLocale(value);
|
|
25
|
+
if (!canonical)
|
|
26
|
+
return "en";
|
|
27
|
+
if (isSupportedLocale(canonical))
|
|
28
|
+
return canonical;
|
|
29
|
+
const language = canonical.split("-")[0] ?? "";
|
|
30
|
+
return isSupportedLocale(language) ? language : "en";
|
|
31
|
+
};
|
|
32
|
+
exports.resolveSupportedWidgetLocale = resolveSupportedWidgetLocale;
|
|
33
|
+
const widgetLocaleAttributes = (value) => {
|
|
34
|
+
const lang = canonicalLocale(value) ?? "en";
|
|
35
|
+
const language = lang.split("-")[0] ?? "en";
|
|
36
|
+
return {
|
|
37
|
+
lang,
|
|
38
|
+
dir: RTL_WIDGET_LANGUAGES.has(language) ? "rtl" : "ltr",
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.widgetLocaleAttributes = widgetLocaleAttributes;
|
|
42
|
+
const resolveWidgetMessages = (overrides = {}, localizedMessages = {}) => ({
|
|
43
|
+
...messages_js_1.defaultMessages,
|
|
44
|
+
...localizedMessages,
|
|
45
|
+
...overrides,
|
|
46
|
+
});
|
|
47
|
+
exports.resolveWidgetMessages = resolveWidgetMessages;
|
|
48
|
+
var supported_js_2 = require("./supported.js");
|
|
49
|
+
Object.defineProperty(exports, "SUPPORTED_WIDGET_LOCALES", { enumerable: true, get: function () { return supported_js_2.SUPPORTED_WIDGET_LOCALES; } });
|