@upscopeio/sdk 2026.6.15 → 2026.6.16

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/index.js CHANGED
@@ -1,96 +1,13 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
- }
9
- function _iterableToArray(iter) {
10
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
- }
12
- function _nonIterableSpread() {
13
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
- }
15
- function _toConsumableArray(arr) {
16
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
- }
18
- function _unsupportedIterableToArray(o, minLen) {
19
- if (!o) return;
20
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
- var n = Object.prototype.toString.call(o).slice(8, -1);
22
- if (n === "Object" && o.constructor) n = o.constructor.name;
23
- if (n === "Map" || n === "Set") return Array.from(n);
24
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
- }
26
- var pendingInstructionsMap = new WeakMap();
27
- var environment = window.__upscope__sdk__load__environment;
1
+ import { createStub, createUpscope, injectAccountScript } from "./sdk-core.js";
2
+ // Default/dynamic entrypoint (@upscopeio/sdk): the account script downloads the latest hosted
3
+ // SDK implementation from js.upscope.io, so the running version always tracks production.
28
4
  function loadSDK(w, apiKey) {
29
5
  if (typeof w.Upscope !== "undefined") return;
30
- var i = function i1() {
31
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
32
- args[_key] = arguments[_key];
33
- }
34
- i.q.push(args);
35
- };
36
- i.q = [];
37
- // The real Upscope implementation is loaded below
38
- w.Upscope = i;
39
- var s = w.document.createElement("script");
40
- s.type = "text/javascript";
41
- s.async = true;
42
- var _;
43
- s.src = (_ = ({
44
- development: "http://code.upscope.local/".concat(apiKey, ".js"),
45
- production: "https://code.upscope.io/".concat(apiKey, ".js"),
46
- staging: "https://code.upscope.xyz/".concat(apiKey, ".js")
47
- })[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://code.upscope.io/".concat(apiKey, ".js");
48
- w.document.head.appendChild(s);
6
+ createStub(w);
7
+ injectAccountScript(w, apiKey);
49
8
  }
50
- // "Loaded" is keyed off window.Upscope existing. Upscope("shutdown") deletes it,
51
- // so the next "init" reloads the account script for whatever apiKey is passed.
52
- var ScopedUpscope = function ScopedUpscope(w) {
53
- for(var _len = arguments.length, instruction = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
54
- instruction[_key - 1] = arguments[_key];
55
- }
56
- var _w;
57
- if (typeof w.Upscope === "undefined") {
58
- if (instruction[0] === "init") {
59
- var config = instruction[1];
60
- if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
61
- loadSDK(w, config.apiKey);
62
- var pendingInstructions = pendingInstructionsMap.get(w);
63
- if (pendingInstructions) {
64
- pendingInstructionsMap.delete(w);
65
- pendingInstructions.forEach(function(instruction) {
66
- var _w;
67
- (_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
68
- });
69
- }
70
- } else if (instruction[0] === "on") {
71
- var _pendingInstructionsMap_get;
72
- pendingInstructionsMap.set(w, _toConsumableArray((_pendingInstructionsMap_get = pendingInstructionsMap.get(w)) !== null && _pendingInstructionsMap_get !== void 0 ? _pendingInstructionsMap_get : []).concat([
73
- instruction
74
- ]));
75
- return;
76
- } else {
77
- throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
78
- }
79
- }
80
- (_w = w).Upscope.apply(_w, _toConsumableArray(instruction));
81
- };
82
- export var upscopeFor = function upscopeFor(w) {
83
- return function() {
84
- for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
85
- instruction[_key] = arguments[_key];
86
- }
87
- ScopedUpscope.apply(void 0, [
88
- w
89
- ].concat(_toConsumableArray(instruction)));
90
- };
91
- };
92
- var _Upscope = upscopeFor(window);
93
- export default _Upscope;
9
+ export var upscopeFor = createUpscope(loadSDK);
10
+ export default upscopeFor(window);
94
11
 
95
12
 
96
13
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,yBAAyB,IAAI;AACnC,IAAM,cAAc,OAAO,iCAAiC;AAC5D,SAAS,QAAQ,CAAC,EAAE,MAAM,EAAE;IACxB,IAAI,OAAO,EAAE,OAAO,KAAK,aACrB;IACJ,IAAM,IAAI,SAAJ,KAAuB;QAAT,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,OAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;YAAG,KAAH,QAAA,SAAA,CAAA,KAAO;QAAD;QACtB,EAAE,CAAC,CAAC,IAAI,CAAC;IACb;IACA,EAAE,CAAC,GAAG,EAAE;IACR,kDAAkD;IAClD,EAAE,OAAO,GAAG;IACZ,IAAM,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC;IACnC,EAAE,IAAI,GAAG;IACT,EAAE,KAAK,GAAG,IAAI;QAEV;IADJ,EAAE,GAAG,GACD,CAAA,IAAA,CAAA;QACI,aAAa,AAAC,6BAAmC,OAAP,QAAO;QACjD,YAAY,AAAC,2BAAiC,OAAP,QAAO;QAC9C,SAAS,AAAC,4BAAkC,OAAP,QAAO;IAChD,CAAA,CAAC,CAAC,wBAAA,yBAAA,cAAe,YAAY,CAAC,cAJ9B,eAAA,IAIkC,AAAC,2BAAiC,O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AkB,CAAhC,OAAiB,mBAAG;IACxB;AACJ,EAAE;AACF,IAAM,WAAW,WAAW;AAC5B,eAAe,SAAS","file":"index.js","sourcesContent":["const pendingInstructionsMap = new WeakMap();\nconst environment = window.__upscope__sdk__load__environment;\nfunction loadSDK(w, apiKey) {\n if (typeof w.Upscope !== \"undefined\")\n return;\n const i = function (...args) {\n i.q.push(args);\n };\n i.q = [];\n // The real Upscope implementation is loaded below\n w.Upscope = i;\n const s = w.document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src =\n {\n development: `http://code.upscope.local/${apiKey}.js`,\n production: `https://code.upscope.io/${apiKey}.js`,\n staging: `https://code.upscope.xyz/${apiKey}.js`,\n }[environment ?? \"production\"] ?? `https://code.upscope.io/${apiKey}.js`;\n w.document.head.appendChild(s);\n}\n// \"Loaded\" is keyed off window.Upscope existing. Upscope(\"shutdown\") deletes it,\n// so the next \"init\" reloads the account script for whatever apiKey is passed.\nconst ScopedUpscope = function (w, ...instruction) {\n if (typeof w.Upscope === \"undefined\") {\n if (instruction[0] === \"init\") {\n const config = instruction[1];\n if (!config?.apiKey)\n throw new Error(\"API key not specified\");\n loadSDK(w, config.apiKey);\n const pendingInstructions = pendingInstructionsMap.get(w);\n if (pendingInstructions) {\n pendingInstructionsMap.delete(w);\n pendingInstructions.forEach((instruction) => {\n w.Upscope(...instruction);\n });\n }\n }\n else if (instruction[0] === \"on\") {\n pendingInstructionsMap.set(w, [...(pendingInstructionsMap.get(w) ?? []), instruction]);\n return;\n }\n else {\n throw new Error('Upscope is not loaded yet. Please call \"init\" as your first command.');\n }\n }\n w.Upscope(...instruction);\n};\nexport const upscopeFor = function (w) {\n return (...instruction) => {\n ScopedUpscope(w, ...instruction);\n };\n};\nconst _Upscope = upscopeFor(window);\nexport default _Upscope;\n"]}
1
+ {"version":3,"sources":["index.js"],"names":["createStub","createUpscope","injectAccountScript","loadSDK","w","apiKey","Upscope","upscopeFor","window"],"mappings":"AAAA,SAASA,UAAU,EAAEC,aAAa,EAAEC,mBAAmB,QAAQ,gBAAgB;AAC/E,8FAA8F;AAC9F,0FAA0F;AAC1F,SAASC,QAAQC,CAAC,EAAEC,MAAM;IACtB,IAAI,OAAOD,EAAEE,OAAO,KAAK,aACrB;IACJN,WAAWI;IACXF,oBAAoBE,GAAGC;AAC3B;AACA,OAAO,IAAME,aAAaN,cAAcE,SAAS;AACjD,eAAeI,WAAWC,QAAQ","file":"index.js","sourcesContent":["import { createStub, createUpscope, injectAccountScript } from \"./sdk-core.js\";\n// Default/dynamic entrypoint (@upscopeio/sdk): the account script downloads the latest hosted\n// SDK implementation from js.upscope.io, so the running version always tracks production.\nfunction loadSDK(w, apiKey) {\n if (typeof w.Upscope !== \"undefined\")\n return;\n createStub(w);\n injectAccountScript(w, apiKey);\n}\nexport const upscopeFor = createUpscope(loadSDK);\nexport default upscopeFor(window);\n"]}
package/package.json CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "name": "@upscopeio/sdk",
3
3
  "main": "index.js",
4
+ "types": "index.d.ts",
4
5
  "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./static": {
12
+ "types": "./static.d.ts",
13
+ "default": "./static.js"
14
+ }
15
+ },
5
16
  "publishConfig": {
6
17
  "registry": "https://registry.npmjs.org",
7
18
  "access": "public"
8
19
  },
9
20
  "dependencies": {},
10
- "version": "2026.6.15"
21
+ "version": "2026.6.16"
11
22
  }
package/sdk-core.js ADDED
@@ -0,0 +1,114 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function _iterable_to_array(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _non_iterable_spread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _to_consumable_array(arr) {
16
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
+ }
18
+ function _unsupported_iterable_to_array(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
+ }
26
+ // URL of the per-account script (services/code/generator.ts) for the current environment. The
27
+ // script sets __defaultConfiguration/__defaultRegion on window.Upscope.
28
+ export function accountScriptUrl(apiKey) {
29
+ return "".concat(environmentOrigin("code"), "/").concat(apiKey, ".js");
30
+ }
31
+ // Creates the command-queue stub and installs it as w.Upscope. Commands pushed onto its queue
32
+ // are drained by the SDK implementation once it boots.
33
+ export function createStub(w) {
34
+ var i = function i1() {
35
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
36
+ args[_key] = arguments[_key];
37
+ }
38
+ i.q.push(args);
39
+ };
40
+ i.q = [];
41
+ w.Upscope = i;
42
+ return i;
43
+ }
44
+ // Builds the importable Upscope command function around a load strategy. "Loaded" is keyed off
45
+ // window.Upscope existing; Upscope("shutdown") deletes it, so the next "init" loads again.
46
+ export function createUpscope(loadSDK) {
47
+ var pendingInstructionsMap = new WeakMap();
48
+ var ScopedUpscope = function ScopedUpscope(w) {
49
+ for(var _len = arguments.length, instruction = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
50
+ instruction[_key - 1] = arguments[_key];
51
+ }
52
+ var _w;
53
+ if (typeof w.Upscope === "undefined") {
54
+ if (instruction[0] === "init") {
55
+ var config = instruction[1];
56
+ if (!(config === null || config === void 0 ? void 0 : config.apiKey)) throw new Error("API key not specified");
57
+ loadSDK(w, config.apiKey);
58
+ var pendingInstructions = pendingInstructionsMap.get(w);
59
+ if (pendingInstructions) {
60
+ pendingInstructionsMap.delete(w);
61
+ pendingInstructions.forEach(function(instruction) {
62
+ var _w;
63
+ (_w = w).Upscope.apply(_w, _to_consumable_array(instruction));
64
+ });
65
+ }
66
+ } else if (instruction[0] === "on") {
67
+ var _pendingInstructionsMap_get;
68
+ pendingInstructionsMap.set(w, _to_consumable_array((_pendingInstructionsMap_get = pendingInstructionsMap.get(w)) !== null && _pendingInstructionsMap_get !== void 0 ? _pendingInstructionsMap_get : []).concat([
69
+ instruction
70
+ ]));
71
+ return;
72
+ } else {
73
+ throw new Error('Upscope is not loaded yet. Please call "init" as your first command.');
74
+ }
75
+ }
76
+ (_w = w).Upscope.apply(_w, _to_consumable_array(instruction));
77
+ };
78
+ return function(w) {
79
+ return function() {
80
+ for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
81
+ instruction[_key] = arguments[_key];
82
+ }
83
+ ScopedUpscope.apply(void 0, [
84
+ w
85
+ ].concat(_to_consumable_array(instruction)));
86
+ };
87
+ };
88
+ }
89
+ // Resolves a "<subdomain>.upscope.<tld>" origin for the current load environment, matching the
90
+ // hosting convention shared by code/js/sdkconfig (e.g. https://code.upscope.io in production).
91
+ export function environmentOrigin(subdomain) {
92
+ var _;
93
+ var environment = window.__upscope__sdk__load__environment;
94
+ return (_ = ({
95
+ development: "http://".concat(subdomain, ".upscope.local"),
96
+ production: "https://".concat(subdomain, ".upscope.io"),
97
+ staging: "https://".concat(subdomain, ".upscope.xyz")
98
+ })[environment !== null && environment !== void 0 ? environment : "production"]) !== null && _ !== void 0 ? _ : "https://".concat(subdomain, ".upscope.io");
99
+ }
100
+ // Injects the per-account script. Optional handlers let the static entry boot its bundled
101
+ // implementation once the configuration has arrived.
102
+ export function injectAccountScript(w, apiKey) {
103
+ var handlers = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
104
+ var s = w.document.createElement("script");
105
+ s.type = "text/javascript";
106
+ s.async = true;
107
+ s.src = accountScriptUrl(apiKey);
108
+ if (handlers.onLoad) s.onload = handlers.onLoad;
109
+ if (handlers.onError) s.onerror = handlers.onError;
110
+ w.document.head.appendChild(s);
111
+ }
112
+
113
+
114
+ //# sourceMappingURL=sdk-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["sdk-core.js"],"names":["accountScriptUrl","apiKey","environmentOrigin","createStub","w","i","args","q","push","Upscope","createUpscope","loadSDK","pendingInstructionsMap","WeakMap","ScopedUpscope","instruction","config","Error","pendingInstructions","get","delete","forEach","set","subdomain","environment","window","__upscope__sdk__load__environment","development","production","staging","injectAccountScript","handlers","s","document","createElement","type","async","src","onLoad","onload","onError","onerror","head","appendChild"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA8F;AAC9F,wEAAwE;AACxE,OAAO,SAASA,iBAAiBC,MAAM;IACnC,OAAO,AAAC,GAA+BA,OAA7BC,kBAAkB,SAAQ,KAAU,OAAPD,QAAO;AAClD;AACA,8FAA8F;AAC9F,uDAAuD;AACvD,OAAO,SAASE,WAAWC,CAAC;IACxB,IAAMC,IAAI;QAAU,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA;YAAGA,KAAH,QAAA,SAAA,CAAA,KAAO;;QACvBD,EAAEE,CAAC,CAACC,IAAI,CAACF;IACb;IACAD,EAAEE,CAAC,GAAG,EAAE;IACRH,EAAEK,OAAO,GAAGJ;IACZ,OAAOA;AACX;AACA,+FAA+F;AAC/F,2FAA2F;AAC3F,OAAO,SAASK,cAAcC,OAAO;IACjC,IAAMC,yBAAyB,IAAIC;IACnC,IAAMC,gBAAgB,uBAAUV,CAAC;QAAE,IAAA,IAA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jCK,YAAY,AAAC,WAAoB,OAAVL,WAAU;QACjCM,SAAS,AAAC,WAAoB,OAAVN,WAAU;IAClC,CAAA,CAAC,CAACC,wBAAAA,yBAAAA,cAAe,aAAa,cAJtB,eAAA,IAI0B,AAAC,WAAoB,OAAVD,WAAU;AAC3D;AACA,0FAA0F;AAC1F,qDAAqD;AACrD,OAAO,SAASO,oBAAoB1B,CAAC,EAAEH,MAAM;QAAE8B,WAAAA,iEAAW,CAAC;IACvD,IAAMC,IAAI5B,EAAE6B,QAAQ,CAACC,aAAa,CAAC;IACnCF,EAAEG,IAAI,GAAG;IACTH,EAAEI,KAAK,GAAG;IACVJ,EAAEK,GAAG,GAAGrC,iBAAiBC;IACzB,IAAI8B,SAASO,MAAM,EACfN,EAAEO,MAAM,GAAGR,SAASO,MAAM;IAC9B,IAAIP,SAASS,OAAO,EAChBR,EAAES,OAAO,GAAGV,SAASS,OAAO;IAChCpC,EAAE6B,QAAQ,CAACS,IAAI,CAACC,WAAW,CAACX;AAChC","file":"sdk-core.js","sourcesContent":["// URL of the per-account script (services/code/generator.ts) for the current environment. The\n// script sets __defaultConfiguration/__defaultRegion on window.Upscope.\nexport function accountScriptUrl(apiKey) {\n return `${environmentOrigin(\"code\")}/${apiKey}.js`;\n}\n// Creates the command-queue stub and installs it as w.Upscope. Commands pushed onto its queue\n// are drained by the SDK implementation once it boots.\nexport function createStub(w) {\n const i = function (...args) {\n i.q.push(args);\n };\n i.q = [];\n w.Upscope = i;\n return i;\n}\n// Builds the importable Upscope command function around a load strategy. \"Loaded\" is keyed off\n// window.Upscope existing; Upscope(\"shutdown\") deletes it, so the next \"init\" loads again.\nexport function createUpscope(loadSDK) {\n const pendingInstructionsMap = new WeakMap();\n const ScopedUpscope = function (w, ...instruction) {\n if (typeof w.Upscope === \"undefined\") {\n if (instruction[0] === \"init\") {\n const config = instruction[1];\n if (!config?.apiKey)\n throw new Error(\"API key not specified\");\n loadSDK(w, config.apiKey);\n const pendingInstructions = pendingInstructionsMap.get(w);\n if (pendingInstructions) {\n pendingInstructionsMap.delete(w);\n pendingInstructions.forEach((instruction) => {\n w.Upscope(...instruction);\n });\n }\n }\n else if (instruction[0] === \"on\") {\n pendingInstructionsMap.set(w, [...(pendingInstructionsMap.get(w) ?? []), instruction]);\n return;\n }\n else {\n throw new Error('Upscope is not loaded yet. Please call \"init\" as your first command.');\n }\n }\n w.Upscope(...instruction);\n };\n return function (w) {\n return (...instruction) => {\n ScopedUpscope(w, ...instruction);\n };\n };\n}\n// Resolves a \"<subdomain>.upscope.<tld>\" origin for the current load environment, matching the\n// hosting convention shared by code/js/sdkconfig (e.g. https://code.upscope.io in production).\nexport function environmentOrigin(subdomain) {\n const environment = window.__upscope__sdk__load__environment;\n return ({\n development: `http://${subdomain}.upscope.local`,\n production: `https://${subdomain}.upscope.io`,\n staging: `https://${subdomain}.upscope.xyz`,\n }[environment ?? \"production\"] ?? `https://${subdomain}.upscope.io`);\n}\n// Injects the per-account script. Optional handlers let the static entry boot its bundled\n// implementation once the configuration has arrived.\nexport function injectAccountScript(w, apiKey, handlers = {}) {\n const s = w.document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src = accountScriptUrl(apiKey);\n if (handlers.onLoad)\n s.onload = handlers.onLoad;\n if (handlers.onError)\n s.onerror = handlers.onError;\n w.document.head.appendChild(s);\n}\n"]}
package/static.d.ts ADDED
@@ -0,0 +1,250 @@
1
+ type CobrowsingSdkConfiguration = {
2
+ // User provided
3
+ agentPrompt?: string;
4
+ callName?: string;
5
+ jsConfiguration?: boolean;
6
+ secretKey?: string;
7
+ sharingRoot: Window;
8
+
9
+ // User provided nulls clear, undefined maintain existing info
10
+ identities?: null | string | string[];
11
+ integrationIds?: null | string | string[];
12
+ metadata?: null | Record<string, string>;
13
+ tags?: null | string | string[];
14
+ uniqueId?: null | string;
15
+
16
+ // Automatic
17
+ agentRequestAcceptedText: LocalizedMessage;
18
+ agentRequestButtonPages: string[];
19
+ agentRequestButtonRequestingSubtitle: LocalizedMessage;
20
+ agentRequestButtonRequestingTitle: LocalizedMessage;
21
+ agentRequestButtonStyle: string;
22
+ agentRequestButtonSubtitle: LocalizedMessage;
23
+ agentRequestButtonTitle: LocalizedMessage;
24
+ agentRequestNotAvailableText: LocalizedMessage;
25
+ agentRequestResultTitle: LocalizedMessage;
26
+ allowAgentRedirect: boolean;
27
+ allowFullScreen: boolean;
28
+ allowRemoteClick: boolean;
29
+ allowRemoteConsole: boolean;
30
+ allowRemoteMiddleware: (element: HTMLElement) => boolean;
31
+ allowRemoteScroll: boolean;
32
+ allowRemoteType: boolean;
33
+ allowRequestFullTab: boolean;
34
+ apiKey: string;
35
+ authorizationPromptMessage: LocalizedMessage;
36
+ authorizationPromptTitle: LocalizedMessage;
37
+ autoconnect: boolean;
38
+ automaticallyRequestFullTab: boolean;
39
+ beta: boolean;
40
+ callAudioAuthorizationFailedMessage: LocalizedMessage;
41
+ callAudioAuthorizationFailedTitle: LocalizedMessage;
42
+ callPopupFailedMessage: LocalizedMessage;
43
+ callPopupFailedTitle: LocalizedMessage;
44
+ callPopupNoInputMessage: LocalizedMessage;
45
+ callPopupNoInputTitle: LocalizedMessage;
46
+ callPopupNoOutputMessage: LocalizedMessage;
47
+ callPopupNoOutputTitle: LocalizedMessage;
48
+ callPopupNoVideoInputMessage: LocalizedMessage;
49
+ callPopupNoVideoInputTitle: LocalizedMessage;
50
+ callPromptText: LocalizedMessage;
51
+ callRingtone: string;
52
+ callVideoAuthorizationFailedMessage: LocalizedMessage;
53
+ callVideoAuthorizationFailedTitle: LocalizedMessage;
54
+ callVideoRequestButton: LocalizedMessage;
55
+ callWaitMessage: LocalizedMessage;
56
+ collectHistory: boolean;
57
+ compressImages: boolean;
58
+ computedStyleSelectors: "angular" | "react" | string[];
59
+ consoleAllowed: boolean;
60
+ controlRequestMessage: LocalizedMessage;
61
+ controlRequestTitle: LocalizedMessage;
62
+ cssFile: string;
63
+ cursorColor: string;
64
+ customCallController: ((callback: (accepted: boolean) => void) => (() => void) | void) | null;
65
+ customControlRequestController: ((callback: (accepted: boolean) => void) => (() => void) | void) | null;
66
+ customFullScreenRequestController: ((callback: (accepted: boolean) => void) => (() => void) | void) | null;
67
+ dataEndpoint: string;
68
+ disableFullScreenWhenMasked: boolean;
69
+ disconnectAfterSeconds: number;
70
+ domChangesDelay: number;
71
+ drawingsTtlMs: number;
72
+ enableCanvases: boolean;
73
+ enableLookupCodeOnKey: boolean;
74
+ enableSessionRating: boolean;
75
+ endOfScreenshareMessage: null | string;
76
+ enlargeCursor: boolean;
77
+ fullScreenRequestMessage: LocalizedMessage;
78
+ fullScreenRequestTitle: LocalizedMessage;
79
+ grabIdentityFromLivechat: boolean;
80
+ ignoreBrowserSupport: boolean;
81
+ injectLookupCodeButton: boolean;
82
+ integrateWithLivechat: boolean;
83
+ javascriptEndpoint: string;
84
+ liveChatRewrite: boolean;
85
+ lookupCodeButtonPages: string[];
86
+ lookupCodeButtonStyle: string;
87
+ lookupCodeElement: HTMLElement | null | string;
88
+ lookupCodeKey: number;
89
+ lookupCodeKeyMessage: LocalizedMessage;
90
+ lookupCodeKeyRepetitions: number;
91
+ lookupCodeKeyTitle: LocalizedMessage;
92
+ maskedElements: string[];
93
+ maskElementMiddleware: (element: HTMLElement) => boolean;
94
+ noRemoteElements: string[];
95
+ onConnection: (() => void) | null;
96
+ onSessionContinue: () => void;
97
+ onSessionEnd: () => void;
98
+ onSessionRequest: (cb: (accepted: boolean) => void, requestingAgent: null | string) => (() => void) | void;
99
+ onSessionStart: () => void;
100
+ onWaitingForCall: () => void;
101
+ pageviewsEndpoint: string;
102
+ phoneEndpoint: string;
103
+ videoCallPromptText: LocalizedMessage;
104
+ // Automatic
105
+ cobrowsingVideoAudioRelationship: "automatic" | "independent" | "video_requires_audio";
106
+ cobrowsingVideoEnabled: "disabled" | "two_way" | "viewer_to_visitor" | "visitor_to_viewer";
107
+ product: "cobrowsingapi" | "helloscreen" | "userview";
108
+ proxyAssets: string[];
109
+ publicLinkOrigin: null | string;
110
+ region: null | string;
111
+ readonly regionWhitelist: null | string[];
112
+ requireAuthorizationForSession: boolean;
113
+ requireControlRequest: boolean;
114
+ rewriteExternalLinks: boolean;
115
+ screenWakeLock: boolean;
116
+ sessionRatingAgentLabel: LocalizedMessage;
117
+ sessionRatingFeedbackLabel: LocalizedMessage;
118
+ sessionRatingModalMessage: LocalizedMessage;
119
+ sessionRatingModalTitle: LocalizedMessage;
120
+ sessionRatingSessionLabel: LocalizedMessage;
121
+ sessionRatingSubmitLabel: LocalizedMessage;
122
+ sfdcFieldId: string;
123
+ sfdcFieldLabel: string;
124
+ shouldComputeStyleMiddleware: (element: HTMLElement) => boolean;
125
+ showAgentRequestButton: "always" | "never" | "when_available"; // One of: always / when_available / never
126
+ showTerminateButton: boolean;
127
+ showUpscopeLink: boolean;
128
+ storageImplementation: null | UpscopeStorageImplementation;
129
+ storageKey: null | string;
130
+ styleSheetContentFromRules: (stylesheet: HTMLLinkElement | HTMLStyleElement) => boolean;
131
+ trackConsole: boolean;
132
+ translationsNo: LocalizedMessage;
133
+ translationsOk: LocalizedMessage;
134
+ translationsStopSession: LocalizedMessage;
135
+ translationsYes: LocalizedMessage;
136
+ unavailableAgentRequestRedirectImmediately: boolean;
137
+ unavailableAgentRequestRedirectTo: null | string;
138
+ useFingerprinting: boolean;
139
+ useInlineCss: boolean;
140
+ version: string;
141
+ };
142
+
143
+ type Instruction =
144
+ | ["beginViewerVideoCall"]
145
+ | ["beginVisitorVideoCall"]
146
+ | ["cancelRequestAgent"]
147
+ | ["connect"]
148
+ | ["customMessage", Record<string, unknown>]
149
+ | ["dataBounce", (ms: number) => void]
150
+ | ["endAudio"]
151
+ | ["endViewerVideoCall"]
152
+ | ["endVisitorVideoCall"]
153
+ | ["expectDisconnect", Partial<{ message: null | string; returnTimeSeconds: null | number; title: null | string }>]
154
+ | ["fullTabEnd"]
155
+ | ["fullTabStart"]
156
+ | ["getLookupCode", (code: string) => void]
157
+ | ["getPublicLink", { agentId: string; agentName: string }, (publicLink: string) => void]
158
+ | ["getShortId", (shortId: string) => void]
159
+ | ["getUserId", (shortId: string) => void] // Legacy version of getShortId
160
+ | ["getWatchLink", (link: string) => void]
161
+ | ["init", Partial<Omit<CobrowsingSdkConfiguration, "apiKey">> & { apiKey: string }]
162
+ | ["logEvent", "contact" | "error" | "info" | "success" | "warn", string]
163
+ | ["newPageview"]
164
+ | ["on", ...(keyof SDKEvents)[], (event: any) => void] // eslint-disable-line @typescript-eslint/no-explicit-any
165
+ | ["prefetchAssets"]
166
+ | ["requestAgent"]
167
+ | [
168
+ "requestMode",
169
+ (
170
+ | "visitor_app"
171
+ | "visitor_browser"
172
+ | `viewer_screen:${"*" | `cobrowsing_viewer_connection_${string}`}`
173
+ | `visitor_screen:${"*" | `cobrowsing_visitor_connection_${string}`}`
174
+ ),
175
+ ]
176
+ | ["reset", boolean]
177
+ | ["reset"]
178
+ | ["saveHistory"]
179
+ | ["shutdown"]
180
+ | ["startAudio"]
181
+ | ["stopSession"]
182
+ | [
183
+ "submitRating",
184
+ {
185
+ userAgentFeedback?: string;
186
+ userAgentRating?: number;
187
+ userSessionRating?: number;
188
+ },
189
+ ]
190
+ | ["triggerConfetti", null | string]
191
+ | ["updateConnection", Partial<CobrowsingSdkConfiguration>];
192
+
193
+ type LocalizedMessage = Record<string, string> | string;
194
+
195
+ type SDKEvents = {
196
+ agentRequestUpdate: ["accepted" | "canceled" | "pending" | "unavailable"];
197
+ agentsAvailable: undefined;
198
+ audioCallAccepted: undefined;
199
+ audioCallEnd: undefined;
200
+ audioCallStart: undefined;
201
+ connection: undefined;
202
+ connectionReset: undefined;
203
+ customMessage: [
204
+ { observer: `cobrowsing_viewer_connection_${string}` } | { visitor: `cobrowsing_visitor_connection_${string}` },
205
+ Record<string, unknown>,
206
+ ];
207
+ newObserver: [`cobrowsing_viewer_connection_${string}`, Viewer];
208
+ observerContentVisible: [`cobrowsing_viewer_connection_${string}`];
209
+ observerGone: [`cobrowsing_viewer_connection_${string}`];
210
+ observersCount: [number];
211
+ observerUpdate: [`cobrowsing_viewer_connection_${string}`, Partial<Viewer>];
212
+ sessionContinue: undefined;
213
+ sessionEnd: undefined;
214
+ sessionRequest: undefined;
215
+ sessionStart: undefined;
216
+ waitingForCall: undefined;
217
+ };
218
+
219
+ type SubmitRating = {
220
+ userAgentFeedback?: string;
221
+ userAgentRating?: number;
222
+ userSessionRating?: number;
223
+ };
224
+
225
+ type Upscope = (...instruction: Instruction) => void;
226
+
227
+ type UpscopeStorageImplementation = {
228
+ clear: () => Promise<void> | void;
229
+ getItem: (key: string) => null | Promise<null | string> | string;
230
+ key: (index: number) => null | Promise<null | string> | string;
231
+ removeItem: (key: string) => Promise<void> | void;
232
+ setItem: (key: string, value: string) => Promise<void> | void;
233
+ };
234
+
235
+ type Viewer = {
236
+ audioStatus: "accepted" | "active" | "authorizing" | "off" | "ringing";
237
+ audioSupported: boolean;
238
+ connectionId: `cobrowsing_viewer_connection_${string}`;
239
+ externalId: "__UNKNOWN_ONPREM_EXTERNAL_VIEWER_ID__" | "__UNTRACKED__" | `ea_${string}` | `u_${string}`;
240
+ hasFocus: boolean;
241
+ keepsSessionAlive: boolean;
242
+ name: null | string;
243
+ screenHeight: number;
244
+ screenScale: number;
245
+ screenWidth: number;
246
+ windowHeight: number;
247
+ windowWidth: number;
248
+ };
249
+
250
+ export default function Upscope(...instruction: Instruction): void;