@tachybase/plugin-auth-wechat 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/README.md +14 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/admin-settings-form.d.ts +2 -0
- package/dist/client/bind-form.d.ts +4 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +15 -0
- package/dist/client/sign-in-form.d.ts +6 -0
- package/dist/client/wechat-qr-component.d.ts +2 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +40 -0
- package/dist/externalVersion.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.d.ts +11 -0
- package/dist/locale/en-US.js +32 -0
- package/dist/locale/index.d.ts +1 -0
- package/dist/locale/index.js +31 -0
- package/dist/locale/zh-CN.d.ts +11 -0
- package/dist/locale/zh-CN.js +32 -0
- package/dist/server/actions/get-auth-cfg.d.ts +2 -0
- package/dist/server/actions/get-auth-cfg.js +65 -0
- package/dist/server/actions/index.d.ts +2 -0
- package/dist/server/actions/index.js +30 -0
- package/dist/server/actions/redirect.d.ts +2 -0
- package/dist/server/actions/redirect.js +77 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +74 -0
- package/dist/server/wechat-auth.d.ts +17 -0
- package/dist/server/wechat-auth.js +138 -0
- package/dist/swagger/index.d.ts +143 -0
- package/dist/swagger/index.js +178 -0
- package/package.json +32 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var redirect_exports = {};
|
|
19
|
+
__export(redirect_exports, {
|
|
20
|
+
redirect: () => redirect
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(redirect_exports);
|
|
23
|
+
var import_server = require("@tachybase/server");
|
|
24
|
+
var import_utils = require("@tachybase/utils");
|
|
25
|
+
var import_constants = require("../../constants");
|
|
26
|
+
const redirect = async (ctx, next) => {
|
|
27
|
+
let { state } = ctx.request.query;
|
|
28
|
+
state = Array.isArray(state) ? state[0] : state;
|
|
29
|
+
const search = new URLSearchParams(state);
|
|
30
|
+
const authenticator = search.get("name");
|
|
31
|
+
const appName = search.get("app");
|
|
32
|
+
const redirect2 = search.get("redirect") || "/admin";
|
|
33
|
+
let prefix = process.env.APP_PUBLIC_PATH || "";
|
|
34
|
+
if (appName && appName !== "main") {
|
|
35
|
+
const appSupervisor = import_server.AppSupervisor.getInstance();
|
|
36
|
+
if ((appSupervisor == null ? void 0 : appSupervisor.runningMode) !== "single") {
|
|
37
|
+
prefix += `apps/${appName}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const auth = await ctx.app.authManager.get(authenticator, ctx);
|
|
41
|
+
if (prefix.endsWith("/")) {
|
|
42
|
+
prefix = prefix.slice(0, -1);
|
|
43
|
+
}
|
|
44
|
+
const bindToken = search.get("bindToken");
|
|
45
|
+
if (bindToken) {
|
|
46
|
+
try {
|
|
47
|
+
const user = await ctx.app.authManager.jwt.decode(bindToken);
|
|
48
|
+
if (!user) {
|
|
49
|
+
ctx.throw(401, "Bind user failed: no user found");
|
|
50
|
+
}
|
|
51
|
+
await auth.bindUser(user.userId);
|
|
52
|
+
ctx.redirect(`${prefix}${redirect2}`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
ctx.logger.error("WeChat auth error", { error });
|
|
55
|
+
ctx.redirect(`${prefix}${redirect2}?error=${error.message}`);
|
|
56
|
+
}
|
|
57
|
+
return next();
|
|
58
|
+
}
|
|
59
|
+
const ts = search.get("ts") ? +search.get("ts") : 0;
|
|
60
|
+
if (ts) {
|
|
61
|
+
if (ts < (0, import_utils.dayjs)().subtract(import_constants.AUTH_TIMEOUT_MINUTE, "minute").unix()) {
|
|
62
|
+
ctx.throw(400, "timeout");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const { token } = await auth.signIn();
|
|
67
|
+
ctx.redirect(`${prefix}${redirect2}?authenticator=${authenticator}&token=${token}`);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
ctx.logger.error("WeChat auth error", { error });
|
|
70
|
+
ctx.redirect(`${prefix}/signin?redirect=${redirect2}&authenticator=${authenticator}&error=${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
await next();
|
|
73
|
+
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
redirect
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
default: () => import_plugin.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(server_exports);
|
|
33
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstallOptions, Plugin } from '@tachybase/server';
|
|
2
|
+
export declare class WeChatAuthPlugin extends Plugin {
|
|
3
|
+
afterAdd(): void;
|
|
4
|
+
beforeLoad(): void;
|
|
5
|
+
load(): Promise<void>;
|
|
6
|
+
install(options?: InstallOptions): Promise<void>;
|
|
7
|
+
afterEnable(): Promise<void>;
|
|
8
|
+
afterDisable(): Promise<void>;
|
|
9
|
+
remove(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export default WeChatAuthPlugin;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var plugin_exports = {};
|
|
19
|
+
__export(plugin_exports, {
|
|
20
|
+
WeChatAuthPlugin: () => WeChatAuthPlugin,
|
|
21
|
+
default: () => plugin_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
24
|
+
var import_server = require("@tachybase/server");
|
|
25
|
+
var import_constants = require("../constants");
|
|
26
|
+
var import_actions = require("./actions");
|
|
27
|
+
var import_wechat_auth = require("./wechat-auth");
|
|
28
|
+
class WeChatAuthPlugin extends import_server.Plugin {
|
|
29
|
+
afterAdd() {
|
|
30
|
+
}
|
|
31
|
+
beforeLoad() {
|
|
32
|
+
}
|
|
33
|
+
async load() {
|
|
34
|
+
this.app.authManager.registerTypes(import_constants.authType, {
|
|
35
|
+
auth: import_wechat_auth.WeChatAuth
|
|
36
|
+
});
|
|
37
|
+
this.app.resourcer.define({
|
|
38
|
+
name: "wechatAuth",
|
|
39
|
+
actions: {
|
|
40
|
+
getAuthCfg: import_actions.getAuthCfg,
|
|
41
|
+
redirect: import_actions.redirect
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.app.acl.allow("wechatAuth", "*", "public");
|
|
45
|
+
import_server.Gateway.getInstance().addAppSelectorMiddleware(async (ctx, next) => {
|
|
46
|
+
const { req } = ctx;
|
|
47
|
+
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
48
|
+
const params = url.searchParams;
|
|
49
|
+
const state = params.get("state");
|
|
50
|
+
if (!state) {
|
|
51
|
+
return next();
|
|
52
|
+
}
|
|
53
|
+
const search = new URLSearchParams(state);
|
|
54
|
+
const appName = search.get("app");
|
|
55
|
+
if (appName) {
|
|
56
|
+
ctx.resolvedAppName = appName;
|
|
57
|
+
}
|
|
58
|
+
await next();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async install(options) {
|
|
62
|
+
}
|
|
63
|
+
async afterEnable() {
|
|
64
|
+
}
|
|
65
|
+
async afterDisable() {
|
|
66
|
+
}
|
|
67
|
+
async remove() {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
var plugin_default = WeChatAuthPlugin;
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
WeChatAuthPlugin
|
|
74
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthConfig, BaseAuth } from '@tachybase/auth';
|
|
2
|
+
export { Model } from '@tachybase/database';
|
|
3
|
+
export declare class WeChatAuth extends BaseAuth {
|
|
4
|
+
constructor(config: AuthConfig);
|
|
5
|
+
validate(): Promise<any>;
|
|
6
|
+
getUnionid(getInfo?: boolean): Promise<{
|
|
7
|
+
unionid?: string;
|
|
8
|
+
info?: any;
|
|
9
|
+
}>;
|
|
10
|
+
bindUser(userId: number): Promise<void>;
|
|
11
|
+
getAuthCfg(redirect: string): Promise<{
|
|
12
|
+
appId: any;
|
|
13
|
+
scope: string;
|
|
14
|
+
redirectUrl: string;
|
|
15
|
+
state: string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var wechat_auth_exports = {};
|
|
19
|
+
__export(wechat_auth_exports, {
|
|
20
|
+
Model: () => import_database.Model,
|
|
21
|
+
WeChatAuth: () => WeChatAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(wechat_auth_exports);
|
|
24
|
+
var import_auth = require("@tachybase/auth");
|
|
25
|
+
var import_utils = require("@tachybase/utils");
|
|
26
|
+
var import_constants = require("../constants");
|
|
27
|
+
var import_database = require("@tachybase/database");
|
|
28
|
+
class WeChatAuth extends import_auth.BaseAuth {
|
|
29
|
+
constructor(config) {
|
|
30
|
+
const { ctx } = config;
|
|
31
|
+
super({
|
|
32
|
+
...config,
|
|
33
|
+
userCollection: ctx.db.getCollection("users")
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async validate() {
|
|
37
|
+
var _a;
|
|
38
|
+
const { ctx } = this;
|
|
39
|
+
try {
|
|
40
|
+
const { unionid } = await this.getUnionid();
|
|
41
|
+
const authenticator = this.authenticator;
|
|
42
|
+
const user = await authenticator.findUser(unionid);
|
|
43
|
+
if (user) {
|
|
44
|
+
return user;
|
|
45
|
+
}
|
|
46
|
+
const { autoSignUp } = ((_a = this.options) == null ? void 0 : _a.public) || {};
|
|
47
|
+
if (!autoSignUp) {
|
|
48
|
+
ctx.logger.error(`User not found: ${unionid}`);
|
|
49
|
+
ctx.throw(401, ctx.t("User not found", { ns: import_constants.namespace }));
|
|
50
|
+
}
|
|
51
|
+
return await authenticator.newUser(unionid, {
|
|
52
|
+
unionid
|
|
53
|
+
});
|
|
54
|
+
} catch (err) {
|
|
55
|
+
ctx.logger.error(`Failed in validate: ${err}`);
|
|
56
|
+
ctx.throw(401, (err == null ? void 0 : err.message) || ctx.t("Unauthorized", { ns: import_constants.namespace }));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async getUnionid(getInfo = false) {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
|
+
const { ctx } = this;
|
|
62
|
+
let { code } = ctx.request.query || {};
|
|
63
|
+
code = Array.isArray(code) ? code[0] : code;
|
|
64
|
+
if (!code) {
|
|
65
|
+
ctx.logger.error("Failed to get code");
|
|
66
|
+
ctx.throw(401, ctx.t("Unauthorized", { ns: import_constants.namespace }));
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const getAccessTokenRsp = await fetch(
|
|
70
|
+
`${import_constants.weChatApiOauthBaseUrl}/oauth2/access_token?appid=${(_b = (_a = this.options) == null ? void 0 : _a.wechatAuth) == null ? void 0 : _b.AppID}&secret=${(_d = (_c = this.options) == null ? void 0 : _c.wechatAuth) == null ? void 0 : _d.AppSecret}&code=${code}&grant_type=authorization_code`
|
|
71
|
+
);
|
|
72
|
+
const getAccessTokenRspJson = await getAccessTokenRsp.json();
|
|
73
|
+
if (getAccessTokenRspJson.errcode) {
|
|
74
|
+
ctx.logger.error(`Failed to get user accessToken: ${getAccessTokenRspJson.errmsg}`);
|
|
75
|
+
ctx.throw(401, ctx.t("Failed to get accessToken", { ns: import_constants.namespace }));
|
|
76
|
+
}
|
|
77
|
+
const { access_token, unionid, openid } = getAccessTokenRspJson;
|
|
78
|
+
if (getInfo) {
|
|
79
|
+
const getInfoRsp = await fetch(
|
|
80
|
+
`${import_constants.weChatApiOauthBaseUrl}/userinfo?access_token=${access_token}&openid=${openid}&lang=zh_CN`
|
|
81
|
+
);
|
|
82
|
+
const getInfoRspJson = await getInfoRsp.json();
|
|
83
|
+
if (!getInfoRspJson.errcode) {
|
|
84
|
+
return { unionid, info: getInfoRspJson };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { unionid };
|
|
88
|
+
} catch (e) {
|
|
89
|
+
ctx.logger.error("Failed to get code");
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async bindUser(userId) {
|
|
94
|
+
const { unionid, info } = await this.getUnionid(true);
|
|
95
|
+
if (!unionid) {
|
|
96
|
+
this.ctx.throw(400, "Bind user failed: no weixin user found");
|
|
97
|
+
}
|
|
98
|
+
const authenticator = this.authenticator;
|
|
99
|
+
const existUser = await authenticator.findUser(unionid);
|
|
100
|
+
if (existUser) {
|
|
101
|
+
this.ctx.throw(400, "Bind user failed: wechat can bine one user!");
|
|
102
|
+
}
|
|
103
|
+
await authenticator.bindUser(userId, unionid, {
|
|
104
|
+
nickname: info == null ? void 0 : info.nickname,
|
|
105
|
+
avatar: info == null ? void 0 : info.headimgurl
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async getAuthCfg(redirect) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const appID = (_b = (_a = this.options) == null ? void 0 : _a.wechatAuth) == null ? void 0 : _b.AppID;
|
|
111
|
+
const app = this.ctx.app.name;
|
|
112
|
+
const ctx = this.ctx;
|
|
113
|
+
const referer = ctx.req.headers["referer"];
|
|
114
|
+
let redirectUrl;
|
|
115
|
+
if (referer) {
|
|
116
|
+
const clientUrl = new URL(referer);
|
|
117
|
+
redirectUrl = `${clientUrl.protocol}//${clientUrl.host}${process.env.API_BASE_PATH}wechatAuth:redirect`;
|
|
118
|
+
} else {
|
|
119
|
+
redirectUrl = `${this.ctx.protocol}://${this.ctx.host}${process.env.API_BASE_PATH}wechatAuth:redirect`;
|
|
120
|
+
}
|
|
121
|
+
const state = encodeURIComponent(
|
|
122
|
+
encodeURIComponent(
|
|
123
|
+
`redirect=${redirect}&app=${app}&name=${this.ctx.headers["x-authenticator"]}&ts=${(0, import_utils.dayjs)().unix()}`
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
return {
|
|
127
|
+
appId: appID,
|
|
128
|
+
scope: import_constants.weChatApiOauthScope,
|
|
129
|
+
redirectUrl: encodeURIComponent(redirectUrl),
|
|
130
|
+
state
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
Model,
|
|
137
|
+
WeChatAuth
|
|
138
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
info: {
|
|
3
|
+
title: string;
|
|
4
|
+
};
|
|
5
|
+
paths: {
|
|
6
|
+
'/wechatAuth:getAuthCfg': {
|
|
7
|
+
security: any[];
|
|
8
|
+
get: {
|
|
9
|
+
description: string;
|
|
10
|
+
tags: string[];
|
|
11
|
+
parameters: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
in: string;
|
|
15
|
+
schema: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
required: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
responses: {
|
|
21
|
+
200: {
|
|
22
|
+
description: string;
|
|
23
|
+
content: {
|
|
24
|
+
'application/json': {
|
|
25
|
+
schema: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
'/wechatAuth:signIn': {
|
|
35
|
+
security: any[];
|
|
36
|
+
post: {
|
|
37
|
+
description: string;
|
|
38
|
+
tags: string[];
|
|
39
|
+
parameters: {
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
in: string;
|
|
43
|
+
schema: {
|
|
44
|
+
type: string;
|
|
45
|
+
};
|
|
46
|
+
required: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
requestBody: {
|
|
49
|
+
content: {
|
|
50
|
+
'application/json': {
|
|
51
|
+
schema: {
|
|
52
|
+
type: string;
|
|
53
|
+
properties: {
|
|
54
|
+
code: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
state: {
|
|
58
|
+
type: string;
|
|
59
|
+
};
|
|
60
|
+
iss: {
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
responses: {
|
|
69
|
+
200: {
|
|
70
|
+
description: string;
|
|
71
|
+
content: {
|
|
72
|
+
'application/json': {
|
|
73
|
+
schema: {
|
|
74
|
+
type: string;
|
|
75
|
+
properties: {
|
|
76
|
+
token: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
user: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
properties: {
|
|
83
|
+
id: {
|
|
84
|
+
type: string;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
nickname: {
|
|
88
|
+
type: string;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
email: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
phone: {
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
appLang: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
systemSettings: {
|
|
104
|
+
type: string;
|
|
105
|
+
description: string;
|
|
106
|
+
properties: {
|
|
107
|
+
theme: {
|
|
108
|
+
type: string;
|
|
109
|
+
description: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
createdAt: {
|
|
114
|
+
type: string;
|
|
115
|
+
format: string;
|
|
116
|
+
description: string;
|
|
117
|
+
};
|
|
118
|
+
updatedAt: {
|
|
119
|
+
type: string;
|
|
120
|
+
format: string;
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
createdById: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
updatedById: {
|
|
128
|
+
type: string;
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
export default _default;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var swagger_exports = {};
|
|
19
|
+
__export(swagger_exports, {
|
|
20
|
+
default: () => swagger_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(swagger_exports);
|
|
23
|
+
const user = {
|
|
24
|
+
type: "object",
|
|
25
|
+
description: "\u7528\u6237",
|
|
26
|
+
properties: {
|
|
27
|
+
id: {
|
|
28
|
+
type: "integer",
|
|
29
|
+
description: "ID"
|
|
30
|
+
},
|
|
31
|
+
nickname: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "\u6635\u79F0"
|
|
34
|
+
},
|
|
35
|
+
email: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "\u90AE\u7BB1"
|
|
38
|
+
},
|
|
39
|
+
phone: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "\u624B\u673A\u53F7"
|
|
42
|
+
},
|
|
43
|
+
appLang: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "\u7528\u6237\u4F7F\u7528\u8BED\u8A00"
|
|
46
|
+
},
|
|
47
|
+
systemSettings: {
|
|
48
|
+
type: "object",
|
|
49
|
+
description: "\u5E94\u7528\u914D\u7F6E",
|
|
50
|
+
properties: {
|
|
51
|
+
theme: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "\u7528\u6237\u4F7F\u7528\u4E3B\u9898"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
createdAt: {
|
|
58
|
+
type: "string",
|
|
59
|
+
format: "date-time",
|
|
60
|
+
description: "\u521B\u5EFA\u65F6\u95F4"
|
|
61
|
+
},
|
|
62
|
+
updatedAt: {
|
|
63
|
+
type: "string",
|
|
64
|
+
format: "date-time",
|
|
65
|
+
description: "\u66F4\u65B0\u65F6\u95F4"
|
|
66
|
+
},
|
|
67
|
+
createdById: {
|
|
68
|
+
type: "integer",
|
|
69
|
+
description: "\u521B\u5EFA\u4EBA"
|
|
70
|
+
},
|
|
71
|
+
updatedById: {
|
|
72
|
+
type: "integer",
|
|
73
|
+
description: "\u66F4\u65B0\u4EBA"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var swagger_default = {
|
|
78
|
+
info: {
|
|
79
|
+
title: "TachyBase API - WeChat Auth plugin"
|
|
80
|
+
},
|
|
81
|
+
paths: {
|
|
82
|
+
"/wechatAuth:getAuthCfg": {
|
|
83
|
+
security: [],
|
|
84
|
+
get: {
|
|
85
|
+
description: "Get WeChat authorization configuration",
|
|
86
|
+
tags: ["WeChat"],
|
|
87
|
+
parameters: [
|
|
88
|
+
{
|
|
89
|
+
name: "X-Authenticator",
|
|
90
|
+
description: "\u767B\u5F55\u65B9\u5F0F\u6807\u8BC6",
|
|
91
|
+
in: "header",
|
|
92
|
+
schema: {
|
|
93
|
+
type: "string"
|
|
94
|
+
},
|
|
95
|
+
required: true
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
responses: {
|
|
99
|
+
200: {
|
|
100
|
+
description: "ok",
|
|
101
|
+
content: {
|
|
102
|
+
"application/json": {
|
|
103
|
+
schema: {
|
|
104
|
+
type: "string"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"/wechatAuth:signIn": {
|
|
113
|
+
security: [],
|
|
114
|
+
post: {
|
|
115
|
+
description: "WeChat sign in",
|
|
116
|
+
tags: ["WeChat"],
|
|
117
|
+
parameters: [
|
|
118
|
+
{
|
|
119
|
+
name: "X-Authenticator",
|
|
120
|
+
description: "\u767B\u5F55\u65B9\u5F0F\u6807\u8BC6",
|
|
121
|
+
in: "header",
|
|
122
|
+
schema: {
|
|
123
|
+
type: "string"
|
|
124
|
+
},
|
|
125
|
+
required: true
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "tachybase_wechat_auth",
|
|
129
|
+
description: "state\u6821\u9A8C\u503C",
|
|
130
|
+
in: "cookie",
|
|
131
|
+
schema: {
|
|
132
|
+
type: "string"
|
|
133
|
+
},
|
|
134
|
+
required: true
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
requestBody: {
|
|
138
|
+
content: {
|
|
139
|
+
"application/json": {
|
|
140
|
+
schema: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
code: {
|
|
144
|
+
type: "string"
|
|
145
|
+
},
|
|
146
|
+
state: {
|
|
147
|
+
type: "string"
|
|
148
|
+
},
|
|
149
|
+
iss: {
|
|
150
|
+
type: "string"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
responses: {
|
|
158
|
+
200: {
|
|
159
|
+
description: "ok",
|
|
160
|
+
content: {
|
|
161
|
+
"application/json": {
|
|
162
|
+
schema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
token: {
|
|
166
|
+
type: "string"
|
|
167
|
+
},
|
|
168
|
+
user
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|