fastify-tokenize
Advanced tools
Comparing version 1.1.3 to 1.2.0
/* | ||
* Copyright (c) 2020 Bowser65, All rights reserved. | ||
* Copyright (c) 2020 Cynthia K. Rey, All rights reserved. | ||
* | ||
@@ -28,4 +28,4 @@ * Redistribution and use in source and binary forms, with or without | ||
import Tokenize from 'node-tokenize' | ||
import { FastifyPlugin } from 'fastify' | ||
import Tokenize from '@cyyynthia/tokenize' | ||
import { FastifyPluginCallback } from 'fastify' | ||
@@ -54,3 +54,3 @@ declare namespace FastifyTokenize { | ||
declare const fastifyTokenize: FastifyPlugin<FastifyTokenize.Options | FastifyTokenize.OptionsAuth> | ||
declare const fastifyTokenize: FastifyPluginCallback<FastifyTokenize.Options | FastifyTokenize.OptionsAuth> | ||
export default fastifyTokenize |
/* | ||
* Copyright (c) 2020 Bowser65, All rights reserved. | ||
* Copyright (c) 2020 Cynthia K. Rey, All rights reserved. | ||
* | ||
@@ -28,4 +28,4 @@ * Redistribution and use in source and binary forms, with or without | ||
const Tokenize = require('@cyyynthia/tokenize') | ||
const fp = require('fastify-plugin') | ||
const Tokenize = require('node-tokenize') | ||
@@ -127,2 +127,2 @@ function fastifyTokenize (fastify, options, next) { | ||
module.exports = fp(fastifyTokenize, { fastify: '>= 1', name: 'fastify-tokenize' }) | ||
module.exports = fp(fastifyTokenize, { fastify: '>= 3', name: 'fastify-tokenize' }) |
{ | ||
"name": "fastify-tokenize", | ||
"version": "1.1.3", | ||
"description": "A fastify plugin to add Tokenize support through a decorator", | ||
"version": "1.2.0", | ||
"description": "A fastify plugin to add Tokenize support through a decorator.", | ||
"main": "index.js", | ||
"repository": "https://github.com/Bowser65/fastify-tokenize", | ||
"author": "Bowser65 <bowoser@weeb.services>", | ||
"author": "Cynthia <cynthia@cynthia.dev>", | ||
"license": "BSD-3-Clause", | ||
"scripts": { | ||
"lint": "eslint --ext js --ext jsx .", | ||
"lint": "eslint .", | ||
"test": "jest test.js" | ||
}, | ||
"dependencies": { | ||
"fastify-plugin": "^1.6.1", | ||
"node-tokenize": "^1.0.6" | ||
"@cyyynthia/tokenize": "^1.1.1", | ||
"fastify-plugin": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.8.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint": "^7.14.0", | ||
"eslint-config-standard": "^16.0.2", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"fastify": "^2.15.0", | ||
"jest": "^26.0.1" | ||
"eslint-plugin-standard": "^4.1.0", | ||
"fastify": "^3.8.0", | ||
"jest": "^26.6.3" | ||
} | ||
} |
# fastify-tokenize | ||
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/G2G71TSDF)<br> | ||
[![License](https://img.shields.io/github/license/Bowser65/fastify-tokenize.svg?style=flat-square)](https://github.com/Bowser65/fastify-tokenize/blob/master/LICENSE) | ||
[![License](https://img.shields.io/github/license/Bowser65/fastify-tokenize.svg?style=flat-square)](https://github.com/Bowser65/fastify-tokenize/blob/mistress/LICENSE) | ||
![CI](https://github.com/Bowser65/fastify-tokenize/workflows/ci/badge.svg) | ||
An extremely tiny plugin for Fastify for [node-tokenize](https://npm.im/node-tokenize). Allows you to share the same | ||
An extremely tiny plugin for Fastify for [@cyyynthia/tokenize](https://npm.im/@cyyynthia/tokenize). Allows you to share the same | ||
instance of Tokenize on every part of your server. | ||
@@ -12,3 +12,3 @@ | ||
Tokenize leverages the pain of generating secure tokens and makes it easy to issue and validate tokens in your | ||
Tokenize removes the pain of generating secure tokens and makes it easy to issue and validate tokens in your | ||
application. | ||
@@ -18,9 +18,4 @@ | ||
``` | ||
With PNPM: | ||
pnpm i fastify-tokenize | ||
With Yarn: | ||
yarn add fastify-tokenize | ||
With NPM: | ||
npm i fastify-tokenize | ||
@@ -47,3 +42,4 @@ ``` | ||
account ID as unique argument and should the user account (or a promise resolving to a user account). The only | ||
required property is `tokensValidSince` which is used to invalidate tokens generated prior this date. | ||
required property is `lastTokenReset` (or `last_token_reset`) which is used to invalidate tokens generated prior | ||
this date. | ||
@@ -50,0 +46,0 @@ ```js |
12
test.js
/* | ||
* Copyright (c) 2020 Bowser65, All rights reserved. | ||
* Copyright (c) 2020 Cynthia K. Rey, All rights reserved. | ||
* | ||
@@ -31,3 +31,3 @@ * Redistribution and use in source and binary forms, with or without | ||
const Fastify = require('fastify') | ||
const Tokenize = require('node-tokenize') | ||
const Tokenize = require('@cyyynthia/tokenize') | ||
const fastifyTokenize = require('./index') | ||
@@ -173,3 +173,3 @@ let fastify | ||
it('should go through if the token is valid', async function () { | ||
register({ fastifyAuth: true, fetchAccount: () => ({ tokensValidSince: 0 }) }) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ lastTokenReset: 0 }) }) | ||
await fastify.ready() | ||
@@ -183,3 +183,3 @@ | ||
it('should target the right cookie', async function () { | ||
register({ fastifyAuth: true, fetchAccount: () => ({ tokensValidSince: 0 }), cookie: 'rawr' }) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ lastTokenReset: 0 }), cookie: 'rawr' }) | ||
await fastify.ready() | ||
@@ -202,3 +202,3 @@ | ||
expect.assertions(1) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ tokensValidSince: 0 }), cookieSigned: true }) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ lastTokenReset: 0 }), cookieSigned: true }) | ||
await fastify.ready() | ||
@@ -215,3 +215,3 @@ | ||
expect.assertions(1) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ tokensValidSince: 0 }) }) | ||
register({ fastifyAuth: true, fetchAccount: () => ({ lastTokenReset: 0 }) }) | ||
await fastify.ready() | ||
@@ -218,0 +218,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
172089
8
77
+ Added@cyyynthia/tokenize@^1.1.1
+ Added@cyyynthia/tokenize@1.1.3(transitive)
+ Addedfastify-plugin@3.0.1(transitive)
- Removednode-tokenize@^1.0.6
- Removedfastify-plugin@1.6.1(transitive)
- Removednode-tokenize@1.0.6(transitive)
- Removedsemver@6.3.1(transitive)
Updatedfastify-plugin@^3.0.0