signinwith 1.0.8 → 1.0.10

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.
Files changed (2) hide show
  1. package/index.js +16 -0
  2. package/package.json +4 -2
package/index.js CHANGED
@@ -25,6 +25,22 @@ export const verifySigninApple = async (config, verificationData) => {
25
25
  return result.email ? { success: true, email: result.email } : { success: false, error: 'Email not available from Apple' };
26
26
  };
27
27
  export const verifySigninDiscord = async (config, verificationData) => {
28
+ const tokenResponse = await fetch('https://discord.com/api/v10/oauth2/token', {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/x-www-form-urlencoded',
32
+ },
33
+ body: new URLSearchParams({
34
+ client_id: config.clientId,
35
+ client_secret: config.clientSecret,
36
+ code: verificationData.code,
37
+ grant_type: 'authorization_code',
38
+ redirect_uri: config.redirectUri,
39
+ scope: 'identity email',
40
+ }),
41
+ });
42
+ const token = await tokenResponse.json();
43
+ verificationData.accessToken = token.access_token;
28
44
  const res = await fetch('https://discord.com/api/v10/users/@me', {
29
45
  headers: {
30
46
  authorization: `Bearer ${verificationData.accessToken}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signinwith",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Simple and straightforward library for sign in / sign up with thirdparty oAuth services like Google, Meta, Apple, Discord...",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,8 @@
29
29
  "author": "ybouane",
30
30
  "license": "ISC",
31
31
  "dependencies": {
32
- "react": "^19.1.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "*"
33
35
  }
34
36
  }