-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
392 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "user" ADD COLUMN "jwtIndex" INTEGER NOT NULL DEFAULT 0; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IsInt, IsString } from "class-validator"; | ||
|
||
export class RefreshTokenReqDto { | ||
@IsString() | ||
/** 사실 꼭 필요하진 않은데 디버깅용... */ | ||
handle: string; | ||
|
||
@IsInt() | ||
last_refreshed_time: number; | ||
} |
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,24 @@ | ||
import { mastodonEmojiModel } from "@/app/_dto/fetch-name-with-emoji/fetch-name-with-emoji.dto"; | ||
|
||
/** | ||
* Mastodon /api/v1/accounts/verify_credentials 에서 돌아오는 응답중에 필요한 것만 추린것 | ||
* 아마도.. .문제 없겠지? | ||
*/ | ||
export type MastodonUser = { | ||
id: string; | ||
username: string; | ||
acct: string; | ||
display_name?: string | null; | ||
locked: boolean; | ||
bot: boolean; | ||
created_at: string; | ||
url: string; | ||
avatar: string | null; | ||
avatar_static?: string | null; | ||
header: string | null; | ||
header_static?: string | null; | ||
followers_count?: number; | ||
following_count?: number; | ||
statuses_count?: number; | ||
emojis: mastodonEmojiModel[]; | ||
}; |
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,24 @@ | ||
'use server'; | ||
|
||
import { SignJWT } from 'jose'; | ||
import { jwtPayload } from './jwtPayload'; | ||
|
||
export async function generateJwt(hostname: string, handle: string, jwtIndex: number) { | ||
const alg = 'HS256'; | ||
const secret = new TextEncoder().encode(process.env.JWT_SECRET); | ||
const jwtPayload: jwtPayload = { | ||
server: hostname, | ||
handle: handle, | ||
jwtIndex: jwtIndex, | ||
}; | ||
|
||
const webUrl = process.env.WEB_URL; | ||
const jwtToken = await new SignJWT(jwtPayload) | ||
.setProtectedHeader({ alg }) | ||
.setIssuedAt() | ||
.setIssuer(`${webUrl}`) | ||
.setAudience('urn:example:audience') | ||
.setExpirationTime('7d') | ||
.sign(secret); | ||
return jwtToken; | ||
} |
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,5 @@ | ||
export type jwtPayload = { | ||
handle: string; | ||
server: string; | ||
jwtIndex: number; | ||
}; |
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
Oops, something went wrong.