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

@sap/bas-sdk

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/bas-sdk - npm Package Compare versions

Comparing version 2.1.5 to 3.1.0

25

api.d.ts

@@ -50,6 +50,9 @@ import { URL } from "url";

* Execute a process in the devspace.
* @param command command to execute.
* @param args list of arguments to the command.
* @param opt command options json
*/
execute(command: string, ...args: string[]): void;
execute(opt: {
command: string;
args?: string[];
onError?: (err?: Error) => void;
}): void;

@@ -62,2 +65,12 @@ /**

/**
* @param callback Adds the listener function for the websocket 'close' event. If the listener has already been added, it will be swapped out by the new one.
*/
onClose(callback: (code: number, reason: Buffer) => void): void;
/**
* @param callback Adds the listener function for the websocket 'error' event. If the listener has already been added, it will be swapped out by the new one.
*/
onError(callback: (error: Error) => void): void;
/**
* Disconnect from the devspace.

@@ -96,3 +109,4 @@ */

* BasicAuthentication - Used for destinations that refer to a service on the Internet or an on-premise system that requires basic authentication.
* NoAuthentication - Create and configure an OAuth2ClientCredentials destination to consume OAuth-protected resources from a Cloud Foundry application.
* OAuth2ClientCredentials - Create and configure an OAuth2ClientCredentials destination to consume OAuth-protected resources from a Cloud Foundry application.
* OAuth2UserTokenExchange - When a user is logged into an application that needs to call another application and pass the user context, the caller application must perform a user token exchange.
*/

@@ -102,3 +116,4 @@ export type AuthenticationType =

| "BasicAuthentication"
| "OAuth2ClientCredentials";
| "OAuth2ClientCredentials"
| "OAuth2UserTokenExchange";

@@ -105,0 +120,0 @@ /**

28

dist/src/apis/devspace-api-factory.js

@@ -46,6 +46,6 @@ "use strict";

});
this.ws.on("error", (error) => {
this.onError((error) => {
reject(error);
});
this.ws.on("close", (code, reason) => {
this.onClose((code, reason) => {
this.connectionOpen = false;

@@ -57,6 +57,7 @@ console.log(`connection closed ${code}, ${reason}`);

}
execute(command, ...args) {
execute(opt) {
var _a;
if (this.connectionOpen) {
const exec = command.concat(" ", ...args.join(" "), "\n");
this.ws.send(exec);
const exec = opt.command.concat(" ", ...(((_a = opt.args) === null || _a === void 0 ? void 0 : _a.join(" ")) || ""), "\n");
this.ws.send(exec, opt.cb);
}

@@ -67,2 +68,19 @@ }

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore for private func
swapCallback(event, cbName, other) {
var _a, _b;
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore for private func
const that = this;
if (that[cbName]) {
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.removeListener(event, that[cbName]);
}
that[cbName] = other;
(_b = this.ws) === null || _b === void 0 ? void 0 : _b.addListener(event, that[cbName]);
}
onError(callback) {
this.swapCallback("error", `callbackOnError`, callback);
}
onClose(callback) {
this.swapCallback("close", `callbackOnClose`, callback);
}
disconnect() {

@@ -69,0 +87,0 @@ if (this.connectionOpen) {

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

return "OAuth2ClientCredentials";
case "OAuth2UserTokenExchange":
return "OAuth2UserTokenExchange";
default:

@@ -28,0 +30,0 @@ return undefined;

@@ -15,3 +15,3 @@ /// <reference types="node" />

*/
export declare type AuthenticationType = "NoAuthentication" | "BasicAuthentication" | "OAuth2ClientCredentials";
export declare type AuthenticationType = "NoAuthentication" | "BasicAuthentication" | "OAuth2ClientCredentials" | "OAuth2UserTokenExchange";
export interface FlatDestination {

@@ -18,0 +18,0 @@ Name: string;

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

"OAuth2ClientCredentials",
"OAuth2UserTokenExchange",
];

@@ -22,0 +23,0 @@ const authenticationType = authenticationNameArr.find((element) => element === authenticationName);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// eslint-disable-next-line eslint-comments/disable-enable-pair -- ignore for testing scope
/* eslint-disable @typescript-eslint/no-explicit-any -- ignore for testing scope */
const chai_1 = require("chai");

@@ -25,4 +27,6 @@ const ws_1 = require("ws");

it("execute command without connect command", function () {
chai_1.expect(devspaceApiFactory("ws://localhost:8991").execute("ls", "-la")).to
.be.undefined;
chai_1.expect(devspaceApiFactory("ws://localhost:8991").execute({
command: "ls",
args: ["-la"],
})).to.be.undefined;
});

@@ -63,3 +67,3 @@ it("create devspace API", function () {

devspaceApi.connect("jwt").then(() => {
devspaceApi.execute(`ls`, `-la`);
devspaceApi.execute({ command: "ls", args: ["-la"] });
});

@@ -84,7 +88,5 @@ });

devspaceApi.connect("jwt").then(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- intended cast to any
chai_1.expect(devspaceApi.connectionOpen).to.be.true;
devspaceApi.execute(`ls`, `-la`);
devspaceApi.execute({ command: "ls" });
await new Promise((resolve) => setTimeout(() => resolve(""), 1000)); // 2 sec
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- intended cast to any
chai_1.expect(devspaceApi.connectionOpen).to.be.false;

@@ -106,8 +108,38 @@ done();

});
it("disconnect when ws is not initialized", function () {
chai_1.expect(devspaceApiFactory("ws://localhost:8991").disconnect()).to.be
.undefined;
it("swapCallback 'error' listener - connection closed", function () {
// create devspace api
const devspaceApi = devspaceApiFactory("ws://localhost:8990");
const cb = () => undefined;
devspaceApi["swapCallback"]("error", "callbackOnError", cb);
chai_1.expect(devspaceApi["callbackOnError"]).to.equal(cb);
const other = () => "undefined";
devspaceApi["swapCallback"]("error", "callbackOnError", other);
chai_1.expect(devspaceApi["callbackOnError"]).to.be.equal(other);
});
it("swapCallback 'close' listener", function (done) {
// create devspace api
const devspaceApi = devspaceApiFactory("ws://localhost:8989");
devspaceApi.connect("jwt").then(() => {
let onCloseOut;
const closeText = "conn closed";
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- test scope
const cb = () => {
onCloseOut = closeText;
return;
};
devspaceApi["swapCallback"]("close", "callbackOnClose", cb);
chai_1.expect(devspaceApi["callbackOnClose"]).to.equal(cb);
devspaceApi.disconnect();
setTimeout(() => {
chai_1.expect(onCloseOut).to.be.equals(closeText);
done();
}, 1000);
});
});
it("disconnect when no connection", function () {
const devspaceApi = devspaceApiFactory("ws://localhost:8989");
devspaceApi.disconnect();
});
});
});
//# sourceMappingURL=devspace-api-factory.spec.js.map

@@ -222,2 +222,12 @@ "use strict";

},
{
name: "hrtt-host",
type: "HTTP",
credentials: {
authentication: "OAuth2UserTokenExchange",
},
proxyType: "OnPremise",
description: "HRTT Host description",
host: "host",
},
];

@@ -243,2 +253,10 @@ //dont use the actual type in purpose in order to make sure we are ignore from not plan object

{
Name: "hrtt-host",
Type: "HTTP",
Authentication: "OAuth2UserTokenExchange",
ProxyType: "OnPremise",
Description: "HRTT Host description",
Host: "host",
},
{
Name: "hrtt-host2",

@@ -281,2 +299,12 @@ Type: "HTTP",

{
name: "hrtt-host",
type: "HTTP",
credentials: {
authentication: "OAuth2UserTokenExchange",
},
proxyType: "OnPremise",
description: "HRTT Host description",
host: "host",
},
{
name: "hrtt-host2",

@@ -283,0 +311,0 @@ type: "HTTP",

{
"name": "@sap/bas-sdk",
"description": "SDK for SAP Business Application Studio",
"version": "2.1.5",
"version": "3.1.0",
"main": "dist/src/index.js",

@@ -33,3 +33,3 @@ "license": "SAP",

"devDependencies": {
"@sap/bas-sdk-sinon-helper": "^2.1.5",
"@sap/bas-sdk-sinon-helper": "^3.1.0",
"@types/cross-spawn": "^6.0.2",

@@ -36,0 +36,0 @@ "@types/lodash": "^4.14.182",

@@ -12,2 +12,4 @@ import { devspaceApi } from "../../api";

private callback!: (value: string) => void;
private callbackOnError!: (e: Error) => void;
private callbackOnClose!: (code: number, reason: Buffer) => void;
private output: string;

@@ -54,7 +56,7 @@ private prompt: string;

this.ws.on("error", (error) => {
this.onError((error) => {
reject(error);
});
this.ws.on("close", (code, reason) => {
this.onClose((code, reason) => {
this.connectionOpen = false;

@@ -68,6 +70,14 @@ console.log(`connection closed ${code}, ${reason}`);

execute(command: string, ...args: string[]): void {
execute(opt: {
command: string;
args?: string[];
cb?: (err?: Error) => void;
}): void {
if (this.connectionOpen) {
const exec = command.concat(" ", ...args.join(" "), "\n");
this.ws.send(exec);
const exec = opt.command.concat(
" ",
...(opt.args?.join(" ") || ""),
"\n"
);
this.ws.send(exec, opt.cb);
}

@@ -80,2 +90,21 @@ }

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore for private func
private swapCallback(event: string, cbName: string, other: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore for private func
const that = this as any;
if (that[cbName]) {
this.ws?.removeListener(event, that[cbName]);
}
that[cbName] = other;
this.ws?.addListener(event, that[cbName]);
}
onError(callback: (e: Error) => void): void {
this.swapCallback("error", `callbackOnError`, callback);
}
onClose(callback: (code: number, reason: Buffer) => void): void {
this.swapCallback("close", `callbackOnClose`, callback);
}
disconnect(): void {

@@ -82,0 +111,0 @@ if (this.connectionOpen) {

@@ -32,2 +32,4 @@ import urljoin from "url-join";

return "OAuth2ClientCredentials";
case "OAuth2UserTokenExchange":
return "OAuth2UserTokenExchange";
default:

@@ -34,0 +36,0 @@ return undefined;

@@ -22,3 +22,4 @@ import { URL } from "url";

| "BasicAuthentication"
| "OAuth2ClientCredentials";
| "OAuth2ClientCredentials"
| "OAuth2UserTokenExchange";

@@ -109,2 +110,3 @@ export interface FlatDestination {

"OAuth2ClientCredentials",
"OAuth2UserTokenExchange",
];

@@ -111,0 +113,0 @@ const authenticationType = authenticationNameArr.find(

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