Socket
Socket
Sign inDemoInstall

@jupiterone/integration-sdk-runtime

Package Overview
Dependencies
Maintainers
1
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupiterone/integration-sdk-runtime - npm Package Compare versions

Comparing version 3.8.0 to 4.0.0

10

dist/src/api/error.d.ts
import { IntegrationError } from '@jupiterone/integration-sdk-core';
export declare class IntegrationMalformedApiKeyError extends IntegrationError {
constructor(message: string);
}
export declare class IntegrationApiKeyRequiredError extends IntegrationError {
constructor(message: string);
constructor();
}
export declare function malformedApiKeyError(): IntegrationMalformedApiKeyError;
export declare function apiKeyRequiredError(): IntegrationMalformedApiKeyError;
export declare class IntegrationAccountRequiredError extends IntegrationError {
constructor();
}

30

dist/src/api/error.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiKeyRequiredError = exports.malformedApiKeyError = exports.IntegrationApiKeyRequiredError = exports.IntegrationMalformedApiKeyError = void 0;
exports.IntegrationAccountRequiredError = exports.IntegrationApiKeyRequiredError = void 0;
const integration_sdk_core_1 = require("@jupiterone/integration-sdk-core");
class IntegrationMalformedApiKeyError extends integration_sdk_core_1.IntegrationError {
constructor(message) {
class IntegrationApiKeyRequiredError extends integration_sdk_core_1.IntegrationError {
constructor() {
super({
code: 'MALFORMED_API_KEY_ERROR',
message,
code: 'JUPITERONE_API_KEY_ENVIRONMENT_VARIABLE_NOT_SET',
message: 'The JUPITERONE_API_KEY environment variable must be set',
});
}
}
exports.IntegrationMalformedApiKeyError = IntegrationMalformedApiKeyError;
class IntegrationApiKeyRequiredError extends integration_sdk_core_1.IntegrationError {
constructor(message) {
exports.IntegrationApiKeyRequiredError = IntegrationApiKeyRequiredError;
class IntegrationAccountRequiredError extends integration_sdk_core_1.IntegrationError {
constructor() {
super({
code: 'JUPITER_ONE_API_KEY_ENVIRONMENT_VARIABLE_NOT_SET',
message,
code: 'JUPITERONE_ACCOUNT_ENVIRONMENT_VARIABLE_NOT_SET',
message: 'The JUPITERONE_ACCOUNT environment variable must be set',
});
}
}
exports.IntegrationApiKeyRequiredError = IntegrationApiKeyRequiredError;
function malformedApiKeyError() {
return new IntegrationMalformedApiKeyError('Malformed API Key provided');
}
exports.malformedApiKeyError = malformedApiKeyError;
function apiKeyRequiredError() {
return new IntegrationMalformedApiKeyError('The JUPITERONE_API_KEY environment variable must be set');
}
exports.apiKeyRequiredError = apiKeyRequiredError;
exports.IntegrationAccountRequiredError = IntegrationAccountRequiredError;
//# sourceMappingURL=error.js.map

@@ -8,11 +8,3 @@ import { AxiosInstance } from 'axios';

}
interface CreateApiClientFromApiKeyInput {
apiBaseUrl: string;
apiKey: string;
}
/**
* Creates an API client using an API key
*/
export declare function createApiClientWithApiKey({ apiBaseUrl, apiKey, }: CreateApiClientFromApiKeyInput): AxiosInstance;
/**
* Configures an api client for hitting JupiterOne APIs.

@@ -31,3 +23,4 @@ *

export declare function getApiBaseUrl({ dev }?: GetApiBaseUrlInput): "https://api.dev.jupiterone.io" | "https://api.us.jupiterone.io";
export declare function getApiKeyFromEnvironment(): string;
export declare const getApiKeyFromEnvironment: () => string;
export declare const getAccountFromEnvironment: () => string;
export {};

@@ -6,38 +6,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getApiKeyFromEnvironment = exports.getApiBaseUrl = exports.createApiClient = exports.createApiClientWithApiKey = void 0;
exports.getAccountFromEnvironment = exports.getApiKeyFromEnvironment = exports.getApiBaseUrl = exports.createApiClient = void 0;
const alpha_1 = __importDefault(require("@lifeomic/alpha"));
const error_1 = require("./error");
const dotenv_1 = __importDefault(require("dotenv"));
const dotenv_expand_1 = __importDefault(require("dotenv-expand"));
const jwt = require('jsonwebtoken');
const error_1 = require("./error");
/**
* Creates an API client using an API key
*/
function createApiClientWithApiKey({ apiBaseUrl, apiKey, }) {
const account = extractAccountFromApiKey(apiKey);
return createApiClient({
apiBaseUrl,
account,
accessToken: apiKey,
});
}
exports.createApiClientWithApiKey = createApiClientWithApiKey;
/**
* Extracts the account from the api key
*/
function extractAccountFromApiKey(apiKey) {
let token;
try {
token = jwt.decode(apiKey);
}
catch (err) {
throw error_1.malformedApiKeyError();
}
const { account } = token;
if (!account) {
throw error_1.malformedApiKeyError();
}
return account;
}
/**
* Configures an api client for hitting JupiterOne APIs.

@@ -72,11 +42,12 @@ *

exports.getApiBaseUrl = getApiBaseUrl;
function getApiKeyFromEnvironment() {
function getFromEnv(variableName, missingError) {
dotenv_expand_1.default(dotenv_1.default.config());
const apiKey = process.env.JUPITERONE_API_KEY;
if (!apiKey) {
throw error_1.apiKeyRequiredError();
const value = process.env[variableName];
if (!value) {
throw new missingError();
}
return apiKey;
return value;
}
exports.getApiKeyFromEnvironment = getApiKeyFromEnvironment;
exports.getApiKeyFromEnvironment = () => getFromEnv('JUPITERONE_API_KEY', error_1.IntegrationApiKeyRequiredError);
exports.getAccountFromEnvironment = () => getFromEnv('JUPITERONE_ACCOUNT', error_1.IntegrationAccountRequiredError);
//# sourceMappingURL=index.js.map

@@ -151,2 +151,3 @@ "use strict";

logger: this._logger.child(options, simple),
onFailure: this.onFailure,
});

@@ -203,2 +204,3 @@ // pass events to parent

this.error({ errorId, err }, description);
this.onFailure({ err });
}

@@ -209,3 +211,2 @@ else {

this.publishEvent({ name: eventName, description });
this.onFailure({ err });
}

@@ -212,0 +213,0 @@ publishMetric(metric) {

{
"name": "@jupiterone/integration-sdk-runtime",
"version": "3.8.0",
"version": "4.0.0",
"description": "The SDK for developing JupiterOne integrations",

@@ -26,3 +26,3 @@ "main": "dist/src/index.js",

"dependencies": {
"@jupiterone/integration-sdk-core": "^3.8.0",
"@jupiterone/integration-sdk-core": "^4.0.0",
"@lifeomic/alpha": "^1.1.3",

@@ -38,3 +38,2 @@ "async-sema": "^3.1.0",

"globby": "^11.0.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",

@@ -47,3 +46,3 @@ "p-map": "^4.0.0",

"devDependencies": {
"@jupiterone/integration-sdk-private-test-utils": "^3.8.0",
"@jupiterone/integration-sdk-private-test-utils": "^4.0.0",
"@types/uuid": "^7.0.2",

@@ -54,3 +53,3 @@ "get-port": "^5.1.1",

},
"gitHead": "23109b1bffa3ffa6847bb182d53d45354f562b68"
"gitHead": "d3cd7630b73195f4fd8db94d2364442ba63c38ff"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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