![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
JWT Authentication Strategy, JWT issuer and API Keys/Tokens generator.
npm install @c8/auth
Check the /examples
folder.
new AuthStrategy(options)
Creates a new Authentication Strategy with a secret. It exposes a series of functions that depend upon that secret.
options
is an object literal containing options to control how the token is extracted from the request or verified.
secretOrKey
(REQUIRED): string or buffer containing the secret (symmetric) or PEM-encoded public key (asymmetric) for verifying the token's signature;verify
(REQUIRED): is a function with the parameters verify(jwtPayload, done)
where jwtPayload
is an object literal containing the decoded JWT payload and done
is a passport error first callback accepting arguments done(error, user, info);jwtFromRequest
: Function that accepts a request as the only parameter and returns either the JWT as a string or null. See Extracting the JWT from the request for more details;issuer
: If defined the token issuer (iss) will be verified against this value;audience
: If defined, the token audience (aud) will be verified against this value. This should not be setup if you're using APIKeys;algorithms
: List of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"];ignoreExpiration
: if true do not validate the expiration of the token;passReqToCallback
: If true the request will be passed to the verify
callback. i.e. verify(request, jwt_payload, done_callback)
;auth.issueToken(payload, opts, callback)
Returns a new JWT string signed with the AuthStrategy
instance secret.
payload
(REQUIRED): the payload to be added to the token. Also a jti
property is set to a UUID to allow for token revoking;opts
: any option accepted by jsonwebtoken#sign;callback
: if callback is not passed, the function is run synchronously and return the JWT as string;auth.generateApiKey()
Returns an object with apiId
(32 chars alphanumeric) and apiKey
(64 chars alphanumeric) pair.
auth.issueTokenForApiKey(credentials, payload, opts, callback)
Returns a new JWT string signed with the AuthStrategy
instance secret for the given credentials. The credentials.apiId
is added to the payload.
credentials
(REQUIRED): an object with apiId
and apiKey
properties;payload
(REQUIRED): the payload to be added to the token. Also a jti
property is set to a UUID to allow for token revoking;opts
: any option accepted by jsonwebtoken#sign;callback
: if callback is not passed, the function is run synchronously and return the JWT as string;The following commands are available:
coverage
for running code coverage with Istanbul (it shows the report at the bottom)standard
for code style checks with Standardjstest
for running Mocha testsThis module adheres to semver versioning. That means that given a version number MAJOR.MINOR.PATCH, we increment the:
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
The MIT License
Copyright (c) 2016 C8 MANAGEMENT LIMITED
FAQs
JWT Authentication Strategy, JWT issuer and API Keys/Tokens generator.
The npm package @c8/auth receives a total of 2 weekly downloads. As such, @c8/auth popularity was classified as not popular.
We found that @c8/auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.