-
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.
feat:annoying bug caused by react-native-dotenv fixed, it rewrites ex…
…po-router config so screen doesn't load
- Loading branch information
1 parent
752841b
commit bc05018
Showing
19 changed files
with
437 additions
and
800 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
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
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import db from '@/lib/utils/db'; | ||
import hashToken from '@/lib/utils/hashToken'; | ||
|
||
// TODO : too many errors being raised with using any | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function addRefreshTokenToWhiteList({ | ||
jti, | ||
refreshToken, | ||
userId, | ||
}: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
jti: any; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
refreshToken: any; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
userId: any; | ||
}) { | ||
return db.refreshTokens.create({ | ||
data: { | ||
id: jti, | ||
hashedToken: hashToken(refreshToken), | ||
userId, | ||
}, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function findRefreshTokenById(id: any) { | ||
return db.refreshTokens.findUnique({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function deleteRefreshToken(id: any) { | ||
return db.refreshTokens.updateMany({ | ||
where: { | ||
id, | ||
}, | ||
data: { | ||
revoked: true, | ||
}, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function revokeTokens(userId: any) { | ||
return db.refreshTokens.updateMany({ | ||
where: { | ||
userId, | ||
}, | ||
data: { | ||
revoked: true, | ||
}, | ||
}); | ||
} | ||
|
||
// TODO : Continue at STEP 7 |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { hashSync } from 'bcrypt-ts'; | ||
import db from '@/lib/utils/db'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars | ||
function findUserByEmail(email: any) { | ||
return db.user.findUnique({ | ||
where: { | ||
email, | ||
}, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function createUserByEmailAndPassword(user: any) { | ||
// TODO : Modify this as needed | ||
user.password = hashSync(user.password, 12); | ||
return db.user.create({ | ||
data: user, | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function findUserById(id: any) { | ||
return db.user.findUnique({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
const db = new PrismaClient(); | ||
export default db; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import crypto from 'crypto'; | ||
|
||
export default function hashToken(token: crypto.BinaryLike) { | ||
// TODO : hashing logic, modify as needed | ||
return crypto.createHash('sha512').update(token).digest('hex'); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
// ? for encryption | ||
import * as jwt from 'jsonwebtoken'; | ||
|
||
// TODO : Remove later | ||
// see if it exists | ||
console.log(process.env.JWT_ACCESS_SECRET); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function generateAccessToken(user: any) { | ||
// ** @see https://jwt.io/introduction | ||
return jwt.sign( | ||
{ | ||
userId: user?.id, | ||
}, | ||
// TODO : Remove string before commiting | ||
process.env.JWT_ACCESS_SECRET ? process.env.JWT_ACCESS_SECRET : 'MYSECRET321', | ||
{ | ||
expiresIn: '5m', | ||
} | ||
); | ||
} | ||
|
||
// TODO : Remove this once the function is invoked with the appropriate params | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function generateRefreshToken(user: { id: any }, jti: any) { | ||
return jwt.sign( | ||
{ | ||
userId: user.id, | ||
jti, | ||
}, | ||
process.env.JWT_REFRESH_SECRET ? process.env.JWT_REFRESH_SECRET : 'MYOTHERSECRET321', | ||
{ | ||
// TODO : Modify this as needed | ||
expiresIn: '8h', | ||
} | ||
); | ||
} | ||
|
||
// TODO : Remove this once the functon is invoked with the appropriate params | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
export function generateAccessAndRefreshTokens(user: any, jti: any) { | ||
const accessToken = generateAccessToken(user); | ||
const refreshToken = generateRefreshToken(user, jti); | ||
|
||
console.log(`The access token is ${accessToken}\n`); | ||
console.log(`The refresh token is ${refreshToken}`); | ||
return { | ||
accessToken, | ||
refreshToken, | ||
}; | ||
} |
Oops, something went wrong.