@logto/connector-discord 1.0.0-beta.4
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/LICENSE +21 -0
- package/README.md +35 -0
- package/docs/config-template.json +4 -0
- package/lib/index.js +14986 -0
- package/lib/jest.config.d.ts +3 -0
- package/lib/src/constant.d.ts +19 -0
- package/lib/src/index.d.ts +14 -0
- package/lib/src/index.test.d.ts +1 -0
- package/lib/src/mock.d.ts +4 -0
- package/lib/src/types.d.ts +69 -0
- package/logo.svg +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConnectorMetadata } from '@logto/connector-kit';
|
|
2
|
+
/**
|
|
3
|
+
* Base authorization URL.
|
|
4
|
+
* https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-urls
|
|
5
|
+
*/
|
|
6
|
+
export declare const authorizationEndpoint = "https://discord.com/oauth2/authorize";
|
|
7
|
+
/**
|
|
8
|
+
* Discord exposes different versions of the API, You should specify which version to use by including it in your requests.
|
|
9
|
+
* https://discord.com/developers/docs/reference#api-reference
|
|
10
|
+
*/
|
|
11
|
+
export declare const accessTokenEndpoint = "https://discord.com/api/v10/oauth2/token";
|
|
12
|
+
export declare const userInfoEndpoint = "https://discord.com/api/v10/users/@me";
|
|
13
|
+
/**
|
|
14
|
+
* OAuth2 Scopes
|
|
15
|
+
* https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
|
|
16
|
+
*/
|
|
17
|
+
export declare const scope = "identify email";
|
|
18
|
+
export declare const defaultMetadata: ConnectorMetadata;
|
|
19
|
+
export declare const defaultTimeout = 5000;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord OAuth2 Connector
|
|
3
|
+
* https://discord.com/developers/docs/topics/oauth2
|
|
4
|
+
*/
|
|
5
|
+
import { CreateConnector, SocialConnector } from '@logto/connector-kit';
|
|
6
|
+
import { DiscordConfig } from './types';
|
|
7
|
+
export declare const getAccessToken: (config: DiscordConfig, codeObject: {
|
|
8
|
+
code: string;
|
|
9
|
+
redirectUri: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
accessToken: string;
|
|
12
|
+
}>;
|
|
13
|
+
declare const createDiscordConnector: CreateConnector<SocialConnector>;
|
|
14
|
+
export default createDiscordConnector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const discordConfigGuard: z.ZodObject<{
|
|
3
|
+
clientId: z.ZodString;
|
|
4
|
+
clientSecret: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
}, {
|
|
9
|
+
clientId: string;
|
|
10
|
+
clientSecret: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare type DiscordConfig = z.infer<typeof discordConfigGuard>;
|
|
13
|
+
export declare const accessTokenResponseGuard: z.ZodObject<{
|
|
14
|
+
access_token: z.ZodString;
|
|
15
|
+
token_type: z.ZodString;
|
|
16
|
+
expires_in: z.ZodNumber;
|
|
17
|
+
scope: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
scope: string;
|
|
20
|
+
access_token: string;
|
|
21
|
+
token_type: string;
|
|
22
|
+
expires_in: number;
|
|
23
|
+
}, {
|
|
24
|
+
scope: string;
|
|
25
|
+
access_token: string;
|
|
26
|
+
token_type: string;
|
|
27
|
+
expires_in: number;
|
|
28
|
+
}>;
|
|
29
|
+
export declare type AccessTokenResponse = z.infer<typeof accessTokenResponseGuard>;
|
|
30
|
+
export declare const userInfoResponseGuard: z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
username: z.ZodOptional<z.ZodString>;
|
|
33
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
34
|
+
email: z.ZodOptional<z.ZodString>;
|
|
35
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
username?: string | undefined;
|
|
38
|
+
avatar?: string | undefined;
|
|
39
|
+
email?: string | undefined;
|
|
40
|
+
verified?: boolean | undefined;
|
|
41
|
+
id: string;
|
|
42
|
+
}, {
|
|
43
|
+
username?: string | undefined;
|
|
44
|
+
avatar?: string | undefined;
|
|
45
|
+
email?: string | undefined;
|
|
46
|
+
verified?: boolean | undefined;
|
|
47
|
+
id: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare type UserInfoResponse = z.infer<typeof userInfoResponseGuard>;
|
|
50
|
+
export declare const authorizationCallbackErrorGuard: z.ZodObject<{
|
|
51
|
+
error: z.ZodString;
|
|
52
|
+
error_description: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
error: string;
|
|
55
|
+
error_description: string;
|
|
56
|
+
}, {
|
|
57
|
+
error: string;
|
|
58
|
+
error_description: string;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const authResponseGuard: z.ZodObject<{
|
|
61
|
+
code: z.ZodString;
|
|
62
|
+
redirectUri: z.ZodString;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
code: string;
|
|
65
|
+
redirectUri: string;
|
|
66
|
+
}, {
|
|
67
|
+
code: string;
|
|
68
|
+
redirectUri: string;
|
|
69
|
+
}>;
|
package/logo.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg enable-background="new 0 0 512 512" id="Layer_1" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><circle cx="256" cy="256" fill="#8C9EFF" id="ellipse" r="256"/><path d="M372.4,168.7c0,0-33.3-26.1-72.7-29.1l-3.5,7.1c35.6,8.7,51.9,21.2,69,36.5 c-29.4-15-58.5-29.1-109.1-29.1s-79.7,14.1-109.1,29.1c17.1-15.3,36.5-29.2,69-36.5l-3.5-7.1c-41.3,3.9-72.7,29.1-72.7,29.1 s-37.2,54-43.6,160c37.5,43.3,94.5,43.6,94.5,43.6l11.9-15.9c-20.2-7-43.1-19.6-62.8-42.3c23.5,17.8,59.1,36.4,116.4,36.4 s92.8-18.5,116.4-36.4c-19.7,22.7-42.6,35.3-62.8,42.3l11.9,15.9c0,0,57-0.3,94.5-43.6C409.6,222.7,372.4,168.7,372.4,168.7z M208.7,299.6c-14.1,0-25.5-13-25.5-29.1s11.4-29.1,25.5-29.1c14.1,0,25.5,13,25.5,29.1S222.8,299.6,208.7,299.6z M303.3,299.6 c-14.1,0-25.5-13-25.5-29.1s11.4-29.1,25.5-29.1s25.5,13,25.5,29.1S317.3,299.6,303.3,299.6z" fill="#FFFFFF" id="logo"/></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@logto/connector-discord",
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
|
+
"description": "Discord connector implementation.",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"exports": "./lib/index.js",
|
|
7
|
+
"author": "ZR3SYSTEMS. <https://github.com/FlurryNight>",
|
|
8
|
+
"license": "MPL-2.0",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib",
|
|
11
|
+
"docs",
|
|
12
|
+
"logo.svg",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"precommit": "lint-staged",
|
|
17
|
+
"build": "rm -rf lib/ && ncc build src/index.ts -o lib",
|
|
18
|
+
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
|
|
19
|
+
"lint": "eslint --ext .ts src",
|
|
20
|
+
"lint:report": "pnpm lint --format json --output-file report.json",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:coverage": "jest --coverage --silent",
|
|
23
|
+
"prepack": "pnpm build"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@logto/connector-kit": "^1.0.0-beta.11",
|
|
27
|
+
"@silverhand/essentials": "^1.2.0",
|
|
28
|
+
"@silverhand/jest-config": "1.0.0",
|
|
29
|
+
"got": "^11.8.2",
|
|
30
|
+
"zod": "^3.14.3"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@jest/types": "^28.1.3",
|
|
34
|
+
"@silverhand/eslint-config": "1.0.0",
|
|
35
|
+
"@silverhand/ts-config": "1.0.0",
|
|
36
|
+
"@types/jest": "^28.1.6",
|
|
37
|
+
"@types/node": "^16.3.1",
|
|
38
|
+
"@vercel/ncc": "^0.34.0",
|
|
39
|
+
"eslint": "^8.21.0",
|
|
40
|
+
"jest": "^28.1.3",
|
|
41
|
+
"jest-matcher-specific-error": "^1.0.0",
|
|
42
|
+
"lint-staged": "^13.0.0",
|
|
43
|
+
"nock": "^13.2.2",
|
|
44
|
+
"prettier": "^2.7.1",
|
|
45
|
+
"typescript": "^4.7.4"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": "^16.0.0"
|
|
49
|
+
},
|
|
50
|
+
"eslintConfig": {
|
|
51
|
+
"extends": "@silverhand"
|
|
52
|
+
},
|
|
53
|
+
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "7a8f2c39a7c31d25ea319c5b3aa824aea4b3ab81"
|
|
58
|
+
}
|