UNPKG

citeright-sdk-js

Version:
39 lines (38 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var CallerContext = /** @class */ (function () { function CallerContext(applicationName, applicationVersion, osType, osVersion, browserType, browserVersion, msWordVersion) { this.applicationName = applicationName; this.applicationVersion = applicationVersion; this.osType = osType; this.osVersion = osVersion; this.browserType = browserType; this.browserVersion = browserVersion; this.msWordVersion = msWordVersion; } CallerContext.inferBrowserContext = function (explicit) { return new CallerContext(explicit.applicationName || null, explicit.applicationVersion || null, explicit.osType || navigator.platform, explicit.osVersion || navigator.appVersion, explicit.browserType || navigator.appVersion, explicit.browserVersion || navigator.appCodeName, explicit.msWordVersion || null); }; CallerContext.inferNodeJSContext = function (explicit) { return new CallerContext(explicit.applicationName || process.env.npm_package_name, explicit.applicationVersion || process.env.npm_package_version, explicit.osType || null, explicit.osVersion || null, explicit.browserType || null, explicit.browserVersion || null, explicit.msWordVersion || null); }; CallerContext.infer = function (explicit) { var isBrowser = typeof window !== "undefined"; return isBrowser ? CallerContext.inferBrowserContext(explicit) : CallerContext.inferNodeJSContext(explicit); }; CallerContext.prototype.toHttpHeaders = function () { return { "x-cr-application-name": this.applicationName, "x-cr-application-version": this.applicationVersion, "x-cr-browser-type": this.browserType, "x-cr-browser-version": this.browserVersion, "x-cr-msword-version": this.msWordVersion, "x-cr-os-type": this.osType, "x-cr-os-version": this.osVersion, }; }; return CallerContext; }()); exports.default = CallerContext;