
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@janiscommerce/api-session
Advanced tools
A session manager for APIs
npm install @janiscommerce/api-session
The package exports two classes ApiSession and ApiSessionError.
constructor(authorizationData, client)
Creates an APISession with the authorizationData
provided or the client
for direct injection.
authorizationData
is an opcional object with the following (also optional) properties: { userId, clientId, clientCode, profileId, permissions, locations, hasAccessToAllLocations }client
is an opcional object for client injection without performing any DB getsvalidateLocation(locationId)
Validate if the location given is valid for the session. Returns Boolean.
ApiSession has the following getters:
getInstance()
method injected. The properties depend on your client internal structure. The client is injected with a getInstance()
method to propagate the session to other instances.The package uses the Client Model in our service for getting the clients. For more information see @janiscommerce/model
const { ApiSession, ApiSessionError } = require('@janiscommerce/api-session');
const { ApiSession } = require('@janiscommerce/api-session');
const SomeModel = require('../models/some-model');
const session = new ApiSession({
userId: 1,
userIsDev: false,
clientId: 2,
clientCode: 'janis',
profileId: 5,
permissions: [
'catalog:product:read',
'catalog:product:write'
],
locations: ['location-1'],
hasAccessToAllLocations: false
});
console.log(`Session created for user ${session.userId} on client ${session.clientCode}.`);
const sessionInjectedModel = session.getSessionInstance(SomeModel, 'some-param', 'some-other-param');
console.log(`Session is propagated for user ${sessionInjectedModel.session.userId} on client ${sessionInjectedModel.session.clientCode}.`);
const client = await sessionInjectedModel.session.client;
console.log(client);
// Outputs your client object
const hasAccess = session.validateLocation('location-1');
console.log(`Session has access to location 1: ${hasAccess}`);
// Outputs 'Session has access to location 1: true'
[3.1.1] - 2021-01-27
FAQs
A session manager for APIs
The npm package @janiscommerce/api-session receives a total of 332 weekly downloads. As such, @janiscommerce/api-session popularity was classified as not popular.
We found that @janiscommerce/api-session 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.