Skip to content

Commit dfe6509

Browse files
fix: comment Discord profile, fix @auth/sveltekit build on Windows (#6550)
* fix: discord types were inaccurate * fix: build on windows computers * Apply review suggestions * Update discord.ts --------- Co-authored-by: Balázs Orbán <[email protected]>
1 parent 1bde7cc commit dfe6509

File tree

4 files changed

+78
-14
lines changed

4 files changed

+78
-14
lines changed

packages/core/src/lib/oauth/callback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async function getProfile(
203203
// If we didn't get a response either there was a problem with the provider
204204
// response *or* the user cancelled the action with the provider.
205205
//
206-
// Unfortuately, we can't tell which - at least not in a way that works for
206+
// Unfortunately, we can't tell which - at least not in a way that works for
207207
// all providers, so we return an empty object; the user should then be
208208
// redirected back to the sign up page. We log the error to help developers
209209
// who might be trying to debug this when configuring a new provider.

packages/core/src/providers/discord.ts

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,77 @@
11
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
22

3+
/**
4+
* Corresponds to the user structure documented here:
5+
* https://discord.com/developers/docs/resources/user#user-object-user-structure
6+
*/
37
export interface DiscordProfile extends Record<string, any> {
4-
accent_color: number
5-
avatar: string
6-
banner: string
7-
banner_color: string
8-
discriminator: string
9-
email: string
10-
flags: number
8+
/** the user's id (i.e. the numerical snowflake) */
119
id: string
12-
image_url: string
13-
locale: string
10+
/** the user's username, not unique across the platform */
11+
username: string
12+
/** the user's 4-digit discord-tag */
13+
discriminator: string
14+
/**
15+
* the user's avatar hash:
16+
* https://discord.com/developers/docs/reference#image-formatting
17+
*/
18+
avatar: string | null
19+
/** whether the user belongs to an OAuth2 application */
20+
bot?: boolean
21+
/**
22+
* whether the user is an Official Discord System user (part of the urgent
23+
* message system)
24+
*/
25+
system?: boolean
26+
/** whether the user has two factor enabled on their account */
1427
mfa_enabled: boolean
28+
/**
29+
* the user's banner hash:
30+
* https://discord.com/developers/docs/reference#image-formatting
31+
*/
32+
banner: string | null
33+
34+
/** the user's banner color encoded as an integer representation of hexadecimal color code */
35+
accent_color: number | null
36+
37+
/**
38+
* the user's chosen language option:
39+
* https://discord.com/developers/docs/reference#locales
40+
*/
41+
locale: string
42+
/** whether the email on this account has been verified */
43+
verified: boolean
44+
/** the user's email */
45+
email: string | null
46+
/**
47+
* the flags on a user's account:
48+
* https://discord.com/developers/docs/resources/user#user-object-user-flags
49+
*/
50+
flags: number
51+
/**
52+
* the type of Nitro subscription on a user's account:
53+
* https://discord.com/developers/docs/resources/user#user-object-premium-types
54+
*/
1555
premium_type: number
56+
/**
57+
* the public flags on a user's account:
58+
* https://discord.com/developers/docs/resources/user#user-object-user-flags
59+
*/
1660
public_flags: number
17-
username: string
18-
verified: boolean
61+
/** undocumented field; corresponds to the user's custom nickname */
62+
display_name: string | null
63+
/**
64+
* undocumented field; corresponds to the Discord feature where you can e.g.
65+
* put your avatar inside of an ice cube
66+
*/
67+
avatar_decoration: string | null
68+
/**
69+
* undocumented field; corresponds to the premium feature where you can
70+
* select a custom banner color
71+
*/
72+
banner_color: string | null
73+
/** undocumented field; the CDN URL of their profile picture */
74+
image_url: string
1975
}
2076

2177
export default function Discord<P extends DiscordProfile>(

packages/core/src/providers/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export type TokenEndpointHandler = EndpointHandler<
6666
params: CallbackParamsType
6767
/**
6868
* When using this custom flow, make sure to do all the necessary security checks.
69-
* Thist object contains parameters you have to match against the request to make sure it is valid.
69+
* This object contains parameters you have to match against the request to make sure it is valid.
7070
*/
7171
checks: OAuthChecks
7272
},

packages/frameworks-sveltekit/scripts/postbuild.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
// After build, copy the files in ./package to the root directory, excluding the package.json file.
2+
23
import fs from "fs/promises"
34
import path from "path"
45

5-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
6+
let __dirname = path.dirname(new URL(import.meta.url).pathname)
7+
8+
// The above hack to polyfill "__dirname" for ESM does not work on Windows computers,
9+
// so we might have to manually perform more steps.
10+
__dirname = __dirname.split(path.sep).join(path.posix.sep)
11+
if (__dirname.match(/^\/\w:\//)) {
12+
__dirname = __dirname.slice(3) // Remove the drive prefix.
13+
}
614

715
const root = path.join(__dirname, "..")
816
const pkgDir = path.join(root, "package")

0 commit comments

Comments
 (0)