Socket
Socket
Sign inDemoInstall

@shapediver/sdk.geometry-api-sdk-core

Package Overview
Dependencies
Maintainers
5
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shapediver/sdk.geometry-api-sdk-core - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

4

dist/api/ShapeDiverSdkApi.d.ts

@@ -1,2 +0,2 @@

import { ShapeDiverSdkConfigInternal } from "../config/ShapeDiverSdkConfig";
import { SdkConfigInternal } from "../config/ShapeDiverSdkConfig";
export interface ShapeDiverSdkApiRequestHeaders {

@@ -12,3 +12,3 @@ contentType: string;

private config;
constructor(config: ShapeDiverSdkConfigInternal);
constructor(config: SdkConfigInternal);
private buildRequestConfig;

@@ -15,0 +15,0 @@ private buildUrl;

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

method: method,
headers: {
"Content-Type": headers.contentType,
},
headers: Object.assign(Object.assign({}, this.config.headers), { "Content-Type": headers.contentType }),
responseType: responseType,
data: undefined,
};
// Add origin if specified.
// The browser adds the Origin automatically to each request.
// However, during testing this needs to be set manually.
if (this.config.origin) {
request.headers["Origin"] = this.config.origin;
}
// Add jwt if provided
if (this.config.jwt && !headers.authorization) {
if (this.config.jwt) {
request.headers["Authorization"] = "Bearer " + this.config.jwt;

@@ -117,3 +109,3 @@ }

let stringData;
if (typeof window === 'undefined') {
if (typeof window === "undefined") {
// NodeJs

@@ -120,0 +112,0 @@ stringData = Buffer.from(data).toString();

import { ShapeDiverSdkApi } from "./api/ShapeDiverSdkApi";
import { ShapeDiverSdkConfig, ShapeDiverSdkConfigInternal } from "./config/ShapeDiverSdkConfig";
import { ShapeDiverSdkConfig, SdkConfigInternal, ShapeDiverSdkConfigType } from "./config/ShapeDiverSdkConfig";
export declare abstract class BaseShapeDiverSdk {
protected readonly sdkConfig: ShapeDiverSdkConfigInternal;
protected readonly sdkConfig: SdkConfigInternal;
protected readonly sdkApi: ShapeDiverSdkApi;

@@ -10,7 +10,14 @@ /**

* @param baseUrl - the URL of the target system
* @param jwt - the client's jwt
*/
protected constructor(baseUrl: string, jwt?: string);
protected constructor(baseUrl: string);
/**
* Set a specific configuration value.
*
* @param type
* @param value
*/
setConfigurationValue(type: ShapeDiverSdkConfigType, value: any): void;
/** Get the ShapeDiver configuration object */
get configuration(): ShapeDiverSdkConfig;
}
//# sourceMappingURL=BaseShapeDiverSdk.d.ts.map

@@ -11,8 +11,17 @@ "use strict";

* @param baseUrl - the URL of the target system
* @param jwt - the client's jwt
*/
constructor(baseUrl, jwt) {
this.sdkConfig = new ShapeDiverSdkConfig_1.ShapeDiverSdkConfigInternal(baseUrl, jwt);
constructor(baseUrl) {
this.sdkConfig = new ShapeDiverSdkConfig_1.SdkConfigInternal(baseUrl);
this.sdkApi = new ShapeDiverSdkApi_1.ShapeDiverSdkApi(this.sdkConfig);
}
/**
* Set a specific configuration value.
*
* @param type
* @param value
*/
setConfigurationValue(type, value) {
this.sdkConfig.setConfigValue(type, value);
}
/** Get the ShapeDiver configuration object */
get configuration() {

@@ -19,0 +28,0 @@ return this.sdkConfig.toConfig();

@@ -0,12 +1,31 @@

/** ShapeDiver configuration object */
export interface ShapeDiverSdkConfig {
baseUrl: string;
jwt: string;
baseUrl: string;
headers: {
[key: string]: any;
};
}
export declare class ShapeDiverSdkConfigInternal {
readonly baseUrl: string;
readonly jwt: string;
readonly origin: string | undefined;
constructor(baseUrl: string, jwt?: string);
/** Supported types of the ShapeDiver configuration object */
export declare enum ShapeDiverSdkConfigType {
BASE_URL = "BASE_URL",
JWT_TOKEN = "JWT_TOKEN",
REQUEST_HEADERS = "REQUEST_HEADERS"
}
export declare type RequestHeader = {
[key: string]: string | number | Array<string | number>;
};
/** Private interface of the ShapeDiver configuration object */
export declare class SdkConfigInternal {
private _baseUrl;
private _headers;
private _jwt;
constructor(baseUrl: string);
get baseUrl(): string;
get headers(): RequestHeader;
get jwt(): string;
toConfig(): ShapeDiverSdkConfig;
setConfigValue(type: ShapeDiverSdkConfigType, value: any): void;
static validateValue(type: ShapeDiverSdkConfigType, value: any, dataType: "string" | "string_keyed_object"): any;
}
//# sourceMappingURL=ShapeDiverSdkConfig.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeDiverSdkConfigInternal = void 0;
class ShapeDiverSdkConfigInternal {
constructor(baseUrl, jwt) {
// The origin is needed during testing, but should not be exposed to the user!
this.origin = undefined;
this.baseUrl = baseUrl;
this.jwt = (jwt) ? jwt : "";
exports.SdkConfigInternal = exports.ShapeDiverSdkConfigType = void 0;
const ShapeDiverErrors_1 = require("../ShapeDiverErrors");
/** Supported types of the ShapeDiver configuration object */
var ShapeDiverSdkConfigType;
(function (ShapeDiverSdkConfigType) {
ShapeDiverSdkConfigType["BASE_URL"] = "BASE_URL";
ShapeDiverSdkConfigType["JWT_TOKEN"] = "JWT_TOKEN";
ShapeDiverSdkConfigType["REQUEST_HEADERS"] = "REQUEST_HEADERS";
})(ShapeDiverSdkConfigType = exports.ShapeDiverSdkConfigType || (exports.ShapeDiverSdkConfigType = {}));
/** Private interface of the ShapeDiver configuration object */
class SdkConfigInternal {
constructor(baseUrl) {
this._baseUrl = baseUrl;
this._headers = {};
this._jwt = "";
}
get baseUrl() {
return this._baseUrl;
}
get headers() {
return this._headers;
}
get jwt() {
return this._jwt;
}
toConfig() {
return {
jwt: this.jwt,
baseUrl: this.baseUrl,
baseUrl: this._baseUrl,
headers: this._headers,
jwt: this._jwt,
};
}
setConfigValue(type, value) {
switch (type) {
case ShapeDiverSdkConfigType.BASE_URL:
this._baseUrl = SdkConfigInternal.validateValue(type, value, "string");
break;
case ShapeDiverSdkConfigType.JWT_TOKEN:
this._jwt = SdkConfigInternal.validateValue(type, value, "string");
break;
case ShapeDiverSdkConfigType.REQUEST_HEADERS:
this._headers = SdkConfigInternal.validateValue(type, value, "string_keyed_object");
break;
default:
throw new ShapeDiverErrors_1.ShapeDiverError(`Invalid config-type ${type}`);
}
}
static validateValue(type, value, dataType) {
switch (dataType) {
case "string":
if (typeof value !== "string")
throw new ShapeDiverErrors_1.ShapeDiverError(`Invalid value for config-type '${type}': Value must be a string`);
break;
case "string_keyed_object":
if (typeof value !== "object" || !Object.values(value).every(v => typeof v === "string" || typeof v === "number" || typeof v === "boolean" || Array.isArray(v)))
throw new ShapeDiverErrors_1.ShapeDiverError(`Invalid value for config-type '${type}': Value must be a string-keyed-object`);
break;
}
return value;
}
}
exports.ShapeDiverSdkConfigInternal = ShapeDiverSdkConfigInternal;
exports.SdkConfigInternal = SdkConfigInternal;
//# sourceMappingURL=ShapeDiverSdkConfig.js.map
import { ShapeDiverSdkApi, ShapeDiverSdkApiRequestHeaders, ShapeDiverSdkApiResponseType } from "./api/ShapeDiverSdkApi";
import { BaseShapeDiverSdk } from "./BaseShapeDiverSdk";
import { ShapeDiverSdkConfig } from "./config/ShapeDiverSdkConfig";
import { ShapeDiverSdkConfig, ShapeDiverSdkConfigType } from "./config/ShapeDiverSdkConfig";
import { BaseResourceApi } from "./resources/BaseResourceApi";
import { ShapeDiverError, ShapeDiverRequestError, ShapeDiverResponseError } from "./ShapeDiverErrors";
export { BaseResourceApi, BaseShapeDiverSdk, ShapeDiverError, ShapeDiverRequestError, ShapeDiverResponseError, ShapeDiverSdkApi, ShapeDiverSdkApiRequestHeaders, ShapeDiverSdkApiResponseType, ShapeDiverSdkConfig, };
export { BaseResourceApi, BaseShapeDiverSdk, ShapeDiverError, ShapeDiverRequestError, ShapeDiverResponseError, ShapeDiverSdkApi, ShapeDiverSdkApiRequestHeaders, ShapeDiverSdkApiResponseType, ShapeDiverSdkConfig, ShapeDiverSdkConfigType, };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeDiverSdkApiResponseType = exports.ShapeDiverSdkApi = exports.ShapeDiverResponseError = exports.ShapeDiverRequestError = exports.ShapeDiverError = exports.BaseShapeDiverSdk = exports.BaseResourceApi = void 0;
exports.ShapeDiverSdkConfigType = exports.ShapeDiverSdkApiResponseType = exports.ShapeDiverSdkApi = exports.ShapeDiverResponseError = exports.ShapeDiverRequestError = exports.ShapeDiverError = exports.BaseShapeDiverSdk = exports.BaseResourceApi = void 0;
const ShapeDiverSdkApi_1 = require("./api/ShapeDiverSdkApi");

@@ -9,2 +9,4 @@ Object.defineProperty(exports, "ShapeDiverSdkApi", { enumerable: true, get: function () { return ShapeDiverSdkApi_1.ShapeDiverSdkApi; } });

Object.defineProperty(exports, "BaseShapeDiverSdk", { enumerable: true, get: function () { return BaseShapeDiverSdk_1.BaseShapeDiverSdk; } });
const ShapeDiverSdkConfig_1 = require("./config/ShapeDiverSdkConfig");
Object.defineProperty(exports, "ShapeDiverSdkConfigType", { enumerable: true, get: function () { return ShapeDiverSdkConfig_1.ShapeDiverSdkConfigType; } });
const BaseResourceApi_1 = require("./resources/BaseResourceApi");

@@ -11,0 +13,0 @@ Object.defineProperty(exports, "BaseResourceApi", { enumerable: true, get: function () { return BaseResourceApi_1.BaseResourceApi; } });

{
"name": "@shapediver/sdk.geometry-api-sdk-core",
"version": "1.0.3",
"version": "1.0.4",
"description": "Core-library for SDK-packages to communicate with the Geometry API",

@@ -9,3 +9,5 @@ "keywords": [],

"main": "dist/index.js",
"directories": {},
"directories": {
"test": "__tests__"
},
"files": [

@@ -29,9 +31,17 @@ "dist"

"typings": "dist/index.d.ts",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testMatch": [
"**/__tests__/**/*.test.ts"
]
},
"dependencies": {
"axios": "^0.23.0"
"axios": "^0.24.0"
},
"devDependencies": {
"jest": "^27.4.5",
"lerna": "^3.22.1",
"typescript": "^4.4.3"
"typescript": "^4.5.4"
}
}

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

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