@tachybase/plugin-api-keys 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.
Files changed (54) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/LICENSE +201 -0
  3. package/README.md +9 -0
  4. package/README.zh-CN.md +9 -0
  5. package/client.d.ts +3 -0
  6. package/client.js +65 -0
  7. package/dist/client/Configuration/ExpiresSelect.d.ts +3 -0
  8. package/dist/client/Configuration/index.d.ts +2 -0
  9. package/dist/client/Configuration/roles.d.ts +3 -0
  10. package/dist/client/Configuration/schema.d.ts +2 -0
  11. package/dist/client/index.d.ts +5 -0
  12. package/dist/client/index.js +6 -0
  13. package/dist/client/locale/index.d.ts +2 -0
  14. package/dist/collections/apiKeys.d.ts +3 -0
  15. package/dist/collections/apiKeys.js +120 -0
  16. package/dist/constants.d.ts +1 -0
  17. package/dist/constants.js +27 -0
  18. package/dist/externalVersion.js +12 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +39 -0
  21. package/dist/locale/en-US.json +21 -0
  22. package/dist/locale/ko_KR.json +21 -0
  23. package/dist/locale/zh-CN.json +21 -0
  24. package/dist/locale.d.ts +1 -0
  25. package/dist/locale.js +30 -0
  26. package/dist/server/actions/api-keys.d.ts +3 -0
  27. package/dist/server/actions/api-keys.js +84 -0
  28. package/dist/server/collections/apiKeys.d.ts +2 -0
  29. package/dist/server/collections/apiKeys.js +34 -0
  30. package/dist/server/index.d.ts +1 -0
  31. package/dist/server/index.js +33 -0
  32. package/dist/server/locale/en-US.d.ts +2 -0
  33. package/dist/server/locale/en-US.js +23 -0
  34. package/dist/server/locale/fr-FR.d.ts +2 -0
  35. package/dist/server/locale/fr-FR.js +23 -0
  36. package/dist/server/locale/index.d.ts +2 -0
  37. package/dist/server/locale/index.js +40 -0
  38. package/dist/server/locale/zh-CN.d.ts +4 -0
  39. package/dist/server/locale/zh-CN.js +25 -0
  40. package/dist/server/plugin.d.ts +7 -0
  41. package/dist/server/plugin.js +85 -0
  42. package/dist/swagger/index.d.ts +106 -0
  43. package/dist/swagger/index.js +130 -0
  44. package/docs/en-US/changelog.md +1 -0
  45. package/docs/en-US/index.md +9 -0
  46. package/docs/en-US/tabs.json +14 -0
  47. package/docs/en-US/usage.md +21 -0
  48. package/docs/zh-CN/changelog.md +1 -0
  49. package/docs/zh-CN/index.md +10 -0
  50. package/docs/zh-CN/tabs.json +14 -0
  51. package/docs/zh-CN/usage.md +21 -0
  52. package/package.json +34 -0
  53. package/server.d.ts +3 -0
  54. package/server.js +1 -0
package/dist/locale.js ADDED
@@ -0,0 +1,30 @@
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 locale_exports = {};
19
+ __export(locale_exports, {
20
+ generateNTemplate: () => generateNTemplate
21
+ });
22
+ module.exports = __toCommonJS(locale_exports);
23
+ var import_constants = require("./constants");
24
+ function generateNTemplate(key) {
25
+ return `{{t('${key}', { ns: '${import_constants.NAMESPACE}', nsMode: 'fallback' })}}`;
26
+ }
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ generateNTemplate
30
+ });
@@ -0,0 +1,3 @@
1
+ import { Context, Next } from '@tachybase/actions';
2
+ export declare function create(ctx: Context, next: Next): Promise<void>;
3
+ export declare function destroy(ctx: Context, next: Next): Promise<void>;
@@ -0,0 +1,84 @@
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 api_keys_exports = {};
29
+ __export(api_keys_exports, {
30
+ create: () => create,
31
+ destroy: () => destroy
32
+ });
33
+ module.exports = __toCommonJS(api_keys_exports);
34
+ var import_crypto = require("crypto");
35
+ var import_actions = __toESM(require("@tachybase/actions"));
36
+ async function create(ctx, next) {
37
+ const { values } = ctx.action.params;
38
+ if (!values.role) {
39
+ return;
40
+ }
41
+ const repository = ctx.db.getRepository("users.roles", ctx.auth.user.id);
42
+ const role = await repository.findOne({
43
+ filter: {
44
+ name: values.role.name
45
+ }
46
+ });
47
+ if (!role) {
48
+ throw ctx.throw(400, ctx.t("Role not found"));
49
+ }
50
+ const hash = (0, import_crypto.createHash)("sha256");
51
+ const jwtToken = ctx.app.authManager.jwt.sign(
52
+ { userId: ctx.auth.user.id, roleName: role.name },
53
+ { expiresIn: values.expiresIn }
54
+ );
55
+ hash.update(jwtToken);
56
+ const token = hash.digest("hex");
57
+ ctx.action.mergeParams({
58
+ values: {
59
+ token: jwtToken,
60
+ accessToken: token
61
+ }
62
+ });
63
+ return import_actions.default.create(ctx, async () => {
64
+ ctx.body = {
65
+ token
66
+ };
67
+ await next();
68
+ });
69
+ }
70
+ async function destroy(ctx, next) {
71
+ const repo = ctx.db.getRepository(ctx.action.resourceName);
72
+ const { filterByTk } = ctx.action.params;
73
+ const data = await repo.findById(filterByTk);
74
+ const token = data == null ? void 0 : data.get("token");
75
+ if (token) {
76
+ await ctx.app.authManager.jwt.block(token);
77
+ }
78
+ return import_actions.default.destroy(ctx, next);
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ create,
83
+ destroy
84
+ });
@@ -0,0 +1,2 @@
1
+ import apiKeys from '../../collections/apiKeys';
2
+ export default apiKeys;
@@ -0,0 +1,34 @@
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 apiKeys_exports = {};
29
+ __export(apiKeys_exports, {
30
+ default: () => apiKeys_default
31
+ });
32
+ module.exports = __toCommonJS(apiKeys_exports);
33
+ var import_apiKeys = __toESM(require("../../collections/apiKeys"));
34
+ var apiKeys_default = import_apiKeys.default;
@@ -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,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,23 @@
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 en_US_exports = {};
19
+ __export(en_US_exports, {
20
+ default: () => en_US_default
21
+ });
22
+ module.exports = __toCommonJS(en_US_exports);
23
+ var en_US_default = {};
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,23 @@
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 fr_FR_exports = {};
19
+ __export(fr_FR_exports, {
20
+ default: () => fr_FR_default
21
+ });
22
+ module.exports = __toCommonJS(fr_FR_exports);
23
+ var fr_FR_default = {};
@@ -0,0 +1,2 @@
1
+ export { default as enUS } from './en-US';
2
+ export { default as zhCN } from './zh-CN';
@@ -0,0 +1,40 @@
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 locale_exports = {};
29
+ __export(locale_exports, {
30
+ enUS: () => import_en_US.default,
31
+ zhCN: () => import_zh_CN.default
32
+ });
33
+ module.exports = __toCommonJS(locale_exports);
34
+ var import_en_US = __toESM(require("./en-US"));
35
+ var import_zh_CN = __toESM(require("./zh-CN"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ enUS,
39
+ zhCN
40
+ });
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ 'Role not found': string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,25 @@
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 zh_CN_exports = {};
19
+ __export(zh_CN_exports, {
20
+ default: () => zh_CN_default
21
+ });
22
+ module.exports = __toCommonJS(zh_CN_exports);
23
+ var zh_CN_default = {
24
+ "Role not found": "\u89D2\u8272\u4E0D\u5B58\u5728"
25
+ };
@@ -0,0 +1,7 @@
1
+ import { Plugin } from '@tachybase/server';
2
+ export declare class PluginAPIKeysServer extends Plugin {
3
+ resourceName: string;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ }
7
+ export default PluginAPIKeysServer;
@@ -0,0 +1,85 @@
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
+ PluginAPIKeysServer: () => PluginAPIKeysServer,
21
+ default: () => plugin_default
22
+ });
23
+ module.exports = __toCommonJS(plugin_exports);
24
+ var import_server = require("@tachybase/server");
25
+ var import_api_keys = require("./actions/api-keys");
26
+ class PluginAPIKeysServer extends import_server.Plugin {
27
+ resourceName = "apiKeys";
28
+ async beforeLoad() {
29
+ this.app.resourcer.define({
30
+ name: this.resourceName,
31
+ actions: {
32
+ create: import_api_keys.create,
33
+ destroy: import_api_keys.destroy
34
+ },
35
+ only: ["list", "create", "destroy"]
36
+ });
37
+ this.app.acl.registerSnippet({
38
+ name: ["pm", this.name, "configuration"].join("."),
39
+ actions: ["apiKeys:list", "apiKeys:create", "apiKeys:destroy"]
40
+ });
41
+ }
42
+ async load() {
43
+ const repo = this.db.getRepository("apiKeys");
44
+ this.app.resourcer.use(
45
+ async (ctx, next) => {
46
+ const token = ctx.getBearerToken();
47
+ if ((token == null ? void 0 : token.length) !== 64) {
48
+ return await next();
49
+ }
50
+ const key = await repo.findOne({
51
+ filter: {
52
+ accessToken: token
53
+ }
54
+ });
55
+ ctx.getBearerToken = () => {
56
+ if (key) {
57
+ return key.token;
58
+ }
59
+ return token;
60
+ };
61
+ await next();
62
+ },
63
+ { tag: "api-access-token", before: "auth" }
64
+ );
65
+ this.app.resourcer.use(
66
+ async (ctx, next) => {
67
+ const { resourceName, actionName } = ctx.action;
68
+ if (resourceName === this.resourceName && ["list", "destroy"].includes(actionName)) {
69
+ ctx.action.mergeParams({
70
+ filter: {
71
+ createdById: ctx.auth.user.id
72
+ }
73
+ });
74
+ }
75
+ await next();
76
+ },
77
+ { tag: "resourceNameListDestroyFilter" }
78
+ );
79
+ }
80
+ }
81
+ var plugin_default = PluginAPIKeysServer;
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ PluginAPIKeysServer
85
+ });
@@ -0,0 +1,106 @@
1
+ declare const _default: {
2
+ info: {
3
+ title: string;
4
+ };
5
+ tags: any[];
6
+ paths: {
7
+ '/apiKeys:create': {
8
+ post: {
9
+ description: string;
10
+ tags: string[];
11
+ requestBody: {
12
+ content: {
13
+ 'application/json': {
14
+ schema: {
15
+ $ref: string;
16
+ };
17
+ };
18
+ };
19
+ };
20
+ responses: {
21
+ 200: {
22
+ description: string;
23
+ content: {
24
+ 'application/json': {
25
+ schema: {
26
+ type: string;
27
+ properties: {
28
+ token: {
29
+ type: string;
30
+ };
31
+ };
32
+ };
33
+ };
34
+ };
35
+ };
36
+ };
37
+ };
38
+ };
39
+ '/apiKeys:list': {
40
+ get: {
41
+ description: string;
42
+ tags: string[];
43
+ responses: {
44
+ 200: {
45
+ description: string;
46
+ content: {
47
+ 'application/json': {
48
+ schema: {
49
+ type: string;
50
+ items: {
51
+ $ref: string;
52
+ };
53
+ };
54
+ };
55
+ };
56
+ };
57
+ };
58
+ };
59
+ };
60
+ '/apiKeys:destroy/{filterByTk}': {
61
+ delete: {
62
+ description: string;
63
+ tags: string[];
64
+ parameters: {
65
+ name: string;
66
+ description: string;
67
+ required: boolean;
68
+ in: string;
69
+ schema: {
70
+ type: string;
71
+ example: number;
72
+ };
73
+ }[];
74
+ responses: {
75
+ 200: {
76
+ description: string;
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ components: {
83
+ schemas: {
84
+ apiKeys: {
85
+ type: string;
86
+ properties: {
87
+ id: {
88
+ type: string;
89
+ };
90
+ name: {
91
+ type: string;
92
+ example: string;
93
+ };
94
+ role: {
95
+ type: string;
96
+ };
97
+ expiresIn: {
98
+ type: string;
99
+ enum: string[];
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ export default _default;
@@ -0,0 +1,130 @@
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
+ var swagger_default = {
24
+ info: {
25
+ title: "TachyBase API - API keys plugin"
26
+ },
27
+ tags: [],
28
+ paths: {
29
+ "/apiKeys:create": {
30
+ post: {
31
+ description: "Create api key",
32
+ tags: ["apiKeys"],
33
+ requestBody: {
34
+ content: {
35
+ "application/json": {
36
+ schema: {
37
+ $ref: "#/components/schemas/apiKeys"
38
+ }
39
+ }
40
+ }
41
+ },
42
+ responses: {
43
+ 200: {
44
+ description: "successful operation",
45
+ content: {
46
+ "application/json": {
47
+ schema: {
48
+ type: "object",
49
+ properties: {
50
+ token: {
51
+ type: "string"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ "/apiKeys:list": {
62
+ get: {
63
+ description: "get api keys",
64
+ tags: ["apiKeys"],
65
+ responses: {
66
+ 200: {
67
+ description: "successful operation",
68
+ content: {
69
+ "application/json": {
70
+ schema: {
71
+ type: "array",
72
+ items: {
73
+ $ref: "#/components/schemas/apiKeys"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ },
82
+ "/apiKeys:destroy/{filterByTk}": {
83
+ delete: {
84
+ description: "Create api key",
85
+ tags: ["apiKeys"],
86
+ parameters: [
87
+ {
88
+ name: "filterByTk",
89
+ description: "primary key",
90
+ required: true,
91
+ in: "path",
92
+ schema: {
93
+ type: "integer",
94
+ example: 1
95
+ }
96
+ }
97
+ ],
98
+ responses: {
99
+ 200: {
100
+ description: "successful operation"
101
+ }
102
+ }
103
+ }
104
+ }
105
+ },
106
+ components: {
107
+ schemas: {
108
+ apiKeys: {
109
+ type: "object",
110
+ properties: {
111
+ id: {
112
+ type: "integer"
113
+ },
114
+ name: {
115
+ type: "string",
116
+ example: "key-name"
117
+ },
118
+ role: {
119
+ type: "object"
120
+ // $ref: '#/components/schemas/roles'
121
+ },
122
+ expiresIn: {
123
+ type: "string",
124
+ enum: ["1d", "7d", "30d", "90d", "never"]
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ };
@@ -0,0 +1 @@
1
+ # API keys Changelog
@@ -0,0 +1,9 @@
1
+ # API keys
2
+
3
+ ## Introduction
4
+
5
+ This plugin allows you to create and manage API keys. The generated API key can be used to access all `TachyBase` APIs.
6
+
7
+ ## Access control
8
+
9
+ When creating an API key, you can bind it to a role, and the role's permissions will be the same as the Key's permissions.