
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@crypto-connect/common
Advanced tools
This package is primarily aimed at providing most of the boilerplate needed to build integrations.
In general, it's expected for integrations to be created by extending
BaseConnectionSecure
with a custom or existing auth method.
import { BaseConnectionSecure, CryptoBalance } from "@crypto-connect/common";
import { ExampleApiKeys } from "./ExampleApiKeys";
import { ExampleBalances } from "./example-types";
/**
* Example API Base URL
*/
const BASE_URL = "https://api.example.com";
/**
* Example Request Endpoints
*/
const ENDPOINTS = {
balances: `${BASE_URL}/balances`,
};
/**
* Example Auth Methods
*/
type ExampleAuth = ExampleApiKeys;
/**
* Example API Client
*/
class ExampleConnectionSecure extends BaseConnectionSecure<ExampleAuth> {
/**
* Supply auth in constructor
*/
constructor(protected auth: ExampleAuth) {
super();
}
/**
* Get normalized list of Example balances
*/
async getBalances(): Promise<CryptoBalance[]> {
const endpoint = ENDPOINTS.accounts;
const result = await this.auth.request<ExampleBalances>(endpoint);
// convert api result to balances
// ...
return balances;
}
}
export { ExampleConnectionSecure as Example };
Integrating a service that uses OAuth is very simple - define the endpoints and the error type.
import { OAuth } from "@crypto-connect/common";
/**
* Example OAuth Base URL
*/
const BASE_URL = "https://api.example.com";
/**
* Example OAuth Endpoints
*/
const ENDPOINTS = {
authorizeUrl: `${BASE_URL}/oauth/authorize`,
tokenUrl: `${BASE_URL}/oauth/token`,
};
/**
* Service Error Response
*/
type ExampleError = { error: string };
/**
* Make authenticated requests with OAuth
*/
export class ExampleOAuth extends OAuth<ExampleError> {
endpoints = ENDPOINTS;
}
Services that use API keys are varied in their approach, so require more effort.
A signRequest
method must be defined that takes the request parameters and
credentials, and returns signed request parameters as needed.
import { ApiKeys, RequestUrl, RequestOptions } from "@crypto-connect/common";
/**
* Make authenticated requests with Api Keys
*/
export class ExampleAPIKeys extends ApiKeys<
// service credentials
{
apiKey: string;
apiSecret: string;
},
// service error response
{
error: string;
}
> {
/**
* Sign requests
*/
signRequest(
url: RequestUrl,
{ method = "GET", headers = {}, body = "" }: RequestOptions = {},
): [RequestUrl, RequestOptions] {
const { apiKey, apiSecret } = this.credentials;
// Generate a signature and sign the request
// ...
return [url, { method, headers, body }];
}
}
FAQs
CryptoConnect common files
We found that @crypto-connect/common demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.