
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@simpleview/auth-client
Advanced tools
Client for communicating with sv-auth
npm install @simpleview/auth-client
Add the token from the header into your context.
const { getTokenFromHeaders } = require("@simpleview/auth-client");
const server = new ApolloServer({
...
context: ({ req }) => {
return {
...
token : getTokenFromHeaders(req.headers)
};
}
});
In a resolver utilize AuthClient.getUser() to convert that token into a user. If you look at the sv-auth project you can see an example of this pattern. In that project TODO ADD URL, admin requires an acct_id and all child-resolvers will have the user already attached to the context.
AuthClient is a class for converting a token and an acct_id into an auth_user with permissions.
const { AuthClient } = require("@simpleview/auth-client");
// the GRAPH_URL is the graphQL server that you wish to communicate with. Get the proper URL from the sv-auth repository to align with the appropriate live/dev/staging resource.
const authClient = new AuthClient({ graphUrl : GRAPH_URL });
This method wraps the call to auth.users_current in a caching layer to ensure that it's optimal performance and is properly updating if a user's permissions have changed.
Generally you will want to make this call very early in your GraphQL stack in order to make the user available on context for all calls to access.
Returns auth_user.
const user = authClient.getUser({
token,
acct_id : "0"
});
If you are finished with an AuthClient instance, call authClient.close() in order to shut it down. Generally this is only needed in unit tests, otherwise there is an internal setInterval which will keep the process open.
Extracts the token from the authorization header.
const { getTokenFromHeaders } = require("@simpleview/auth-client");
const server = new ApolloServer({
...
context: ({ req }) => {
return {
token : getTokenFromHeaders(req.headers)
};
}
});
GraphServer is an API interface to communicate with the auth/admin system's graphQL server to make it a little bit easier to call the various methods.
acct_id is required for any endpoints on admin.If you need to set the context at run-time, you can manually update the context via setting graphServer.context.acct_id = "x". You cannot set the context key to a new object or it will not function, manually updated or Object.assign you're changes in.
const { GraphServer } = require("@simpleview/auth-client");
// the GRAPH_URL is the graphQL server that you wish to communicate with. Get the proper URL from the sv-auth repository to align with the appropriate live/dev/staging resource.
const graphServer = new GraphServer({
graphUrl : GRAPH_URL
});
The easiest way to find the endpoints on GraphServer is to either check the src/graphql or simply new the instance and console log.
Examples
const result = await graphServer.users.login({
email : "x",
password : "y",
fields : "success message"
});
const result = await graphServer.roles.find({
filter : {
acct_id : "0"
},
fields : `
docs {
id
name
...
}
count
`
});
For the available fields on each call you can reference the GraphQL schema via the schema browser.
FAQs
Client for communicating with sv-auth
The npm package @simpleview/auth-client receives a total of 3 weekly downloads. As such, @simpleview/auth-client popularity was classified as not popular.
We found that @simpleview/auth-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.