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

oso-cloud

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oso-cloud - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

package.json
{
"name": "oso-cloud",
"version": "0.1.0",
"version": "0.2.0",
"description": "Client library for Oso Cloud",

@@ -8,8 +8,4 @@ "main": "src/client.js",

"scripts": {
"test": "jest"
"test": "node ./src/client.test.js"
},
"license": "ISC",
"devDependencies": {
"jest": "^27.0.4"
},
"dependencies": {

@@ -16,0 +12,0 @@ "node-fetch": "^2.6.7"

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

const http = require("http");
const { URLSearchParams } = require("url");

@@ -27,7 +26,8 @@ const fetch = require("node-fetch");

class Oso {
constructor(serviceUrl) {
if (typeof serviceUrl !== "string" && serviceUrl !== undefined)
throw new TypeError(`'serviceUrl' should be a string: ${action}`);
constructor(url, apiKey) {
if (typeof url !== "string" && url !== undefined)
throw new TypeError(`'url' should be a string: ${action}`);
this.serviceUrl = serviceUrl || "http://localhost:8080";
this.url = url || "https://cloud.osohq.com";
this.token = apiKey
}

@@ -115,10 +115,11 @@

GET(path, query) {
let url = `${this.serviceUrl}/${path}`;
let url = `${this.url}/api/${path}`;
if (query) url += `?${new URLSearchParams(query)}`;
return fetch(url).then((res) => res.json());
const headers = { "Authorization": `Basic ${this.token}`};
return fetch(url, headers).then((res) => res.json());
}
POST(path, body) {
let url = `${this.serviceUrl}/${path}`;
const headers = { "Content-Type": "application/json" };
let url = `${this.url}/api/${path}`;
const headers = { "Content-Type": "application/json", "Authorization": `Basic ${this.token}` };
return fetch(url, {

@@ -132,4 +133,4 @@ method: "POST",

DELETE(path, body) {
let url = `${this.serviceUrl}/${path}`;
const headers = { "Content-Type": "application/json" };
let url = `${this.url}/api/${path}`;
const headers = { "Content-Type": "application/json", "Authorization": `Basic ${this.token}` };
return fetch(url, {

@@ -136,0 +137,0 @@ method: "DELETE",

@@ -0,1 +1,5 @@

// To run the tests you must first start the service locally in test mode.
// cargo run -- run --test-mode
// That loads in the test user so the tests can run.
const { Oso } = require("./client.js");

@@ -16,28 +20,33 @@ const assert = require("assert");

it("works", async () => {
const oso = new Oso("http://localhost:8080");
const user1 = new User(1);
const repo2 = new Repo(2);
const repo3 = new Repo(3);
(async () => {
try {
const oso = new Oso("http://localhost:8080","b3NvX3Rlc3RfdXNlcjpvc29fdGVzdF90b2tlbg==");
const user1 = new User(1);
const repo2 = new Repo(2);
const repo3 = new Repo(3);
// Clear out any existing roles/relations
await oso.deleteRelation(repo2, "parent", repo3);
await oso.deleteRole(user1, "member", repo2);
// Clear out any existing roles/relations
await oso.deleteRelation(repo2, "parent", repo3);
await oso.deleteRole(user1, "member", repo2);
const authorize = await oso.authorize(user1, "read", repo2);
assert.strictEqual(authorize, false);
const authorize = await oso.authorize(user1, "read", repo2);
assert.strictEqual(authorize, false);
const list = await oso.list(user1, "read", Repo);
assert(Array.isArray(list) && list.length === 0);
const list = await oso.list(user1, "read", Repo);
assert(Array.isArray(list) && list.length === 0);
await oso.addRelation(repo2, "parent", repo3);
await oso.addRole(user1, "member", repo2);
await oso.deleteRelation(repo2, "parent", repo3);
//await oso.addRelation(repo2, "parent", repo3);
//await oso.deleteRelation(repo2, "parent", repo3);
const roles = await oso.getRoles(user1, "member", repo2);
console.log("roles", roles);
assert(Array.isArray(roles) && roles.length === 1);
const role = roles[0];
assert(role.role === "member");
await oso.deleteRole(user1, "member", repo2);
});
// await oso.addRole(user1, "member", repo2);
// const roles = await oso.getRoles(user1, "member", repo2);
// console.log("roles", roles);
// assert(Array.isArray(roles) && roles.length === 1);
// const role = roles[0];
// assert(role.role === "member");
// await oso.deleteRole(user1, "member", repo2);
} catch (e) {
console.error(e);
process.exitCode = 1;
}
})();
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