@mikandev/next-discord-auth 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,8 +12,16 @@ export function setup(config) {
12
12
  console.warn("Global config is already set. Overwriting existing config.");
13
13
  }
14
14
  globalConfig = {
15
- clientId: config.clientId ?? process.env.AUTH_DISCORD_ID ?? (() => { throw new Error("clientId is required"); })(),
16
- clientSecret: config.clientSecret ?? process.env.AUTH_DISCORD_SECRET ?? (() => { throw new Error("clientSecret is required"); })(),
15
+ clientId: config.clientId ??
16
+ process.env.AUTH_DISCORD_ID ??
17
+ (() => {
18
+ throw new Error("clientId is required");
19
+ })(),
20
+ clientSecret: config.clientSecret ??
21
+ process.env.AUTH_DISCORD_SECRET ??
22
+ (() => {
23
+ throw new Error("clientSecret is required");
24
+ })(),
17
25
  scopes: config.scopes ?? ["identify", "email"],
18
26
  redirectUri: config.redirectUri,
19
27
  jwtSecret: config.jwtSecret,
@@ -0,0 +1,21 @@
1
+ export interface Session {
2
+ user: {
3
+ id: string;
4
+ name: string;
5
+ email?: string;
6
+ avatar: string;
7
+ };
8
+ expires: string;
9
+ accessToken?: string;
10
+ }
11
+
12
+ export interface Config {
13
+ clientId: string;
14
+ clientSecret: string;
15
+ scopes: string[];
16
+ redirectUri: string;
17
+ jwtSecret: string;
18
+ }
19
+
20
+ export function setup(config: Config): void;
21
+ export function getGlobalConfig(): Config;
@@ -0,0 +1,5 @@
1
+ import type { NextRequest, NextResponse } from "next/server";
2
+
3
+ export declare function handleRedirect(
4
+ req: NextRequest,
5
+ ): Promise<NextResponse | void>;
@@ -0,0 +1,8 @@
1
+ import type { NextRequest, NextResponse } from "next/server";
2
+ import type { Session } from "./index";
3
+
4
+ export declare function getSession(req: NextRequest): Promise<Session | null>;
5
+
6
+ export declare function signIn(req: NextRequest): Promise<NextResponse>;
7
+
8
+ export declare function signOut(req: NextRequest): Promise<NextResponse>;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@mikandev/next-discord-auth",
3
+ "description": "Discord OAuth for Next.js that doesn't suck",
3
4
  "module": "dist/index.ts",
4
5
  "types": "dist/index.d.ts",
5
6
  "main": "dist/index.js",
6
7
  "files": ["dist"],
7
8
  "license": "WTFPL",
8
- "version": "0.0.9",
9
+ "version": "0.1.1",
9
10
  "type": "module",
10
11
  "repository": {
11
12
  "type": "git",
@@ -13,7 +14,7 @@
13
14
  },
14
15
  "homepage": "https://mikn.dev/solutions/developers/next-discord-auth",
15
16
  "scripts": {
16
- "build": "tsc",
17
+ "build": "bun build.ts",
17
18
  "format": "biome format --write .",
18
19
  "lint": "biome lint",
19
20
  "lintfix": "biome lint --fix"
@@ -29,5 +30,28 @@
29
30
  "dependencies": {
30
31
  "jsonwebtoken": "^9.0.2",
31
32
  "next": "^15.3.2"
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "import": "./dist/index.js",
37
+ "require": "./dist/index.js",
38
+ "types": "./dist/types/index.d.ts"
39
+ },
40
+ "./redirect": {
41
+ "import": "./dist/redirect.js",
42
+ "require": "./dist/redirect.js",
43
+ "types": "./dist/types/redirect.d.ts"
44
+ },
45
+ "./server-actions": {
46
+ "import": "./dist/server-actions.js",
47
+ "require": "./dist/server-actions.js",
48
+ "types": "./dist/types/server-actions.d.ts"
49
+ }
50
+ },
51
+ "typesVersions": {
52
+ "*": {
53
+ "redirect": ["dist/types/redirect.d.ts"],
54
+ "server-actions": ["dist/types/server-actions.d.ts"]
55
+ }
32
56
  }
33
57
  }