@nocobase/plugin-users 0.5.0-alpha.38 → 0.7.0-alpha.2

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 (85) hide show
  1. package/LICENSE +201 -21
  2. package/esm/actions/users.d.ts +11 -0
  3. package/esm/actions/users.js +165 -0
  4. package/esm/actions/users.js.map +1 -0
  5. package/esm/collections/roles-users.d.ts +3 -0
  6. package/esm/collections/roles-users.js +5 -0
  7. package/esm/collections/roles-users.js.map +1 -0
  8. package/esm/collections/users.d.ts +3 -0
  9. package/esm/collections/users.js +86 -0
  10. package/esm/collections/users.js.map +1 -0
  11. package/esm/index.d.ts +1 -0
  12. package/esm/index.js +2 -0
  13. package/esm/index.js.map +1 -0
  14. package/esm/jwt-service.d.ts +12 -0
  15. package/esm/jwt-service.js +26 -0
  16. package/esm/jwt-service.js.map +1 -0
  17. package/esm/middlewares/check.d.ts +1 -0
  18. package/esm/middlewares/check.js +22 -0
  19. package/esm/middlewares/check.js.map +1 -0
  20. package/esm/middlewares/index.d.ts +2 -0
  21. package/esm/middlewares/index.js +3 -0
  22. package/esm/middlewares/index.js.map +1 -0
  23. package/esm/middlewares/parseToken.d.ts +6 -0
  24. package/esm/middlewares/parseToken.js +64 -0
  25. package/esm/middlewares/parseToken.js.map +1 -0
  26. package/esm/models/UserModel.d.ts +4 -0
  27. package/esm/models/UserModel.js +53 -0
  28. package/esm/models/UserModel.js.map +1 -0
  29. package/esm/server.d.ts +23 -0
  30. package/esm/server.js +133 -0
  31. package/esm/server.js.map +1 -0
  32. package/lib/actions/users.d.ts +1 -0
  33. package/lib/actions/users.js +145 -241
  34. package/lib/actions/users.js.map +1 -1
  35. package/lib/collections/roles-users.d.ts +3 -0
  36. package/lib/collections/roles-users.js +7 -0
  37. package/lib/collections/roles-users.js.map +1 -0
  38. package/lib/collections/users.d.ts +2 -2
  39. package/lib/collections/users.js +85 -112
  40. package/lib/collections/users.js.map +1 -1
  41. package/lib/index.js +5 -30
  42. package/lib/index.js.map +1 -1
  43. package/lib/jwt-service.d.ts +12 -0
  44. package/lib/jwt-service.js +33 -0
  45. package/lib/jwt-service.js.map +1 -0
  46. package/lib/middlewares/check.d.ts +1 -1
  47. package/lib/middlewares/check.js +22 -60
  48. package/lib/middlewares/check.js.map +1 -1
  49. package/lib/middlewares/index.d.ts +2 -2
  50. package/lib/middlewares/index.js +6 -41
  51. package/lib/middlewares/index.js.map +1 -1
  52. package/lib/middlewares/parseToken.d.ts +6 -1
  53. package/lib/middlewares/parseToken.js +62 -63
  54. package/lib/middlewares/parseToken.js.map +1 -1
  55. package/lib/models/UserModel.d.ts +4 -0
  56. package/lib/models/UserModel.js +57 -0
  57. package/lib/models/UserModel.js.map +1 -0
  58. package/lib/server.d.ts +23 -3
  59. package/lib/server.js +147 -159
  60. package/lib/server.js.map +1 -1
  61. package/package.json +17 -6
  62. package/tsconfig.build.json +9 -0
  63. package/lib/actions/users.d.ts.map +0 -1
  64. package/lib/collections/users.d.ts.map +0 -1
  65. package/lib/fields/CreatedBy.d.ts +0 -11
  66. package/lib/fields/CreatedBy.d.ts.map +0 -1
  67. package/lib/fields/CreatedBy.js +0 -66
  68. package/lib/fields/CreatedBy.js.map +0 -1
  69. package/lib/fields/UpdatedBy.d.ts +0 -16
  70. package/lib/fields/UpdatedBy.d.ts.map +0 -1
  71. package/lib/fields/UpdatedBy.js +0 -87
  72. package/lib/fields/UpdatedBy.js.map +0 -1
  73. package/lib/fields/index.d.ts +0 -2
  74. package/lib/fields/index.d.ts.map +0 -1
  75. package/lib/fields/index.js +0 -43
  76. package/lib/fields/index.js.map +0 -1
  77. package/lib/fields/utils.d.ts +0 -4
  78. package/lib/fields/utils.d.ts.map +0 -1
  79. package/lib/fields/utils.js +0 -51
  80. package/lib/fields/utils.js.map +0 -1
  81. package/lib/index.d.ts.map +0 -1
  82. package/lib/middlewares/check.d.ts.map +0 -1
  83. package/lib/middlewares/index.d.ts.map +0 -1
  84. package/lib/middlewares/parseToken.d.ts.map +0 -1
  85. package/lib/server.d.ts.map +0 -1
@@ -1,115 +1,88 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- Object.defineProperty(exports, "__esModule", {
16
- value: true
17
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.default = {
19
- name: 'users',
20
- title: '{{t("Users")}}',
21
- sortable: 'sort',
22
- createdBy: false,
23
- updatedBy: false,
24
- privilege: 'undelete',
25
- scopes: {
26
- withPassword: {
27
- attributes: {
28
- include: ['password']
29
- }
30
- }
31
- },
32
- defaultScope: {
33
- attributes: {
34
- exclude: ['password']
35
- }
36
- },
37
- fields: [{
38
- interface: 'string',
39
- type: 'string',
40
- name: 'nickname',
41
- uiSchema: {
42
- type: 'string',
43
- title: '{{t("Nickname")}}',
44
- 'x-component': 'Input'
45
- }
46
- }, {
47
- interface: 'email',
48
- type: 'string',
49
- name: 'email',
50
- unique: true,
51
- privilege: 'undelete',
52
- uiSchema: {
53
- type: 'string',
54
- title: '{{t("Email")}}',
55
- 'x-component': 'Input',
56
- require: true
57
- }
58
- }, {
59
- interface: 'password',
60
- type: 'password',
61
- name: 'password',
62
- privilege: 'undelete',
63
- uiSchema: {
64
- type: 'string',
65
- title: '{{t("Password")}}',
66
- 'x-component': 'Password'
67
- }
68
- }, {
69
- interface: 'linkTo',
70
- type: 'belongsToMany',
71
- name: 'roles',
72
- target: 'roles',
73
- foreignKey: 'user_id',
74
- otherKey: 'role_name',
75
- sourceKey: 'id',
76
- targetKey: 'name',
77
- uiSchema: {
78
- type: 'array',
79
- title: '{{t("Roles")}}',
80
- 'x-component': 'Select.Drawer',
81
- 'x-component-props': {
82
- multiple: true,
83
- fieldNames: {
84
- label: 'title',
85
- value: 'name'
86
- }
87
- },
88
- 'x-decorator': 'FormItem',
89
- 'x-designable-bar': 'Select.Drawer.DesignableBar'
90
- }
91
- }, {
92
- interface: 'select',
93
- type: 'string',
94
- name: 'appLang',
95
- privilege: 'undelete',
96
- state: 0
97
- }, {
98
- interface: 'password',
99
- type: 'string',
100
- name: 'token',
101
- unique: true,
102
- hidden: true,
103
- privilege: 'undelete',
104
- state: 0
105
- }, {
106
- interface: 'password',
107
- type: 'string',
108
- name: 'reset_token',
109
- unique: true,
110
- hidden: true,
111
- privilege: 'undelete',
112
- state: 0
113
- }]
4
+ name: 'users',
5
+ title: '{{t("Users")}}',
6
+ sortable: 'sort',
7
+ model: 'UserModel',
8
+ createdBy: true,
9
+ updatedBy: true,
10
+ fields: [
11
+ {
12
+ name: 'id',
13
+ type: 'integer',
14
+ autoIncrement: true,
15
+ primaryKey: true,
16
+ allowNull: false,
17
+ uiSchema: { type: 'number', title: '{{t("ID")}}', 'x-component': 'InputNumber', 'x-read-pretty': true },
18
+ interface: 'id',
19
+ },
20
+ {
21
+ interface: 'input',
22
+ type: 'string',
23
+ name: 'nickname',
24
+ uiSchema: {
25
+ type: 'string',
26
+ title: '{{t("Nickname")}}',
27
+ 'x-component': 'Input',
28
+ },
29
+ },
30
+ {
31
+ interface: 'email',
32
+ type: 'string',
33
+ name: 'email',
34
+ unique: true,
35
+ uiSchema: {
36
+ type: 'string',
37
+ title: '{{t("Email")}}',
38
+ 'x-component': 'Input',
39
+ require: true,
40
+ },
41
+ },
42
+ {
43
+ interface: 'password',
44
+ type: 'password',
45
+ name: 'password',
46
+ hidden: true,
47
+ uiSchema: {
48
+ type: 'string',
49
+ title: '{{t("Password")}}',
50
+ 'x-component': 'Password',
51
+ },
52
+ },
53
+ {
54
+ interface: 'linkTo',
55
+ type: 'belongsToMany',
56
+ name: 'roles',
57
+ target: 'roles',
58
+ foreignKey: 'userId',
59
+ otherKey: 'roleName',
60
+ sourceKey: 'id',
61
+ targetKey: 'name',
62
+ through: 'rolesUsers',
63
+ uiSchema: {
64
+ type: 'array',
65
+ title: '{{t("Roles")}}',
66
+ 'x-component': 'RecordPicker',
67
+ 'x-component-props': {
68
+ multiple: true,
69
+ fieldNames: {
70
+ label: 'title',
71
+ value: 'name',
72
+ },
73
+ },
74
+ },
75
+ },
76
+ {
77
+ type: 'string',
78
+ name: 'appLang',
79
+ },
80
+ {
81
+ type: 'string',
82
+ name: 'resetToken',
83
+ unique: true,
84
+ hidden: true,
85
+ },
86
+ ],
114
87
  };
115
- //# sourceMappingURL=users.js.map
88
+ //# sourceMappingURL=users.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["collections/users.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,MAAM;IAGhB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE;QACN,YAAY,EAAE;YACZ,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE;SACtC;KACF;IACD,YAAY,EAAE;QACZ,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE;KACtC;IACD,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EAAE,OAAO;aACvB;SACF;QACD;YACE,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,UAAU;YACrB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,gBAAgB;gBACvB,aAAa,EAAE,OAAO;gBACtB,OAAO,EAAE,IAAI;aACd;SACF;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,UAAU;YACrB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EAAE,UAAU;aAC1B;SACF;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,gBAAgB;gBACvB,aAAa,EAAE,eAAe;gBAC9B,mBAAmB,EAAE;oBACnB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE;wBACV,KAAK,EAAE,OAAO;wBACd,KAAK,EAAE,MAAM;qBACd;iBACF;gBACD,aAAa,EAAE,UAAU;gBACzB,kBAAkB,EAAE,6BAA6B;aAClD;SACF;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,CAAC;SACT;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,CAAC;SACT;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,CAAC;SACT;KACF;CACc,CAAC","file":"users.js","sourcesContent":["import { TableOptions } from '@nocobase/database';\n\nexport default {\n name: 'users',\n title: '{{t(\"Users\")}}',\n sortable: 'sort',\n // developerMode: true,\n // internal: true,\n createdBy: false,\n updatedBy: false,\n privilege: 'undelete',\n scopes: {\n withPassword: {\n attributes: { include: ['password'] },\n },\n },\n defaultScope: {\n attributes: { exclude: ['password'] },\n },\n fields: [\n {\n interface: 'string',\n type: 'string',\n name: 'nickname',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Nickname\")}}',\n 'x-component': 'Input',\n },\n },\n {\n interface: 'email',\n type: 'string',\n name: 'email',\n unique: true,\n privilege: 'undelete',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Email\")}}',\n 'x-component': 'Input',\n require: true,\n },\n },\n {\n interface: 'password',\n type: 'password',\n name: 'password',\n privilege: 'undelete',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Password\")}}',\n 'x-component': 'Password',\n },\n },\n {\n interface: 'linkTo',\n type: 'belongsToMany',\n name: 'roles',\n target: 'roles',\n foreignKey: 'user_id',\n otherKey: 'role_name',\n sourceKey: 'id',\n targetKey: 'name',\n uiSchema: {\n type: 'array',\n title: '{{t(\"Roles\")}}',\n 'x-component': 'Select.Drawer',\n 'x-component-props': {\n multiple: true,\n fieldNames: {\n label: 'title',\n value: 'name',\n },\n },\n 'x-decorator': 'FormItem',\n 'x-designable-bar': 'Select.Drawer.DesignableBar',\n },\n },\n {\n interface: 'select',\n type: 'string',\n name: 'appLang',\n privilege: 'undelete',\n state: 0,\n },\n {\n interface: 'password',\n type: 'string',\n name: 'token',\n unique: true,\n hidden: true,\n privilege: 'undelete',\n state: 0,\n },\n {\n interface: 'password',\n type: 'string',\n name: 'reset_token',\n unique: true,\n hidden: true,\n privilege: 'undelete',\n state: 0,\n },\n ],\n} as TableOptions;\n"]}
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/collections/users.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,WAAW;IAClB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,MAAM,EAAE;QACN;YACE,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,SAAS;YACf,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,IAAI,EAAE;YACvG,SAAS,EAAE,IAAI;SAChB;QACD;YACE,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EAAE,OAAO;aACvB;SACF;QACD;YACE,SAAS,EAAE,OAAO;YAClB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,gBAAgB;gBACvB,aAAa,EAAE,OAAO;gBACtB,OAAO,EAAE,IAAI;aACd;SACF;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EAAE,UAAU;aAC1B;SACF;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,MAAM;YACjB,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,gBAAgB;gBACvB,aAAa,EAAE,cAAc;gBAC7B,mBAAmB,EAAE;oBACnB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE;wBACV,KAAK,EAAE,OAAO;wBACd,KAAK,EAAE,MAAM;qBACd;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,SAAS;SAChB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;SACb;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'users',\n title: '{{t(\"Users\")}}',\n sortable: 'sort',\n model: 'UserModel',\n createdBy: true,\n updatedBy: true,\n fields: [\n {\n name: 'id',\n type: 'integer',\n autoIncrement: true,\n primaryKey: true,\n allowNull: false,\n uiSchema: { type: 'number', title: '{{t(\"ID\")}}', 'x-component': 'InputNumber', 'x-read-pretty': true },\n interface: 'id',\n },\n {\n interface: 'input',\n type: 'string',\n name: 'nickname',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Nickname\")}}',\n 'x-component': 'Input',\n },\n },\n {\n interface: 'email',\n type: 'string',\n name: 'email',\n unique: true,\n uiSchema: {\n type: 'string',\n title: '{{t(\"Email\")}}',\n 'x-component': 'Input',\n require: true,\n },\n },\n {\n interface: 'password',\n type: 'password',\n name: 'password',\n hidden: true,\n uiSchema: {\n type: 'string',\n title: '{{t(\"Password\")}}',\n 'x-component': 'Password',\n },\n },\n {\n interface: 'linkTo',\n type: 'belongsToMany',\n name: 'roles',\n target: 'roles',\n foreignKey: 'userId',\n otherKey: 'roleName',\n sourceKey: 'id',\n targetKey: 'name',\n through: 'rolesUsers',\n uiSchema: {\n type: 'array',\n title: '{{t(\"Roles\")}}',\n 'x-component': 'RecordPicker',\n 'x-component-props': {\n multiple: true,\n fieldNames: {\n label: 'title',\n value: 'name',\n },\n },\n },\n },\n {\n type: 'string',\n name: 'appLang',\n },\n {\n type: 'string',\n name: 'resetToken',\n unique: true,\n hidden: true,\n },\n ],\n} as CollectionOptions;\n"]}
package/lib/index.js CHANGED
@@ -1,34 +1,9 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
16
- return mod && mod.__esModule ? mod : {
17
- "default": mod
18
- };
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
-
21
- Object.defineProperty(exports, "__esModule", {
22
- value: true
23
- });
5
+ Object.defineProperty(exports, "__esModule", { value: true });
24
6
  exports.default = void 0;
25
-
26
7
  var server_1 = require("./server");
27
-
28
- Object.defineProperty(exports, "default", {
29
- enumerable: true,
30
- get: function get() {
31
- return __importDefault(server_1).default;
32
- }
33
- });
34
- //# sourceMappingURL=index.js.map
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(server_1).default; } });
9
+ //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","file":"index.js","sourcesContent":["export { default } from './server';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export { default } from './server';\n"]}
@@ -0,0 +1,12 @@
1
+ export interface JwtOptions {
2
+ secret: string;
3
+ expiresIn?: string;
4
+ }
5
+ export declare class JwtService {
6
+ protected options: JwtOptions;
7
+ constructor(options: JwtOptions);
8
+ private expiresIn;
9
+ private secret;
10
+ sign(payload: any): string;
11
+ decode(token: string): Promise<any>;
12
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JwtService = void 0;
7
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
+ class JwtService {
9
+ constructor(options) {
10
+ this.options = options;
11
+ }
12
+ expiresIn() {
13
+ return this.options.expiresIn || '7d';
14
+ }
15
+ secret() {
16
+ return this.options.secret;
17
+ }
18
+ sign(payload) {
19
+ return jsonwebtoken_1.default.sign(payload, this.secret(), { expiresIn: this.expiresIn() });
20
+ }
21
+ decode(token) {
22
+ return new Promise((resolve, reject) => {
23
+ jsonwebtoken_1.default.verify(token, this.secret(), (err, decoded) => {
24
+ if (err) {
25
+ return reject(err);
26
+ }
27
+ resolve(decoded);
28
+ });
29
+ });
30
+ }
31
+ }
32
+ exports.JwtService = JwtService;
33
+ //# sourceMappingURL=jwt-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-service.js","sourceRoot":"","sources":["../src/jwt-service.ts"],"names":[],"mappings":";;;;;;AAAA,gEAA+B;AAO/B,MAAa,UAAU;IACrB,YAAsB,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAErC,SAAS;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IACxC,CAAC;IAEO,MAAM;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,OAAY;QACf,OAAO,sBAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,GAAQ,EAAE,OAAY,EAAE,EAAE;gBAC1D,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;gBAED,OAAO,CAAC,OAAO,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,gCA0BC","sourcesContent":["import jwt from 'jsonwebtoken';\n\nexport interface JwtOptions {\n secret: string;\n expiresIn?: string;\n}\n\nexport class JwtService {\n constructor(protected options: JwtOptions) {}\n\n private expiresIn() {\n return this.options.expiresIn || '7d';\n }\n\n private secret() {\n return this.options.secret;\n }\n\n sign(payload: any) {\n return jwt.sign(payload, this.secret(), { expiresIn: this.expiresIn() });\n }\n\n decode(token: string): Promise<any> {\n return new Promise((resolve, reject) => {\n jwt.verify(token, this.secret(), (err: any, decoded: any) => {\n if (err) {\n return reject(err);\n }\n\n resolve(decoded);\n });\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- export default function (options: any): (ctx: any, next: any) => Promise<any>;
1
+ export declare function check(options: any): (ctx: any, next: any) => Promise<any>;
@@ -1,64 +1,26 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) {
17
- return value instanceof P ? value : new P(function (resolve) {
18
- resolve(value);
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
9
  });
20
- }
21
-
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- }
30
-
31
- function rejected(value) {
32
- try {
33
- step(generator["throw"](value));
34
- } catch (e) {
35
- reject(e);
36
- }
37
- }
38
-
39
- function step(result) {
40
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41
- }
42
-
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
10
  };
46
-
47
- Object.defineProperty(exports, "__esModule", {
48
- value: true
49
- });
50
-
51
- function default_1(options) {
52
- return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
53
- const currentUser = ctx.state.currentUser;
54
-
55
- if (!currentUser) {
56
- return ctx.throw(401, 'Unauthorized');
57
- }
58
-
59
- return next();
60
- });
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.check = void 0;
13
+ // TODO(usage): 拦截用户的处理暂时作为一个中间件导出,应用需要的时候可以直接使用这个中间件
14
+ function check(options) {
15
+ return function check(ctx, next) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const { currentUser } = ctx.state;
18
+ if (!currentUser) {
19
+ return ctx.throw(401, 'Unauthorized');
20
+ }
21
+ return next();
22
+ });
23
+ };
61
24
  }
62
-
63
- exports.default = default_1;
64
- //# sourceMappingURL=check.js.map
25
+ exports.check = check;
26
+ //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["middlewares/check.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,mBAAyB,OAAO;IAC9B,OAAO,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;QAClC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;SACvC;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAA,CAAC;AACJ,CAAC;AATD,4BASC","file":"check.js","sourcesContent":["// TODO(usage): 拦截用户的处理暂时作为一个中间件导出,应用需要的时候可以直接使用这个中间件\nexport default function (options) {\n return async (ctx, next) => {\n const { currentUser } = ctx.state;\n if (!currentUser) {\n return ctx.throw(401, 'Unauthorized');\n }\n\n return next();\n };\n}\n"]}
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/middlewares/check.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAqD;AACrD,SAAgB,KAAK,CAAC,OAAO;IAC3B,OAAO,SAAe,KAAK,CAAC,GAAG,EAAE,IAAI;;YACnC,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;YAClC,IAAI,CAAC,WAAW,EAAE;gBAChB,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;aACvC;YACD,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KAAA,CAAC;AACJ,CAAC;AARD,sBAQC","sourcesContent":["// TODO(usage): 拦截用户的处理暂时作为一个中间件导出,应用需要的时候可以直接使用这个中间件\nexport function check(options) {\n return async function check(ctx, next) {\n const { currentUser } = ctx.state;\n if (!currentUser) {\n return ctx.throw(401, 'Unauthorized');\n }\n return next();\n };\n}\n"]}
@@ -1,2 +1,2 @@
1
- export { default as parseToken } from './parseToken';
2
- export { default as check } from './check';
1
+ export { check } from './check';
2
+ export { parseToken } from './parseToken';
@@ -1,43 +1,8 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
16
- return mod && mod.__esModule ? mod : {
17
- "default": mod
18
- };
19
- };
20
-
21
- Object.defineProperty(exports, "__esModule", {
22
- value: true
23
- });
24
- exports.check = exports.parseToken = void 0;
25
-
26
- var parseToken_1 = require("./parseToken");
27
-
28
- Object.defineProperty(exports, "parseToken", {
29
- enumerable: true,
30
- get: function get() {
31
- return __importDefault(parseToken_1).default;
32
- }
33
- });
34
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseToken = exports.check = void 0;
35
4
  var check_1 = require("./check");
36
-
37
- Object.defineProperty(exports, "check", {
38
- enumerable: true,
39
- get: function get() {
40
- return __importDefault(check_1).default;
41
- }
42
- });
43
- //# sourceMappingURL=index.js.map
5
+ Object.defineProperty(exports, "check", { enumerable: true, get: function () { return check_1.check; } });
6
+ var parseToken_1 = require("./parseToken");
7
+ Object.defineProperty(exports, "parseToken", { enumerable: true, get: function () { return parseToken_1.parseToken; } });
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["middlewares/index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAqD;AAA5C,yHAAA,OAAO,OAAc;AAC9B,iCAA2C;AAAlC,+GAAA,OAAO,OAAS","file":"index.js","sourcesContent":["export { default as parseToken } from './parseToken';\nexport { default as check } from './check';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,2CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["export { check } from './check';\nexport { parseToken } from './parseToken';\n"]}
@@ -1 +1,6 @@
1
- export default function (options: any): (ctx: any, next: any) => Promise<any>;
1
+ import { Context, Next } from '@nocobase/actions';
2
+ import UsersPlugin from '../server';
3
+ export declare function parseToken(options?: {
4
+ plugin: UsersPlugin;
5
+ }): (ctx: Context, next: Next) => Promise<any>;
6
+ export declare function setCurrentRole(ctx: any): void;
@@ -1,70 +1,69 @@
1
1
  "use strict";
2
-
3
- function _react() {
4
- const data = _interopRequireDefault(require("react"));
5
-
6
- _react = function _react() {
7
- return data;
8
- };
9
-
10
- return data;
11
- }
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) {
17
- return value instanceof P ? value : new P(function (resolve) {
18
- resolve(value);
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
9
  });
20
- }
21
-
22
- return new (P || (P = Promise))(function (resolve, reject) {
23
- function fulfilled(value) {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.setCurrentRole = exports.parseToken = void 0;
13
+ function parseToken(options) {
14
+ return function parseToken(ctx, next) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const user = yield findUserByToken(ctx, options.plugin);
17
+ if (user) {
18
+ ctx.state.currentUser = user;
19
+ setCurrentRole(ctx);
20
+ }
21
+ return next();
22
+ });
23
+ };
24
+ }
25
+ exports.parseToken = parseToken;
26
+ function setCurrentRole(ctx) {
27
+ var _a;
28
+ let currentRole = ctx.get('X-Role');
29
+ if (currentRole === 'anonymous') {
30
+ ctx.state.currentRole = currentRole;
31
+ return;
29
32
  }
30
-
31
- function rejected(value) {
32
- try {
33
- step(generator["throw"](value));
34
- } catch (e) {
35
- reject(e);
36
- }
33
+ const userRoles = ctx.state.currentUser.roles;
34
+ if (userRoles.length == 1) {
35
+ currentRole = userRoles[0].name;
37
36
  }
38
-
39
- function step(result) {
40
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
37
+ else if (userRoles.length > 1) {
38
+ const role = userRoles.find((role) => role.name === currentRole);
39
+ if (!role) {
40
+ const defaultRole = userRoles.find((role) => { var _a; return (_a = role === null || role === void 0 ? void 0 : role.rolesUsers) === null || _a === void 0 ? void 0 : _a.default; });
41
+ currentRole = (_a = (defaultRole || userRoles[0])) === null || _a === void 0 ? void 0 : _a.name;
42
+ }
41
43
  }
42
-
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
- };
46
-
47
- Object.defineProperty(exports, "__esModule", {
48
- value: true
49
- });
50
-
51
- function default_1(options) {
52
- return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
53
- const token = ctx.get('Authorization').replace(/^Bearer\s+/gi, '');
54
- const User = ctx.db.getModel('users');
55
- const user = yield User.findOne({
56
- where: {
57
- token
58
- }
59
- });
60
-
61
- if (user) {
62
- ctx.state.currentUser = user;
44
+ if (currentRole) {
45
+ ctx.state.currentRole = currentRole;
63
46
  }
64
-
65
- return next();
66
- });
67
47
  }
68
-
69
- exports.default = default_1;
70
- //# sourceMappingURL=parseToken.js.map
48
+ exports.setCurrentRole = setCurrentRole;
49
+ function findUserByToken(ctx, plugin) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const token = ctx.getBearerToken();
52
+ if (!token) {
53
+ return null;
54
+ }
55
+ try {
56
+ const { userId } = yield plugin.jwtService.decode(token);
57
+ return yield ctx.db.getRepository('users').findOne({
58
+ filter: {
59
+ id: userId,
60
+ },
61
+ appends: ['roles'],
62
+ });
63
+ }
64
+ catch (error) {
65
+ console.warn(error);
66
+ }
67
+ });
68
+ }
69
+ //# sourceMappingURL=parseToken.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["middlewares/parseToken.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,mBAAyB,OAAO;IAC9B,OAAO,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE;gBACL,KAAK;aACN;SACF,CAAC,CAAC;QACH,IAAI,IAAI,EAAE;YACR,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;SAC9B;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAA,CAAC;AACJ,CAAC;AAfD,4BAeC","file":"parseToken.js","sourcesContent":["// TODO(feature): 表名应在 options 中配置\n// 中间件默认只解决解析 token 和附加对应 user 的工作,不解决是否提前报 401 退出。\n// 因为是否提供匿名访问资源是应用决定的,不是使用插件就一定不能匿名访问。\nexport default function (options) {\n return async (ctx, next) => {\n const token = ctx.get('Authorization').replace(/^Bearer\\s+/gi, '');\n const User = ctx.db.getModel('users');\n const user = await User.findOne({\n where: {\n token,\n },\n });\n if (user) {\n ctx.state.currentUser = user;\n }\n\n return next();\n };\n}\n"]}
1
+ {"version":3,"file":"parseToken.js","sourceRoot":"","sources":["../../src/middlewares/parseToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,SAAe,UAAU,CAAC,GAAY,EAAE,IAAU;;YACvD,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACxD,IAAI,IAAI,EAAE;gBACR,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;gBAC7B,cAAc,CAAC,GAAG,CAAC,CAAC;aACrB;YACD,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KAAA,CAAC;AACJ,CAAC;AATD,gCASC;AAED,SAAgB,cAAc,CAAC,GAAG;;IAChC,IAAI,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEpC,IAAI,WAAW,KAAK,WAAW,EAAE;QAC/B,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QACpC,OAAO;KACR;IAED,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC;IAE9C,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QACzB,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACjC;SAAM,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,0CAAE,OAAO,CAAA,EAAA,CAAC,CAAC;YACxE,WAAW,GAAG,MAAA,CAAC,WAAW,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAC;SACnD;KACF;IAED,IAAI,WAAW,EAAE;QACf,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;KACrC;AACH,CAAC;AAvBD,wCAuBC;AAED,SAAe,eAAe,CAAC,GAAY,EAAE,MAAmB;;QAC9D,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,IAAI,CAAC;SACb;QACD,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAEzD,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBACjD,MAAM,EAAE;oBACN,EAAE,EAAE,MAAM;iBACX;gBACD,OAAO,EAAE,CAAC,OAAO,CAAC;aACnB,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrB;IACH,CAAC;CAAA","sourcesContent":["import { Context, Next } from '@nocobase/actions';\nimport UsersPlugin from '../server';\n\nexport function parseToken(options?: { plugin: UsersPlugin }) {\n return async function parseToken(ctx: Context, next: Next) {\n const user = await findUserByToken(ctx, options.plugin);\n if (user) {\n ctx.state.currentUser = user;\n setCurrentRole(ctx);\n }\n return next();\n };\n}\n\nexport function setCurrentRole(ctx) {\n let currentRole = ctx.get('X-Role');\n\n if (currentRole === 'anonymous') {\n ctx.state.currentRole = currentRole;\n return;\n }\n\n const userRoles = ctx.state.currentUser.roles;\n\n if (userRoles.length == 1) {\n currentRole = userRoles[0].name;\n } else if (userRoles.length > 1) {\n const role = userRoles.find((role) => role.name === currentRole);\n if (!role) {\n const defaultRole = userRoles.find((role) => role?.rolesUsers?.default);\n currentRole = (defaultRole || userRoles[0])?.name;\n }\n }\n\n if (currentRole) {\n ctx.state.currentRole = currentRole;\n }\n}\n\nasync function findUserByToken(ctx: Context, plugin: UsersPlugin) {\n const token = ctx.getBearerToken();\n if (!token) {\n return null;\n }\n try {\n const { userId } = await plugin.jwtService.decode(token);\n\n return await ctx.db.getRepository('users').findOne({\n filter: {\n id: userId,\n },\n appends: ['roles'],\n });\n } catch (error) {\n console.warn(error);\n }\n}\n"]}