jfrog-client-js
Advanced tools
Comparing version 2.6.2 to 2.6.3
@@ -5,2 +5,3 @@ import { IUsageFeature } from './UsageFeature'; | ||
features: IUsageFeature[]; | ||
uniqueClientId?: string; | ||
} |
@@ -6,5 +6,6 @@ import { ArtifactorySystemClient } from './ArtifactorySystemClient'; | ||
export declare class ArtifactoryClient { | ||
private readonly clientId?; | ||
private readonly httpClient; | ||
private logger; | ||
constructor(config: IClientSpecificConfig); | ||
constructor(config: IClientSpecificConfig, clientId?: string | undefined); | ||
system(): ArtifactorySystemClient; | ||
@@ -11,0 +12,0 @@ search(): ArtifactorySearchClient; |
@@ -10,3 +10,4 @@ "use strict"; | ||
class ArtifactoryClient { | ||
constructor(config) { | ||
constructor(config, clientId) { | ||
this.clientId = clientId; | ||
const { serverUrl, logger = console, username, password, accessToken, proxy, headers, retries, } = config; | ||
@@ -20,3 +21,3 @@ if (!serverUrl) { | ||
system() { | ||
return new ArtifactorySystemClient_1.ArtifactorySystemClient(this.httpClient, this.logger); | ||
return new ArtifactorySystemClient_1.ArtifactorySystemClient(this.httpClient, this.logger, this.clientId); | ||
} | ||
@@ -23,0 +24,0 @@ search() { |
@@ -7,6 +7,7 @@ import { IArtifactoryVersion, IUsageFeature } from '../../model'; | ||
private readonly logger; | ||
private readonly clientId?; | ||
private readonly pingEndpoint; | ||
private readonly versionEndpoint; | ||
private readonly usageEndpoint; | ||
constructor(httpClient: HttpClient, logger: ILogger); | ||
constructor(httpClient: HttpClient, logger: ILogger, clientId?: string | undefined); | ||
ping(): Promise<boolean>; | ||
@@ -13,0 +14,0 @@ version(): Promise<IArtifactoryVersion>; |
@@ -6,5 +6,6 @@ "use strict"; | ||
class ArtifactorySystemClient { | ||
constructor(httpClient, logger) { | ||
constructor(httpClient, logger, clientId) { | ||
this.httpClient = httpClient; | ||
this.logger = logger; | ||
this.clientId = clientId; | ||
this.pingEndpoint = '/api/system/ping'; | ||
@@ -41,2 +42,3 @@ this.versionEndpoint = '/api/system/version'; | ||
features: featureArray, | ||
uniqueClientId: this.clientId, | ||
}; | ||
@@ -43,0 +45,0 @@ const requestParams = { |
@@ -0,4 +1,6 @@ | ||
/// <reference types="node" /> | ||
import { IJfrogClientConfig } from '../model/JfrogClientConfig'; | ||
import { XrayClient } from './Xray/XrayClient'; | ||
import { ArtifactoryClient } from './Artifactory/ArtifactoryClient'; | ||
import * as os from 'os'; | ||
export declare class JfrogClient { | ||
@@ -8,2 +10,3 @@ private _jfrogConfig; | ||
private static readonly XRAY_SUFFIX; | ||
readonly clientId?: string; | ||
constructor(_jfrogConfig: IJfrogClientConfig); | ||
@@ -21,2 +24,4 @@ artifactory(): ArtifactoryClient; | ||
private static addTrailingSlashIfMissing; | ||
static getClientId(interfaces: (os.NetworkInterfaceBase[] | undefined)[]): string | undefined; | ||
private static hash; | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,2 +32,4 @@ exports.JfrogClient = void 0; | ||
const ArtifactoryClient_1 = require("./Artifactory/ArtifactoryClient"); | ||
const os = __importStar(require("os")); | ||
const crypto_1 = __importDefault(require("crypto")); // Important - Don't import '*'. It'll import deprecated encryption methods | ||
class JfrogClient { | ||
@@ -13,5 +41,6 @@ constructor(_jfrogConfig) { | ||
} | ||
this.clientId = JfrogClient.getClientId(Object.values(os.networkInterfaces())); | ||
} | ||
artifactory() { | ||
return new ArtifactoryClient_1.ArtifactoryClient(this.getSpecificClientConfig(JfrogClient.ARTIFACTORY_SUFFIX, this._jfrogConfig.artifactoryUrl)); | ||
return new ArtifactoryClient_1.ArtifactoryClient(this.getSpecificClientConfig(JfrogClient.ARTIFACTORY_SUFFIX, this._jfrogConfig.artifactoryUrl), this.clientId); | ||
} | ||
@@ -43,2 +72,15 @@ xray() { | ||
} | ||
static getClientId(interfaces) { | ||
for (const networkInterfaces of interfaces) { | ||
for (const networkInterface of networkInterfaces !== null && networkInterfaces !== void 0 ? networkInterfaces : []) { | ||
if (networkInterface.mac) { | ||
return this.hash('sha1', networkInterface.mac); | ||
} | ||
} | ||
} | ||
return undefined; | ||
} | ||
static hash(algorithm, data) { | ||
return crypto_1.default.createHash(algorithm).update(data).digest('hex'); | ||
} | ||
} | ||
@@ -45,0 +87,0 @@ exports.JfrogClient = JfrogClient; |
{ | ||
"name": "jfrog-client-js", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"description": "JFrog Javascript Client is a javascript library, which wraps some of the REST APIs exposed by JFrog Services's different services.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
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
104879
1433