Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
@elastic.io/odata-library
Advanced tools
Contains methods to authenticate, make requests to OData APIs and build API entities json schema.
OdataClient class got most common methods for odata client
const restClient = new NoAuthRestClient(emitter, cfg);
const keys = [{
name: 'id',
required: false,
type: 'Edm.Int64',
wrapValueInQuotesInUrls: false,
}];
const odataClient = new ODataClient(cfg, restClient, keys);
Methods makes request with set rest client to 'baseUrl/$metadata' address and returns result as string
const result = await odataClient.getMetadata();
Methods makes request with set rest client to 'baseUrl/${this.cfg.objectType}'. Returns all object for provided object type. Be careful: this method DOES NOT support pagination.
const result = await odataClient.getAll();
Method to make polling request to odata API. Uses deltaLink fetch that may not be supported.
{
"deltaLink": "https://someDeltalink.com/with/details"
}
This method does NOT emitting snapshot by itself.
const result = await odataClient.getObjectsPollingByDeltaLink(snapshot);
Method get entities by PK value.
object - object, which contains entity with PK values
objectType - object Type For example:
object has unique key id
const result = await odataClient.getObjectById(id, 'Customer');
const result = await odataClient.getObjectById({No: 3}, 'Customer');
Method makes POST request to insert entity.
const result = await odataClient.postObject(object, 'Customer');
Method makes PUT request to update entity by PK.
const result = await odataClient.putObject(object, 'Customer');
Method makes PATCH request to update entity fields by PK.
const result = await odataClient.patchObject(object, 'Customer');
Method to upsert (update or, if not found, create) entity.
const result = await odataClient.upsertObjectById(object, 'Customer', 'PUT');
Method remove entities by PK value.
For example:
const result = await odataClient.deleteObjectById({id: 2}, 'Customer');
const result = await odataClient.deleteObjectById({No: 3}, 'Customer');
Method remove entities by PK value.
const result = await odataClient.deleteObjectsByCriteria(criteria, eTag, 'Customer');
Classes to make requests to restricted resources
NoAuthRestClient class to make rest requests no no auth APIs by provided options. Uses promisify(require('request')) library to make REST requests.
const Client = new NoAuthRestClient(emitter, cfg);
Makes requests: options expects the following sub-variables:
BasicAuthRestClient class extends NoAuthRestClient class. Makes requests to resource with basic auth.
const Client = new BasicAuthRestClient(emitter, cfg, user, pass);
ApiKeyRestClient class extends NoAuthRestClient class. Makes requests to resource with api key (custom header) auth.
const Client = new BasicAuthRestClient(emitter, cfg, user, pass);
OAuth2RestClient class extends NoAuthRestClient class. Makes requests to resource with oauth2 access token auth.
const Client = new OAuth2AuthorizationCodeRestClient(emitter, cfg);
This class can handle, refresh and emit oauth2 EIO configuration.
Classes and methods to generate json schemas and EIO io metadata
MetadataBuilder class can generate EIO io metadata for most common actions and triggers. Requires CsdlConverter class to process csdl. All fields except PKs is not required in input metadata.
const converter = await new CsdlConverter(inputCsdl).build();
const metadataBuilder = new MetadataBuilder(converter, 10);
Method returns resource list can be used in EIO getObjects method as action resource map.
const result = metadataBuilder.getObjectsNamingList();
Method returns get metadata for chosen objectType for polling trigger. Has no 'in' metadata, PK is required for output.
const result = metadataBuilder.getTriggerMetadata('Entity');
Method returns metadata by chosen objectType for 'getById' action. 'in' metadata has required PK only.
const result = metadataBuilder.getByIdMetadata('Entity');
Method returns metadata by chosen objectType for POST action. 'in' metadata has required PK.
const result = metadataBuilder.getPostMetadata('Entity');
Method returns metadata by chosen objectType for PUT action. 'in' metadata not expected PK.
const result = metadataBuilder.getPutMetadata('Entity');
Method returns metadata by chosen objectType for upsert action. 'in' metadata expected but not required PK.
const result = metadataBuilder.getUpsertMetadata('Entity');
Method returns metadata by chosen objectType for DELETE action. 'in' and 'out' metadata contains required PK only.
const result = metadataBuilder.getDeleteMetadata('Entity');
CsdlConverter lass can process OData csdl by input string or resource url
CsdlConverter class builder Can be used in 2 ways:
await new CsdlConverter(inputCsdl).build();
- to build converter by input csdl stringawait new CsdlConverter().buildByMetadataUrl('https://example.net/$metadata');
- to build converter by data from csdl resourceMethod to get list of entities can be used as resources in component with their primary keys description:
const converter = await new CsdlConverter(inputCsdl).build();
const result = converter.getResourcesList();
Result sample:
[
{
"name": "Products",
"keys": [
{
"required": true,
"name": "ID",
"wrapValueInQuotesInUrls": false,
"type": "Edm.Int32"
}
]
}
...
]
Method to get object contains raw json schema (with unresolved $ref(s)) and PKs list for chosen entity. Throws an error if no such entity name in json schema or found more than one entity with same name.
const converter = await new CsdlConverter(inputCsdl).build();
const result = converter.convertCsdlString('Entity');
Method resolve all refs in provided json schema.
const converter = await new CsdlConverter(inputCsdl).build();
const result = converter.convertCsdlString('Entity');
const jsonSchema = converter.resolveMetadataRefs(result.jsonSchema, 8);
FAQs
Re-usable OData client library
We found that @elastic.io/odata-library demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers 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.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.