-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use uid to create the refreshToken
- Loading branch information
1 parent
f950378
commit 6e0ac13
Showing
4 changed files
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import jwt from "jsonwebtoken"; | ||
import env from "../../main/config/env"; | ||
import { uid } from "uid"; | ||
import type { CreateRefreshToken } from "../../data/protocols"; | ||
|
||
export class UtilCreateRefreshToken { | ||
public create(userId: string): string { | ||
return jwt.sign( | ||
{ | ||
aud: userId, | ||
sub: "user", | ||
}, | ||
env.secretRefreshTokenJwt | ||
); | ||
export class UtilCreateRefreshToken implements CreateRefreshToken { | ||
public create(): string { | ||
const LENGTH = 25; | ||
return uid(LENGTH); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,6 +586,11 @@ | |
"@jridgewell/resolve-uri" "^3.0.3" | ||
"@jridgewell/sourcemap-codec" "^1.4.10" | ||
|
||
"@lukeed/csprng@^1.0.0": | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/@lukeed/csprng/-/csprng-1.0.1.tgz#625e93a0edb2c830e3c52ce2d67b9d53377c6a66" | ||
integrity sha512-uSvJdwQU5nK+Vdf6zxcWAY2A8r7uqe+gePwLWzJ+fsQehq18pc0I2hJKwypZ2aLM90+Er9u1xn4iLJPZ+xlL4g== | ||
|
||
"@mapbox/node-pre-gyp@^1.0.0": | ||
version "1.0.9" | ||
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz#09a8781a3a036151cdebbe8719d6f8b25d4058bc" | ||
|
@@ -5217,6 +5222,13 @@ typescript@^4.7.4: | |
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" | ||
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== | ||
|
||
uid@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/uid/-/uid-2.0.0.tgz#1773bec106e96955f1658f20272e2ccea414e8bc" | ||
integrity sha512-hFw+zKBA1szYdbZWj6FjTxZzJnKNf+wTDcsxlJaXS64MCy9LQEmJUVieGYHCKek/WRyFIcs0cEXtGIQmfvHe2A== | ||
dependencies: | ||
"@lukeed/csprng" "^1.0.0" | ||
|
||
unbox-primitive@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" | ||
|
@@ -5267,7 +5279,7 @@ [email protected], uuid@^8.3.1: | |
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" | ||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== | ||
|
||
uuidv4@*, uuidv4@^6.2.13: | ||
uuidv4@*: | ||
version "6.2.13" | ||
resolved "https://registry.yarnpkg.com/uuidv4/-/uuidv4-6.2.13.tgz#8f95ec5ef22d1f92c8e5d4c70b735d1c89572cb7" | ||
integrity sha512-AXyzMjazYB3ovL3q051VLH06Ixj//Knx7QnUSi1T//Ie3io6CpsPu9nVMOx5MoLWh6xV0B9J0hIaxungxXUbPQ== | ||
|