@navigraph/app
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -43,3 +43,3 @@ "use strict"; | ||
// src/public-types.ts | ||
// src/types.ts | ||
var Scope = /* @__PURE__ */ ((Scope2) => { | ||
@@ -54,4 +54,46 @@ Scope2["CHARTS"] = "charts"; | ||
// src/internal.ts | ||
var _apps = /* @__PURE__ */ new Map(); | ||
// src/shared/errors.ts | ||
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 AuthenticationAbortedError = class extends Error { | ||
constructor() { | ||
super("Unable to sign in with device flow. The authentication was aborted."); | ||
this.name = "AuthenticationAborted"; | ||
} | ||
}; | ||
var NonGeoreferencedChartError = class extends Error { | ||
constructor(indexNumber) { | ||
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`); | ||
this.name = "NonGeoreferencedChartError"; | ||
} | ||
}; | ||
@@ -117,15 +159,7 @@ // src/lib/Logger.ts | ||
// src/api.ts | ||
var getApp = () => { | ||
const app = _apps.get("DEFAULT"); | ||
return app; | ||
}; | ||
var getDefaultAppDomain = () => { | ||
var _a, _b; | ||
return (_b = (_a = getApp()) == null ? void 0 : _a.domain) != null ? _b : "navigraph.com"; | ||
}; | ||
function initializeApp(app) { | ||
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"]; | ||
app.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app.scopes])); | ||
if (_apps.get("DEFAULT")) { | ||
// src/internals/apps.ts | ||
var app; | ||
var getApp = () => app; | ||
var setApp = (newApp) => { | ||
if (app) { | ||
Logger_default.warning( | ||
@@ -135,49 +169,15 @@ "Navigraph App has already been initialized. The existing configuration will be overwritten." | ||
} | ||
_apps.set("DEFAULT", app); | ||
} | ||
// src/errors.ts | ||
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"; | ||
} | ||
app = newApp; | ||
}; | ||
var UserDeniedAccessError = class extends Error { | ||
constructor() { | ||
super("Authentication failed. User denied access."); | ||
this.name = "UserDeniedAccessError"; | ||
} | ||
var getDefaultAppDomain = () => { | ||
var _a; | ||
return (_a = app == null ? void 0 : app.domain) != null ? _a : "navigraph.com"; | ||
}; | ||
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 AuthenticationAbortedError = class extends Error { | ||
constructor() { | ||
super("Unable to sign in with device flow. The authentication was aborted."); | ||
this.name = "AuthenticationAborted"; | ||
} | ||
}; | ||
var NonGeoreferencedChartError = class extends Error { | ||
constructor(indexNumber) { | ||
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`); | ||
this.name = "NonGeoreferencedChartError"; | ||
} | ||
}; | ||
// src/lib/initializeApp.ts | ||
function initializeApp(app2) { | ||
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"]; | ||
app2.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app2.scopes])); | ||
setApp(app2); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -184,0 +184,0 @@ 0 && (module.exports = { |
@@ -9,25 +9,3 @@ declare enum Scope { | ||
} | ||
/** The configuration needed to define your Navigraph application */ | ||
interface NavigraphApp { | ||
/** The id for your client which you will obtain from Navigraph. */ | ||
clientId: string; | ||
/** The secret password for your client which you will obtain from Navigraph. */ | ||
clientSecret: string; | ||
domain?: string; | ||
/** Scopes enable your application to access specific API endpoints on behalf of a user. | ||
* The set of scopes you pass in your call determines the access permissions that the user is required to grant. | ||
* @see {@link Scope} */ | ||
scopes: Scope[]; | ||
} | ||
/** Grabs the currently authenticated Navigraph App. */ | ||
declare const getApp: () => NavigraphApp | undefined; | ||
declare const getDefaultAppDomain: () => string; | ||
/** | ||
* Initialize a Navigraph application. This configures the Navigraph SDK | ||
* with the necessary details to authenticate and communicate with Navigraph APIs. | ||
* @param {NavigraphApp} app - The configuration needed to define your Navigraph application | ||
* */ | ||
declare function initializeApp(app: NavigraphApp): void; | ||
declare class NotInitializedError extends Error { | ||
@@ -56,3 +34,3 @@ constructor(source?: string); | ||
declare const LEVELS: readonly ["emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"]; | ||
type LogLevel = typeof LEVELS[number]; | ||
type LogLevel = (typeof LEVELS)[number]; | ||
declare class Logger { | ||
@@ -73,2 +51,26 @@ level: LogLevel; | ||
/** The configuration needed to define your Navigraph application */ | ||
interface NavigraphApp { | ||
/** The id for your client which you will obtain from Navigraph. */ | ||
clientId: string; | ||
/** The secret password for your client which you will obtain from Navigraph. */ | ||
clientSecret: string; | ||
domain?: string; | ||
/** Scopes enable your application to access specific API endpoints on behalf of a user. | ||
* The set of scopes you pass in your call determines the access permissions that the user is required to grant. | ||
* @see {@link Scope} */ | ||
scopes: Scope[]; | ||
} | ||
/** | ||
* Initialize a Navigraph application. This configures the Navigraph SDK | ||
* with the necessary details to authenticate and communicate with Navigraph APIs. | ||
* @param {NavigraphApp} app - The configuration needed to define your Navigraph application | ||
* */ | ||
declare function initializeApp(app: NavigraphApp): void; | ||
/** Returns a reference to the currently configured {@link NavigraphApp}. */ | ||
declare const getApp: () => NavigraphApp | undefined; | ||
/** Returns the domain for the currently configured {@link NavigraphApp}. */ | ||
declare const getDefaultAppDomain: () => string; | ||
export { AuthenticationAbortedError, DeviceFlowTokenExpiredError, InvalidClientError, InvalidScopeError, logger as Logger, NavigraphApp, NonGeoreferencedChartError, NotInitializedError, Scope, UserDeniedAccessError, getApp, getDefaultAppDomain, initializeApp }; |
@@ -8,3 +8,3 @@ var __defProp = Object.defineProperty; | ||
// src/public-types.ts | ||
// src/types.ts | ||
var Scope = /* @__PURE__ */ ((Scope2) => { | ||
@@ -19,4 +19,46 @@ Scope2["CHARTS"] = "charts"; | ||
// src/internal.ts | ||
var _apps = /* @__PURE__ */ new Map(); | ||
// src/shared/errors.ts | ||
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 AuthenticationAbortedError = class extends Error { | ||
constructor() { | ||
super("Unable to sign in with device flow. The authentication was aborted."); | ||
this.name = "AuthenticationAborted"; | ||
} | ||
}; | ||
var NonGeoreferencedChartError = class extends Error { | ||
constructor(indexNumber) { | ||
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`); | ||
this.name = "NonGeoreferencedChartError"; | ||
} | ||
}; | ||
@@ -82,15 +124,7 @@ // src/lib/Logger.ts | ||
// src/api.ts | ||
var getApp = () => { | ||
const app = _apps.get("DEFAULT"); | ||
return app; | ||
}; | ||
var getDefaultAppDomain = () => { | ||
var _a, _b; | ||
return (_b = (_a = getApp()) == null ? void 0 : _a.domain) != null ? _b : "navigraph.com"; | ||
}; | ||
function initializeApp(app) { | ||
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"]; | ||
app.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app.scopes])); | ||
if (_apps.get("DEFAULT")) { | ||
// src/internals/apps.ts | ||
var app; | ||
var getApp = () => app; | ||
var setApp = (newApp) => { | ||
if (app) { | ||
Logger_default.warning( | ||
@@ -100,49 +134,15 @@ "Navigraph App has already been initialized. The existing configuration will be overwritten." | ||
} | ||
_apps.set("DEFAULT", app); | ||
} | ||
// src/errors.ts | ||
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"; | ||
} | ||
app = newApp; | ||
}; | ||
var UserDeniedAccessError = class extends Error { | ||
constructor() { | ||
super("Authentication failed. User denied access."); | ||
this.name = "UserDeniedAccessError"; | ||
} | ||
var getDefaultAppDomain = () => { | ||
var _a; | ||
return (_a = app == null ? void 0 : app.domain) != null ? _a : "navigraph.com"; | ||
}; | ||
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 AuthenticationAbortedError = class extends Error { | ||
constructor() { | ||
super("Unable to sign in with device flow. The authentication was aborted."); | ||
this.name = "AuthenticationAborted"; | ||
} | ||
}; | ||
var NonGeoreferencedChartError = class extends Error { | ||
constructor(indexNumber) { | ||
super(`Could not calculate bounds for ${indexNumber || "a chart"} since it is not georeferenced`); | ||
this.name = "NonGeoreferencedChartError"; | ||
} | ||
}; | ||
// src/lib/initializeApp.ts | ||
function initializeApp(app2) { | ||
const DEFAULT_SCOPES = ["userinfo", "openid", "offline_access"]; | ||
app2.scopes = Array.from(/* @__PURE__ */ new Set([...DEFAULT_SCOPES, ...app2.scopes])); | ||
setApp(app2); | ||
} | ||
export { | ||
@@ -149,0 +149,0 @@ AuthenticationAbortedError, |
{ | ||
"name": "@navigraph/app", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "The fundamental part of the Navigraph SDK", |
407
14301