Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.