
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@authefy/node-client
Advanced tools
An Authefy software development kit for javascript. Simplifies the use of Authefy endpoints by providing set of libraries that are familiar for javascript developers. It also supports cross-runtime client service that can run on browser and Node.js server without code change.
npm run build
transpiles the *.ts
from src
to build
and updates dist
files
To use with node:
$ npm install @authefy/server-client;
Then import sdk:
import * as authefy from package;
ServerClient
Works only in NodeJS runtime. Handles functions for client's server side.
opt
<Object>
appId
<string> application id (required)appKey
<string> appliction secret key (required)import { ServerClient } from <package>
const authefyServerClient = new ServerClient({
appId: 'app123', appKey: 'shh'
});
input
<Object>
username
<string> (required)password
<string> (required)externalId
<string> user reference under applicationgroups
<string[]> groups id in arraydetails
<Object> user additional informationReturns:<Promise> Fufills with <User> upon success.
await authefyServerClient.user.create({
username: 'john', password: 'doe'
})
// [Object] User
id
<string> user id to update
input
<Object>
password
<string>isVerified
<boolean>groups
<string[]>details
<Object> user reference under applicationReturns:<Promise> Fufills with boolean
upon success.
await authefyServerClient.user.update(
'user123',
{
details: { name: 'johndoe' }
}
)
// true
id
<string> user id to delete
Returns:<Promise> Fufills with boolean
upon success.
await authefyServerClient.user.delete('user123')
// true
Method: authenticate(input)
input
<Object>
oneOf
<Object> (required)
grantType
<'bitclout'>
token
<string>publicKey
<string>grantType
<'password'>
username
<string>password
<string>grantType
<'refreshToken'>
refreshToken
<string>Returns: <Promise> Fufills with { accessToken: string; refreshToken?: string; expiresIn: number; }
upon success.
await authefyServerClient.token.authenticate({
grantType: 'bitclout',
})
await authefyServerClient.token.authenticate({
grantType: 'password',
username: 'john',
password: 'doe'
})
await authefyServerClient.token.authenticate({
grantType: 'refreshToken',
refreshToken: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MjEyNTYxNDMsImV4cCI6MTYyMTI1NjIwM30.uc8aXYsWsHZsF-62vKgIEqq8jw_K2bkhIgxB6FadUG-C_Lcl5F-66rRotSWm4_lsaStQ1pJjeRAUMvDh3ikz4g'
})
// { accessToken: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MjEyNTYxNDMsImV4cCI6MTYyMTI1NjIwM30.uc8aXYsWsHZsF-62vKgIEqq8jw_K2bkhIgxB6FadUG-C_Lcl5F-66rRotSWm4_lsaStQ1pJjeRAUMvDh3ikz4g', refreshToken: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MjEyNTYxNDMsImV4cCI6MTYyMTI1NjIwM30.uc8aXYsWsHZsF-62vKgIEqq8jw_K2bkhIgxB6FadUG-C_Lcl5F-66rRotSWm4_lsaStQ1pJjeRAUMvDh3ikz4g', expiresIn: 60000 }
Method: revoke(input)
input
<Object>
refreshToken
<string> (required)Returns: <Promise> Fufills with boolean
upon success.
await authefyServerClient.token.revoke({
refreshToken: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MjEyNTYxNDMsImV4cCI6MTYyMTI1NjIwM30.uc8aXYsWsHZsF-62vKgIEqq8jw_K2bkhIgxB6FadUG-C_Lcl5F-66rRotSWm4_lsaStQ1pJjeRAUMvDh3ikz4g'
})
// true
Method: authorizeBearer(authorization)
authorization
<string> authorization token starts with Bearer
;
Returns: <Promise> Fufills with { id: string; externalId?: string; iat: number; exp: number; sub: string }
upon success.
await authefyServerClient.token.authorizeBearer('Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MjEyNTYxNDMsImV4cCI6MTYyMTI1NjIwM30.uc8aXYsWsHZsF-62vKgIEqq8jw_K2bkhIgxB6FadUG-C_Lcl5F-66rRotSWm4_lsaStQ1pJjeRAUMvDh3ikz4g')
// { id: '', externalId: '', iat: 1621401772134, exp: 1621401772134, sub: '' }
Method: listen(options)
options
<Object>
startFromLastEventCursor
<string | false | null>type
<'UserCreated' | 'UserUpdated' | 'UserDeleted'>reconnect
<boolean>Returns: <Promise> Fufills with <EventEmitter> upon success.
emitter.on('data', callback)
emitter.on('UserCreated' | 'UserUpdated' | 'UserDeleted', callback)
const emitter = await authefyServerClient.event.listen({
startFromLastEventCursor: false,
type: 'UserCreated'
reconnect: false,
})
emitter.on('data', event => /* process event */)
// or
emitter.on('UserCreated', event => /* process event */)
emitter.on('UserUpdated', event => /* process event */)
emitter.on('UserDeleted', event => /* process event */)
Method: fetch(params)
params
<Object>
filter
<Object>
type
: <'UserCreated' | 'UserUpdated' | 'UserDeleted'>sort
<ASC | DESC>size
<number>after
<string>before
<string>Returns: <Promise> Fufills with { edges: { UserEvent, cursor: string }[], endCursor?: string, totalCount: number }
upon success.
await authefyServerClient.token.fetch({})
User
id
<string>externalId
<string>username
<string>password
<string>groups
<string[]>details
<Object>isEmailVerified
<boolean>isVerified
<boolean>UserEvent
id
<string>user
<string>externalId
<string>application
<string>dateTimeCreated
<Date>cursor
<string>type
<'UserCreated' | 'UserUpdated' | 'UserDeleted'>body
<Object>FAQs
Authefy NodeJS SDK
The npm package @authefy/node-client receives a total of 18 weekly downloads. As such, @authefy/node-client popularity was classified as not popular.
We found that @authefy/node-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 CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.