Socket
Socket
Sign inDemoInstall

@shapediver/sdk.sdtf-v1

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shapediver/sdk.sdtf-v1 - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

8

dist/http/SdtfHttpClient.d.ts

@@ -7,3 +7,5 @@ import { ISdtfHttpClient } from "./ISdtfHttpClient";

readonly jsonContentUrl: string;
constructor(jsonContentUrl: string);
/** the minimum headers object that should be used for all HTTP calls.. */
private readonly basicHttpHeader;
constructor(jsonContentUrl: string, authToken?: string);
/**

@@ -48,8 +50,6 @@ * Constructs the URL of this sdTF asset for the given URI.

* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetchFully(url: string, offset: number, length: number): Promise<any>;
fetchFully(url: string): Promise<any>;
}
//# sourceMappingURL=SdtfHttpClient.d.ts.map

@@ -21,6 +21,10 @@ "use strict";

class SdtfHttpClient {
constructor(jsonContentUrl) {
constructor(jsonContentUrl, authToken) {
this.binarySdtfParser = new SdtfBinarySdtf_1.SdtfBinarySdtf();
// This initializes this http client for the specified sdTF asset
this.jsonContentUrl = jsonContentUrl;
// Initialize tha basic HTTP header object
this.basicHttpHeader = {};
if (authToken)
this.basicHttpHeader.authorization = "Bearer " + authToken;
}

@@ -92,3 +96,3 @@ /**

try {
response = yield axios_1.default.head(url);
response = yield axios_1.default.head(url, { headers: this.basicHttpHeader });
}

@@ -111,3 +115,3 @@ catch (e) {

yield this.fetchPartially(url, offset, length) :
yield this.fetchFully(url, offset, length);
yield this.fetchFully(url);
// This is required to support Node.js as well as Browsers

@@ -136,3 +140,3 @@ const buffer = (data instanceof ArrayBuffer) ? data : Uint8Array.from(data).buffer;

response = yield axios_1.default.get(url, {
headers: { range: `bytes=${offset}-${offset + length - 1}` },
headers: Object.assign(Object.assign({}, this.basicHttpHeader), { range: `bytes=${offset}-${offset + length - 1}` }),
responseType: "arraybuffer",

@@ -157,7 +161,5 @@ });

* @param url
* @param offset - Zero-based byte index at which to begin (inclusive).
* @param length - Length of the buffer.
* @throws {@link SdtfError} when the request was not successful.
*/
fetchFully(url, offset, length) {
fetchFully(url) {
return __awaiter(this, void 0, void 0, function* () {

@@ -168,2 +170,3 @@ let response;

response = yield axios_1.default.get(url, {
headers: this.basicHttpHeader,
responseType: "arraybuffer",

@@ -170,0 +173,0 @@ });

@@ -1,11 +0,12 @@

import { ISdtfIntegration, ISdtfParser, ISdtfReadableAsset } from "@shapediver/sdk.sdtf-core";
import { ISdtfParser, ISdtfReadableAsset } from "@shapediver/sdk.sdtf-core";
import { ISdtfBufferCache } from "../buffer_cache/ISdtfBufferCache";
import { SdtfConfig } from "../SdtfConfig";
import { ISdtfComponentList } from "../structure/ISdtfComponentList";
import { ISdtfReadableComponentFactory } from "./ISdtfReadableComponentFactory";
export declare class SdtfParser implements ISdtfParser {
private readonly integration;
private readonly config;
private readonly binarySdtfParser;
private readonly componentFactory;
private readonly fileUtils;
constructor(integration: ISdtfIntegration[]);
constructor(config: SdtfConfig);
readFromFile(path: string): Promise<ISdtfReadableAsset>;

@@ -12,0 +13,0 @@ readFromUrl(url: string): Promise<ISdtfReadableAsset>;

@@ -26,4 +26,4 @@ "use strict";

class SdtfParser {
constructor(integration) {
this.integration = integration;
constructor(config) {
this.config = config;
this.binarySdtfParser = new SdtfBinarySdtf_1.SdtfBinarySdtf();

@@ -55,3 +55,3 @@ this.componentFactory = new SdtfComponentFactoryWrapper_1.SdtfComponentFactoryWrapper();

return __awaiter(this, void 0, void 0, function* () {
const httpClient = new SdtfHttpClient_1.SdtfHttpClient(url);
const httpClient = new SdtfHttpClient_1.SdtfHttpClient(url, this.config.authToken);
const [contentBuffer, binaryBuffer] = yield httpClient.getJsonContent();

@@ -74,3 +74,3 @@ const jsonContent = this.binarySdtfParser.readJsonContent(contentBuffer);

const componentList = this.componentFactory.createFromJson(content);
const readableComponentFactory = new SdtfReadableComponentFactory_1.SdtfReadableComponentFactory(bufferCache, new SdtfDataParser_1.SdtfDataParser(this.integration));
const readableComponentFactory = new SdtfReadableComponentFactory_1.SdtfReadableComponentFactory(bufferCache, new SdtfDataParser_1.SdtfDataParser(this.config.integrations));
return this.buildReadableAsset(componentList, readableComponentFactory);

@@ -77,0 +77,0 @@ }

@@ -13,4 +13,11 @@ import { ISdtfIntegration } from "@shapediver/sdk.sdtf-core";

integrations: ISdtfIntegration[];
/**
* The JSON Web Token (JWT) to authorization HTTP calls.
*
* ShapeDiver models can be configured so that all interactions with them require a JSON Web Token (JWT) for
* authorization. In this case, a `401` HTTP status is returned when no `authToken` has been specified.
*/
authToken?: string;
constructor(config?: Partial<SdtfConfig>);
}
//# sourceMappingURL=SdtfConfig.d.ts.map

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

this.integrations = config.integrations;
this.authToken = config === null || config === void 0 ? void 0 : config.authToken;
}

@@ -25,0 +26,0 @@ }

@@ -37,3 +37,3 @@ "use strict";

createParser() {
return new SdtfParser_1.SdtfParser(this.config.integrations);
return new SdtfParser_1.SdtfParser(this.config);
}

@@ -40,0 +40,0 @@ /**

{
"name": "@shapediver/sdk.sdtf-v1",
"version": "1.0.0",
"version": "1.1.0",
"description": "Official sdTF SDK for TypeScript",

@@ -51,16 +51,16 @@ "keywords": [

"dependencies": {
"@shapediver/sdk.sdtf-core": "^1.0.0",
"@shapediver/sdk.sdtf-primitives": "^1.0.0",
"@shapediver/sdk.sdtf-geometry": "^1.0.0",
"axios": "^0.27.2",
"@shapediver/sdk.sdtf-core": "^1.1.0",
"@shapediver/sdk.sdtf-primitives": "^1.1.0",
"@shapediver/sdk.sdtf-geometry": "^1.1.0",
"axios": "^1.1.3",
"browser-or-node": "^2.0.0"
},
"devDependencies": {
"jest": "^28.1.0",
"jest": "^29.2.2",
"lerna": "3.22.1",
"typescript": "^4.6.4",
"webpack": "^5.72.1",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.0"
"typescript": "^4.8.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1"
}
}

@@ -55,3 +55,9 @@ <p align="center">

By default, the SDK instantiates the integrations for [primitive types](https://www.npmjs.com/package/@shapediver/sdk.sdtf-primitives) and [geometry types](https://www.npmjs.com/package/@shapediver/sdk.sdtf-geometry).
The default integrations can be adopted by specifying a customized list of integrations in the `integrations`-array of the `SdtfConfig` object:
The default integrations can be adopted by specifying a customized list of integrations in the `integrations`-array of the `SdtfConfig` object.
By default, the SDK does not use any authorization token for its HTTP calls.
However, ShapeDiver models can be configured so that all interactions with them require a JSON Web Token (JWT) for authorization.
Thus, a valid JWT must be provided when the SDK is instantiated and the sdTF file is accessed remotely (`readFromUrl`).
Otherwise, a`401` HTTP status is returned when the sdTF is fetched.
```typescript

@@ -61,3 +67,7 @@ import { create } from "@shapediver/sdk.sdtf-v1"

create({
integrations: [], // Remove the default integrations from the sdTF
// Remove the default integrations from the sdTF
integrations: [],
// Add a JWT for HTTP authorization
authToken: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3d3dy5zaGFwZWRpdmVyLmNvbS9hcGkvdjEvdG9rZW5zIiwic3ViIjoiMWM0MzY2MzAtMWYxNy00Y2QyLWFmMTItNDNiYTMzZmVkMDYyIiwiYXVkIjoiOTIwNzk0ZmEtMjQ1YS00ODdkLThhYmUtYWY1NjlhOTdkYTQyIiwiZXhwIjoxNjY3NDc4MDUzLCJzY29wZSI6Imdyb3VwLmV4cG9ydCBncm91cC52aWV3IiwiaWF0IjoxNjY3NDc0NDUzLCJzZF91c2VyX2lkIjoiOTQ4MzJlN2YtMGNjNS00YjE4LWIxNGItOTBkN2FlZTYxYzIzIn0.AKkzs-mCW_3qA3XISMiaW6Bp_MFPVoUnWPWcPllUOZ1Ve5K_tFd0xxpT_T0AoUs8OxQZBXujdKojJLj5sbycKA7X9IEGomQBYjCoTJsQGeafFJW_LSrWb9Z4L9xTu0g02UcvKbwSxyIxLug0pVunklSNN382sgbcKVt6ZapT5a8YGaH5LjYCHVb90OTTQ2JUurtdyqyBLJ1CJbszdkggZuyV2uHhSgJ--jrxcOq_lBgI-tuPj4cbQx340vdhPFXTZA9NAnk6fuI8kfSSej-BQpkdHBi_FAhxlQf5AZov6BonaKl8KIvcFi2Zk77jyB6fjfWwXsT5s0kNVaali58PXQ"
}).then(sdk => {

@@ -64,0 +74,0 @@ // use sdk here

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