New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@navigraph/app

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@navigraph/app - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

673

dist/index.cjs.js
"use strict";
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [
null
];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
var _typeof = function(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var __defProp = Object.defineProperty;

@@ -173,375 +6,181 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = function(obj, key, value) {
return key in obj ? __defProp(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value: value
}) : obj[key] = value;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __export = function(target, all) {
for(var name in all)__defProp(target, name, {
get: all[name],
enumerable: true
});
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __copyProps = function(to, from, except, desc) {
if (from && typeof from === "object" || typeof from === "function") {
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
try {
var _loop = function() {
var key = _step.value;
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: function() {
return from[key];
},
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
};
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally{
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally{
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return to;
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __toCommonJS = function(mod) {
return __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
};
var __publicField = function(obj, key, value) {
__defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _typeof(key)) !== "symbol" ? key + "" : key, value);
return value;
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
DeviceFlowTokenExpiredError: function() {
return DeviceFlowTokenExpiredError;
},
InvalidClientError: function() {
return InvalidClientError;
},
InvalidScopeError: function() {
return InvalidScopeError;
},
Logger: function() {
return Logger_default;
},
NonGeoreferencedChartError: function() {
return NonGeoreferencedChartError;
},
NotInitializedError: function() {
return NotInitializedError;
},
Scope: function() {
return Scope;
},
UserDeniedAccessError: function() {
return UserDeniedAccessError;
},
getApp: function() {
return getApp;
},
getDefaultAppDomain: function() {
return getDefaultAppDomain;
},
initializeApp: function() {
return initializeApp;
}
DeviceFlowTokenExpiredError: () => DeviceFlowTokenExpiredError,
InvalidClientError: () => InvalidClientError,
InvalidScopeError: () => InvalidScopeError,
Logger: () => Logger_default,
NonGeoreferencedChartError: () => NonGeoreferencedChartError,
NotInitializedError: () => NotInitializedError,
Scope: () => Scope,
UserDeniedAccessError: () => UserDeniedAccessError,
getApp: () => getApp,
getDefaultAppDomain: () => getDefaultAppDomain,
initializeApp: () => initializeApp
});
module.exports = __toCommonJS(src_exports);
// src/public-types.ts
var Scope = /* @__PURE__ */ function(Scope2) {
Scope2["CHARTS"] = "charts";
Scope2["FMSDATA"] = "fmsdata";
Scope2["EMAIL"] = "email";
Scope2["TILES"] = "tiles";
Scope2["OFFLINE"] = "offline_access";
return Scope2;
}(Scope || {});
var Scope = /* @__PURE__ */ ((Scope2) => {
Scope2["CHARTS"] = "charts";
Scope2["FMSDATA"] = "fmsdata";
Scope2["EMAIL"] = "email";
Scope2["TILES"] = "tiles";
Scope2["OFFLINE"] = "offline_access";
return Scope2;
})(Scope || {});
// src/internal.ts
var _apps = /* @__PURE__ */ new Map();
// src/lib/Logger.ts
var LEVELS = [
"emerg",
"alert",
"crit",
"err",
"warning",
"notice",
"info",
"debug"
];
var Logger = /*#__PURE__*/ function() {
function Logger() {
_classCallCheck(this, Logger);
__publicField(this, "level", "notice");
var LEVELS = ["emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"];
var Logger = class {
constructor() {
__publicField(this, "level", "notice");
}
_log(level, ...message) {
if (LEVELS.indexOf(this.level) < LEVELS.indexOf(level)) {
return;
}
_createClass(Logger, [
{
key: "_log",
value: function _log(level) {
for(var _len = arguments.length, message = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
message[_key - 1] = arguments[_key];
}
if (LEVELS.indexOf(this.level) < LEVELS.indexOf(level)) {
return;
}
switch(level){
case "emerg":
case "alert":
case "crit":
case "err":
var _console;
(_console = console).error.apply(_console, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
case "warning":
var _console1;
(_console1 = console).warn.apply(_console1, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
case "debug":
var _console2;
(_console2 = console).debug.apply(_console2, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
default:
var _console3;
(_console3 = console).log.apply(_console3, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
}
}
},
{
key: "log",
value: function log() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"info"
].concat(_toConsumableArray(message)));
}
},
{
key: "emerg",
value: function emerg() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"emerg"
].concat(_toConsumableArray(message)));
}
},
{
key: "alert",
value: function alert() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"alert"
].concat(_toConsumableArray(message)));
}
},
{
key: "crit",
value: function crit() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"crit"
].concat(_toConsumableArray(message)));
}
},
{
key: "err",
value: function err() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"err"
].concat(_toConsumableArray(message)));
}
},
{
key: "warning",
value: function warning() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"warning"
].concat(_toConsumableArray(message)));
}
},
{
key: "notice",
value: function notice() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"notice"
].concat(_toConsumableArray(message)));
}
},
{
key: "info",
value: function info() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"info"
].concat(_toConsumableArray(message)));
}
},
{
key: "debug",
value: function debug() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"debug"
].concat(_toConsumableArray(message)));
}
}
]);
return Logger;
}();
switch (level) {
case "emerg":
case "alert":
case "crit":
case "err":
console.error("[Navigraph]", ...message);
break;
case "warning":
console.warn("[Navigraph]", ...message);
break;
case "debug":
console.debug("[Navigraph]", ...message);
break;
default:
console.log("[Navigraph]", ...message);
break;
}
}
log(...message) {
this._log("info", ...message);
}
emerg(...message) {
this._log("emerg", ...message);
}
alert(...message) {
this._log("alert", ...message);
}
crit(...message) {
this._log("crit", ...message);
}
err(...message) {
this._log("err", ...message);
}
warning(...message) {
this._log("warning", ...message);
}
notice(...message) {
this._log("notice", ...message);
}
info(...message) {
this._log("info", ...message);
}
debug(...message) {
this._log("debug", ...message);
}
};
var logger = new Logger();
var Logger_default = logger;
// src/api.ts
var getApp = function() {
var app = _apps.get("DEFAULT");
return app;
var getApp = () => {
const app = _apps.get("DEFAULT");
return app;
};
var ref;
var getDefaultAppDomain = function() {
var ref1;
return (ref = (ref1 = getApp()) === null || ref1 === void 0 ? void 0 : ref1.domain) !== null && ref !== void 0 ? ref : "navigraph.com";
var getDefaultAppDomain = () => {
var _a, _b;
return (_b = (_a = getApp()) == null ? void 0 : _a.domain) != null ? _b : "navigraph.com";
};
function initializeApp(app) {
var DEFAULT_SCOPES = [
"userinfo",
"openid",
"offline_access"
];
app.scopes = Array.from(/* @__PURE__ */ new Set(_toConsumableArray(DEFAULT_SCOPES).concat(_toConsumableArray(app.scopes))));
if (_apps.get("DEFAULT")) {
Logger_default.warning("Navigraph App has already been initialized. The existing configuration will be overwritten.");
}
_apps.set("DEFAULT", app);
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"];
app.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app.scopes]));
if (_apps.get("DEFAULT")) {
Logger_default.warning(
"Navigraph App has already been initialized. The existing configuration will be overwritten."
);
}
_apps.set("DEFAULT", app);
}
// src/errors.ts
var NotInitializedError = /*#__PURE__*/ function(Error1) {
_inherits(NotInitializedError, Error1);
var _super = _createSuper(NotInitializedError);
function NotInitializedError(source) {
_classCallCheck(this, NotInitializedError);
var _this;
var message = source ? "[".concat(source, "] Navigraph app is not initialized.") : "Navigraph app is not initialized.";
_this = _super.call(this, message);
_this.name = "NotInitializedError";
return _this;
}
return NotInitializedError;
}(_wrapNativeSuper(Error));
var UserDeniedAccessError = /*#__PURE__*/ function(Error1) {
_inherits(UserDeniedAccessError, Error1);
var _super = _createSuper(UserDeniedAccessError);
function UserDeniedAccessError() {
_classCallCheck(this, UserDeniedAccessError);
var _this;
_this = _super.call(this, "Authentication failed. User denied access.");
_this.name = "UserDeniedAccessError";
return _this;
}
return UserDeniedAccessError;
}(_wrapNativeSuper(Error));
var DeviceFlowTokenExpiredError = /*#__PURE__*/ function(Error1) {
_inherits(DeviceFlowTokenExpiredError, Error1);
var _super = _createSuper(DeviceFlowTokenExpiredError);
function DeviceFlowTokenExpiredError() {
_classCallCheck(this, DeviceFlowTokenExpiredError);
var _this;
_this = _super.call(this, "Authentication failed. Device flow token expired.");
_this.name = "DeviceFlowTokenExpiredError";
return _this;
}
return DeviceFlowTokenExpiredError;
}(_wrapNativeSuper(Error));
var InvalidScopeError = /*#__PURE__*/ function(Error1) {
_inherits(InvalidScopeError, Error1);
var _super = _createSuper(InvalidScopeError);
function InvalidScopeError(scope) {
_classCallCheck(this, InvalidScopeError);
var _this;
_this = _super.call(this, "Authentication failed. Invalid scope ".concat(scope ? ": " + scope : "provided."));
_this.name = "InvalidScopeError";
return _this;
}
return InvalidScopeError;
}(_wrapNativeSuper(Error));
var InvalidClientError = /*#__PURE__*/ function(Error1) {
_inherits(InvalidClientError, Error1);
var _super = _createSuper(InvalidClientError);
function InvalidClientError() {
_classCallCheck(this, InvalidClientError);
var _this;
_this = _super.call(this, "Unable to sign in with device flow. The client is likely incorrectly configured.");
_this.name = "InvalidClientError";
return _this;
}
return InvalidClientError;
}(_wrapNativeSuper(Error));
var NonGeoreferencedChartError = /*#__PURE__*/ function(Error1) {
_inherits(NonGeoreferencedChartError, Error1);
var _super = _createSuper(NonGeoreferencedChartError);
function NonGeoreferencedChartError(indexNumber) {
_classCallCheck(this, NonGeoreferencedChartError);
var _this;
_this = _super.call(this, "Could not calculate bounds for ".concat(indexNumber || "a chart", " since it is not georeferenced"));
_this.name = "NonGeoreferencedChartError";
return _this;
}
return NonGeoreferencedChartError;
}(_wrapNativeSuper(Error));
var NotInitializedError = class extends Error {
constructor(source) {
const message = source ? `[${source}] Navigraph app is not initialized.` : "Navigraph app is not initialized.";
super(message);
this.name = "NotInitializedError";
}
};
var UserDeniedAccessError = class extends Error {
constructor() {
super("Authentication failed. User denied access.");
this.name = "UserDeniedAccessError";
}
};
var DeviceFlowTokenExpiredError = class extends Error {
constructor() {
super("Authentication failed. Device flow token expired.");
this.name = "DeviceFlowTokenExpiredError";
}
};
var InvalidScopeError = class extends Error {
constructor(scope) {
super(`Authentication failed. Invalid scope ${scope ? ": " + scope : "provided."}`);
this.name = "InvalidScopeError";
}
};
var InvalidClientError = class extends Error {
constructor() {
super("Unable to sign in with device flow. The client is likely incorrectly configured.");
this.name = "InvalidClientError";
}
};
var NonGeoreferencedChartError = class extends Error {
constructor(indexNumber) {
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`);
this.name = "NonGeoreferencedChartError";
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DeviceFlowTokenExpiredError: DeviceFlowTokenExpiredError,
InvalidClientError: InvalidClientError,
InvalidScopeError: InvalidScopeError,
Logger: Logger,
NonGeoreferencedChartError: NonGeoreferencedChartError,
NotInitializedError: NotInitializedError,
Scope: Scope,
UserDeniedAccessError: UserDeniedAccessError,
getApp: getApp,
getDefaultAppDomain: getDefaultAppDomain,
initializeApp: initializeApp
DeviceFlowTokenExpiredError,
InvalidClientError,
InvalidScopeError,
Logger,
NonGeoreferencedChartError,
NotInitializedError,
Scope,
UserDeniedAccessError,
getApp,
getDefaultAppDomain,
initializeApp
});

@@ -52,3 +52,3 @@ declare enum Scope {

declare const LEVELS: readonly ["emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"];
declare type LogLevel = typeof LEVELS[number];
type LogLevel = typeof LEVELS[number];
declare class Logger {

@@ -55,0 +55,0 @@ level: LogLevel;

@@ -1,456 +0,150 @@

function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [
null
];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
var _typeof = function(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var __defProp = Object.defineProperty;
var __defNormalProp = function(obj, key, value) {
return key in obj ? __defProp(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value: value
}) : obj[key] = value;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __publicField = function(obj, key, value) {
__defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _typeof(key)) !== "symbol" ? key + "" : key, value);
return value;
};
// src/public-types.ts
var Scope = /* @__PURE__ */ function(Scope2) {
Scope2["CHARTS"] = "charts";
Scope2["FMSDATA"] = "fmsdata";
Scope2["EMAIL"] = "email";
Scope2["TILES"] = "tiles";
Scope2["OFFLINE"] = "offline_access";
return Scope2;
}(Scope || {});
var Scope = /* @__PURE__ */ ((Scope2) => {
Scope2["CHARTS"] = "charts";
Scope2["FMSDATA"] = "fmsdata";
Scope2["EMAIL"] = "email";
Scope2["TILES"] = "tiles";
Scope2["OFFLINE"] = "offline_access";
return Scope2;
})(Scope || {});
// src/internal.ts
var _apps = /* @__PURE__ */ new Map();
// src/lib/Logger.ts
var LEVELS = [
"emerg",
"alert",
"crit",
"err",
"warning",
"notice",
"info",
"debug"
];
var Logger = /*#__PURE__*/ function() {
"use strict";
function Logger() {
_classCallCheck(this, Logger);
__publicField(this, "level", "notice");
var LEVELS = ["emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"];
var Logger = class {
constructor() {
__publicField(this, "level", "notice");
}
_log(level, ...message) {
if (LEVELS.indexOf(this.level) < LEVELS.indexOf(level)) {
return;
}
_createClass(Logger, [
{
key: "_log",
value: function _log(level) {
for(var _len = arguments.length, message = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
message[_key - 1] = arguments[_key];
}
if (LEVELS.indexOf(this.level) < LEVELS.indexOf(level)) {
return;
}
switch(level){
case "emerg":
case "alert":
case "crit":
case "err":
var _console;
(_console = console).error.apply(_console, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
case "warning":
var _console1;
(_console1 = console).warn.apply(_console1, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
case "debug":
var _console2;
(_console2 = console).debug.apply(_console2, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
default:
var _console3;
(_console3 = console).log.apply(_console3, [
"[Navigraph]"
].concat(_toConsumableArray(message)));
break;
}
}
},
{
key: "log",
value: function log() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"info"
].concat(_toConsumableArray(message)));
}
},
{
key: "emerg",
value: function emerg() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"emerg"
].concat(_toConsumableArray(message)));
}
},
{
key: "alert",
value: function alert() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"alert"
].concat(_toConsumableArray(message)));
}
},
{
key: "crit",
value: function crit() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"crit"
].concat(_toConsumableArray(message)));
}
},
{
key: "err",
value: function err() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"err"
].concat(_toConsumableArray(message)));
}
},
{
key: "warning",
value: function warning() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"warning"
].concat(_toConsumableArray(message)));
}
},
{
key: "notice",
value: function notice() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"notice"
].concat(_toConsumableArray(message)));
}
},
{
key: "info",
value: function info() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"info"
].concat(_toConsumableArray(message)));
}
},
{
key: "debug",
value: function debug() {
for(var _len = arguments.length, message = new Array(_len), _key = 0; _key < _len; _key++){
message[_key] = arguments[_key];
}
this._log.apply(this, [
"debug"
].concat(_toConsumableArray(message)));
}
}
]);
return Logger;
}();
switch (level) {
case "emerg":
case "alert":
case "crit":
case "err":
console.error("[Navigraph]", ...message);
break;
case "warning":
console.warn("[Navigraph]", ...message);
break;
case "debug":
console.debug("[Navigraph]", ...message);
break;
default:
console.log("[Navigraph]", ...message);
break;
}
}
log(...message) {
this._log("info", ...message);
}
emerg(...message) {
this._log("emerg", ...message);
}
alert(...message) {
this._log("alert", ...message);
}
crit(...message) {
this._log("crit", ...message);
}
err(...message) {
this._log("err", ...message);
}
warning(...message) {
this._log("warning", ...message);
}
notice(...message) {
this._log("notice", ...message);
}
info(...message) {
this._log("info", ...message);
}
debug(...message) {
this._log("debug", ...message);
}
};
var logger = new Logger();
var Logger_default = logger;
// src/api.ts
var getApp = function() {
var app = _apps.get("DEFAULT");
return app;
var getApp = () => {
const app = _apps.get("DEFAULT");
return app;
};
var ref;
var getDefaultAppDomain = function() {
var ref1;
return (ref = (ref1 = getApp()) === null || ref1 === void 0 ? void 0 : ref1.domain) !== null && ref !== void 0 ? ref : "navigraph.com";
var getDefaultAppDomain = () => {
var _a, _b;
return (_b = (_a = getApp()) == null ? void 0 : _a.domain) != null ? _b : "navigraph.com";
};
function initializeApp(app) {
var DEFAULT_SCOPES = [
"userinfo",
"openid",
"offline_access"
];
app.scopes = Array.from(/* @__PURE__ */ new Set(_toConsumableArray(DEFAULT_SCOPES).concat(_toConsumableArray(app.scopes))));
if (_apps.get("DEFAULT")) {
Logger_default.warning("Navigraph App has already been initialized. The existing configuration will be overwritten.");
}
_apps.set("DEFAULT", app);
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"];
app.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app.scopes]));
if (_apps.get("DEFAULT")) {
Logger_default.warning(
"Navigraph App has already been initialized. The existing configuration will be overwritten."
);
}
_apps.set("DEFAULT", app);
}
// src/errors.ts
var NotInitializedError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(NotInitializedError, Error1);
var _super = _createSuper(NotInitializedError);
function NotInitializedError(source) {
_classCallCheck(this, NotInitializedError);
var _this;
var message = source ? "[".concat(source, "] Navigraph app is not initialized.") : "Navigraph app is not initialized.";
_this = _super.call(this, message);
_this.name = "NotInitializedError";
return _this;
}
return NotInitializedError;
}(_wrapNativeSuper(Error));
var UserDeniedAccessError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(UserDeniedAccessError, Error1);
var _super = _createSuper(UserDeniedAccessError);
function UserDeniedAccessError() {
_classCallCheck(this, UserDeniedAccessError);
var _this;
_this = _super.call(this, "Authentication failed. User denied access.");
_this.name = "UserDeniedAccessError";
return _this;
}
return UserDeniedAccessError;
}(_wrapNativeSuper(Error));
var DeviceFlowTokenExpiredError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(DeviceFlowTokenExpiredError, Error1);
var _super = _createSuper(DeviceFlowTokenExpiredError);
function DeviceFlowTokenExpiredError() {
_classCallCheck(this, DeviceFlowTokenExpiredError);
var _this;
_this = _super.call(this, "Authentication failed. Device flow token expired.");
_this.name = "DeviceFlowTokenExpiredError";
return _this;
}
return DeviceFlowTokenExpiredError;
}(_wrapNativeSuper(Error));
var InvalidScopeError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(InvalidScopeError, Error1);
var _super = _createSuper(InvalidScopeError);
function InvalidScopeError(scope) {
_classCallCheck(this, InvalidScopeError);
var _this;
_this = _super.call(this, "Authentication failed. Invalid scope ".concat(scope ? ": " + scope : "provided."));
_this.name = "InvalidScopeError";
return _this;
}
return InvalidScopeError;
}(_wrapNativeSuper(Error));
var InvalidClientError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(InvalidClientError, Error1);
var _super = _createSuper(InvalidClientError);
function InvalidClientError() {
_classCallCheck(this, InvalidClientError);
var _this;
_this = _super.call(this, "Unable to sign in with device flow. The client is likely incorrectly configured.");
_this.name = "InvalidClientError";
return _this;
}
return InvalidClientError;
}(_wrapNativeSuper(Error));
var NonGeoreferencedChartError = /*#__PURE__*/ function(Error1) {
"use strict";
_inherits(NonGeoreferencedChartError, Error1);
var _super = _createSuper(NonGeoreferencedChartError);
function NonGeoreferencedChartError(indexNumber) {
_classCallCheck(this, NonGeoreferencedChartError);
var _this;
_this = _super.call(this, "Could not calculate bounds for ".concat(indexNumber || "a chart", " since it is not georeferenced"));
_this.name = "NonGeoreferencedChartError";
return _this;
}
return NonGeoreferencedChartError;
}(_wrapNativeSuper(Error));
export { DeviceFlowTokenExpiredError, InvalidClientError, InvalidScopeError, Logger_default as Logger, NonGeoreferencedChartError, NotInitializedError, Scope, UserDeniedAccessError, getApp, getDefaultAppDomain, initializeApp };
var NotInitializedError = class extends Error {
constructor(source) {
const message = source ? `[${source}] Navigraph app is not initialized.` : "Navigraph app is not initialized.";
super(message);
this.name = "NotInitializedError";
}
};
var UserDeniedAccessError = class extends Error {
constructor() {
super("Authentication failed. User denied access.");
this.name = "UserDeniedAccessError";
}
};
var DeviceFlowTokenExpiredError = class extends Error {
constructor() {
super("Authentication failed. Device flow token expired.");
this.name = "DeviceFlowTokenExpiredError";
}
};
var InvalidScopeError = class extends Error {
constructor(scope) {
super(`Authentication failed. Invalid scope ${scope ? ": " + scope : "provided."}`);
this.name = "InvalidScopeError";
}
};
var InvalidClientError = class extends Error {
constructor() {
super("Unable to sign in with device flow. The client is likely incorrectly configured.");
this.name = "InvalidClientError";
}
};
var NonGeoreferencedChartError = class extends Error {
constructor(indexNumber) {
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`);
this.name = "NonGeoreferencedChartError";
}
};
export {
DeviceFlowTokenExpiredError,
InvalidClientError,
InvalidScopeError,
Logger_default as Logger,
NonGeoreferencedChartError,
NotInitializedError,
Scope,
UserDeniedAccessError,
getApp,
getDefaultAppDomain,
initializeApp
};
{
"name": "@navigraph/app",
"version": "1.3.0",
"version": "1.3.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "The fundamental part of the Navigraph SDK",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc