Socket
Socket
Sign inDemoInstall

@microtica/code-repository

Package Overview
Dependencies
108
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 1.0.0

8

js/bitbucket.d.ts

@@ -1,7 +0,7 @@

/// <reference types="node" />
import { CodeRepository, RepoCredentials, Repository, RepoVersion, RepositoryTeam } from "./code-repository";
import { CodeRepository, Repository, RepoVersion, RepositoryTeam } from "./code-repository";
export declare class Bitbucket implements CodeRepository {
private credentials;
private accessToken;
private baseUrl;
constructor(credentials: RepoCredentials);
private headers;
constructor(accessToken: string);
listTeams(): Promise<RepositoryTeam[]>;

@@ -8,0 +8,0 @@ listRepositories(): Promise<Repository[]>;

@@ -10,7 +10,8 @@ "use strict";

class Bitbucket {
constructor(credentials) {
this.credentials = credentials;
if (credentials.authType !== 'BASIC')
throw new Error("Only BASIC authorization method is supported at this moment");
this.baseUrl = `https://${this.credentials.username}:${this.credentials.password}@api.bitbucket.org/2.0`;
constructor(accessToken) {
this.accessToken = accessToken;
// if (credentials.authType !== 'BASIC')
// throw new Error("Only BASIC authorization method is supported at this moment");
this.baseUrl = `https://bitbucket.org`;
this.headers = { Authorization: `Bearer ${accessToken}` };
}

@@ -21,2 +22,3 @@ listTeams() {

url: `${this.baseUrl}/teams?role=member&pagelen=100`,
headers: this.headers,
json: true

@@ -49,3 +51,3 @@ }, (err, response) => {

const url = `${this.baseUrl}/repositories/${account}?page=${page}&pagelen=${pagelen}`;
const response = await rp.get({ url, json: true });
const response = await rp.get({ url, json: true, headers: this.headers });
const repos = response.values.map((repo) => ({

@@ -64,4 +66,4 @@ name: repo.name,

async listPrivateRepositories() {
const url = `${this.baseUrl}/repositories/${this.credentials.username}`;
const response = await rp.get({ url, json: true });
const url = `${this.baseUrl}/repositories`;
const response = await rp.get({ url, json: true, headers: this.headers });
const repos = response.values.map((repo) => ({

@@ -78,3 +80,4 @@ name: repo.name,

url: `${this.baseUrl}/repositories${repoName}/refs/tags?pagelen=100`,
json: true
json: true,
headers: this.headers
}, (err, response) => {

@@ -105,3 +108,5 @@ if (err)

});
request(`https://${this.credentials.username}:${this.credentials.password}@bitbucket.org/${repoName}/get/${version}.zip`).pipe(stream);
request(`${this.baseUrl}/${repoName}/get/${version}.zip`, {
headers: this.headers
}).pipe(stream);
archive.pipe(output);

@@ -108,0 +113,0 @@ stream.pipe(unzip.Parse())

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

/// <reference types="node" />
export declare enum RepoCredentialsType {

@@ -3,0 +2,0 @@ BASIC = 0,

{
"name": "@microtica/code-repository",
"version": "0.2.0",
"version": "1.0.0",
"description": "Integration module with git repository providers",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc