@tachybase/module-auth 1.6.33 → 1.6.34

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.
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.6.33",
3
+ "@tachybase/client": "1.6.34",
4
4
  "react-router-dom": "6.28.1",
5
5
  "@tego/client": "1.6.17",
6
6
  "axios": "1.13.0",
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { AuthModel, BasicAuth, default } from './server';
1
+ export { AuthModel, BasicAuth, default, isAuthenticationSecretKey, redactSensitiveAuthenticationData, serializeAuthenticatedUser, } from './server';
package/dist/index.js CHANGED
@@ -29,12 +29,18 @@ var index_exports = {};
29
29
  __export(index_exports, {
30
30
  AuthModel: () => import_server.AuthModel,
31
31
  BasicAuth: () => import_server.BasicAuth,
32
- default: () => import_server.default
32
+ default: () => import_server.default,
33
+ isAuthenticationSecretKey: () => import_server.isAuthenticationSecretKey,
34
+ redactSensitiveAuthenticationData: () => import_server.redactSensitiveAuthenticationData,
35
+ serializeAuthenticatedUser: () => import_server.serializeAuthenticatedUser
33
36
  });
34
37
  module.exports = __toCommonJS(index_exports);
35
38
  var import_server = __toESM(require("./server"));
36
39
  // Annotate the CommonJS export names for ESM import in node:
37
40
  0 && (module.exports = {
38
41
  AuthModel,
39
- BasicAuth
42
+ BasicAuth,
43
+ isAuthenticationSecretKey,
44
+ redactSensitiveAuthenticationData,
45
+ serializeAuthenticatedUser
40
46
  });
@@ -1 +1 @@
1
- {"name":"cron","description":"Cron jobs for your node","version":"3.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -b tsconfig.build.json","lint:eslint":"eslint src/ tests/","lint:prettier":"prettier ./**/*.{json,md,yml} --check","lint":"npm run lint:eslint && npm run lint:prettier","lint:fix":"npm run lint:eslint -- --fix && npm run lint:prettier -- --write","test":"jest --coverage","test:watch":"jest --watch --coverage","test:fuzz":"jest --testMatch='**/*.fuzz.ts' --coverage=false --testTimeout=120000","prepare":"husky"},"dependencies":{"@types/luxon":"~3.4.0","luxon":"~3.5.0"},"devDependencies":{"@commitlint/cli":"19.6.0","@eslint/js":"^9.14.0","@fast-check/jest":"2.0.3","@insurgent/commitlint-config":"20.0.0","@insurgent/conventional-changelog-preset":"10.0.0","@semantic-release/changelog":"6.0.3","@semantic-release/commit-analyzer":"13.0.0","@semantic-release/git":"10.0.1","@semantic-release/github":"11.0.1","@semantic-release/npm":"12.0.1","@semantic-release/release-notes-generator":"14.0.1","@types/jest":"29.5.14","@types/node":"20.17.9","@types/sinon":"17.0.3","chai":"4.5.0","eslint":"8.57.1","eslint-config-prettier":"9.1.0","eslint-plugin-jest":"27.9.0","eslint-plugin-prettier":"5.2.1","husky":"9.1.7","jest":"29.7.0","lint-staged":"15.2.10","prettier":"3.3.3","semantic-release":"24.2.0","sinon":"17.0.2","ts-jest":"29.2.5","typescript":"5.7.2","typescript-eslint":"^7.2.0"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Pierre Cavin <me@sherlox.io> (https://github.com/sheerlox)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"files":["dist/**/*.js","dist/**/*.d.ts","CHANGELOG.md","LICENSE","README.md"],"lint-staged":{"*.ts":"eslint src/ tests/ --fix","*.{json,md,yml}":"prettier ./**/*.{json,md,yml} --check --write"},"_lastModified":"2026-08-13T08:16:12.473Z"}
1
+ {"name":"cron","description":"Cron jobs for your node","version":"3.3.1","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -b tsconfig.build.json","lint:eslint":"eslint src/ tests/","lint:prettier":"prettier ./**/*.{json,md,yml} --check","lint":"npm run lint:eslint && npm run lint:prettier","lint:fix":"npm run lint:eslint -- --fix && npm run lint:prettier -- --write","test":"jest --coverage","test:watch":"jest --watch --coverage","test:fuzz":"jest --testMatch='**/*.fuzz.ts' --coverage=false --testTimeout=120000","prepare":"husky"},"dependencies":{"@types/luxon":"~3.4.0","luxon":"~3.5.0"},"devDependencies":{"@commitlint/cli":"19.6.0","@eslint/js":"^9.14.0","@fast-check/jest":"2.0.3","@insurgent/commitlint-config":"20.0.0","@insurgent/conventional-changelog-preset":"10.0.0","@semantic-release/changelog":"6.0.3","@semantic-release/commit-analyzer":"13.0.0","@semantic-release/git":"10.0.1","@semantic-release/github":"11.0.1","@semantic-release/npm":"12.0.1","@semantic-release/release-notes-generator":"14.0.1","@types/jest":"29.5.14","@types/node":"20.17.9","@types/sinon":"17.0.3","chai":"4.5.0","eslint":"8.57.1","eslint-config-prettier":"9.1.0","eslint-plugin-jest":"27.9.0","eslint-plugin-prettier":"5.2.1","husky":"9.1.7","jest":"29.7.0","lint-staged":"15.2.10","prettier":"3.3.3","semantic-release":"24.2.0","sinon":"17.0.2","ts-jest":"29.2.5","typescript":"5.7.2","typescript-eslint":"^7.2.0"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Pierre Cavin <me@sherlox.io> (https://github.com/sheerlox)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"files":["dist/**/*.js","dist/**/*.d.ts","CHANGELOG.md","LICENSE","README.md"],"lint-staged":{"*.ts":"eslint src/ tests/ --fix","*.{json,md,yml}":"prettier ./**/*.{json,md,yml} --check --write"},"_lastModified":"2026-08-13T17:41:37.104Z"}
@@ -1 +1 @@
1
- {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-08-13T08:16:12.578Z"}
1
+ {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-08-13T17:41:37.203Z"}
@@ -1,3 +1,4 @@
1
1
  export { BasicAuth } from './basic-auth';
2
2
  export { AuthModel } from './model/authenticator';
3
+ export { isAuthenticationSecretKey, redactSensitiveAuthenticationData, serializeAuthenticatedUser, } from './sensitive-data';
3
4
  export { default } from './plugin';
@@ -29,14 +29,21 @@ var server_exports = {};
29
29
  __export(server_exports, {
30
30
  AuthModel: () => import_authenticator.AuthModel,
31
31
  BasicAuth: () => import_basic_auth.BasicAuth,
32
- default: () => import_plugin.default
32
+ default: () => import_plugin.default,
33
+ isAuthenticationSecretKey: () => import_sensitive_data.isAuthenticationSecretKey,
34
+ redactSensitiveAuthenticationData: () => import_sensitive_data.redactSensitiveAuthenticationData,
35
+ serializeAuthenticatedUser: () => import_sensitive_data.serializeAuthenticatedUser
33
36
  });
34
37
  module.exports = __toCommonJS(server_exports);
35
38
  var import_basic_auth = require("./basic-auth");
36
39
  var import_authenticator = require("./model/authenticator");
40
+ var import_sensitive_data = require("./sensitive-data");
37
41
  var import_plugin = __toESM(require("./plugin"));
38
42
  // Annotate the CommonJS export names for ESM import in node:
39
43
  0 && (module.exports = {
40
44
  AuthModel,
41
- BasicAuth
45
+ BasicAuth,
46
+ isAuthenticationSecretKey,
47
+ redactSensitiveAuthenticationData,
48
+ serializeAuthenticatedUser
42
49
  });
@@ -39,6 +39,7 @@ var import_authenticators = __toESM(require("./actions/authenticators"));
39
39
  var import_basic_auth = require("./basic-auth");
40
40
  var import_locale = require("./locale");
41
41
  var import_authenticator = require("./model/authenticator");
42
+ var import_sensitive_data = require("./sensitive-data");
42
43
  var import_storer = require("./storer");
43
44
  var import_token_blacklist = require("./token-blacklist");
44
45
  var import_token_controller = require("./token-controller");
@@ -130,6 +131,40 @@ class PluginAuthServer extends import_server.Plugin {
130
131
  Object.entries(import_authenticators.default).forEach(
131
132
  ([action, handler]) => this.app.resourcer.registerAction(`authenticators:${action}`, handler)
132
133
  );
134
+ this.app.resourcer.use(
135
+ async (ctx, next) => {
136
+ var _a, _b;
137
+ await next();
138
+ if (((_a = ctx.action) == null ? void 0 : _a.resourceName) !== "auth") {
139
+ return;
140
+ }
141
+ if (ctx.action.actionName === "check") {
142
+ const responseUser = (0, import_sensitive_data.serializeAuthenticatedUser)(ctx.body);
143
+ const userWithPassword = responseUser.id ? await ctx.db.getRepository("users").findOne({
144
+ filterByTk: responseUser.id,
145
+ fields: ["id", "password"],
146
+ raw: true
147
+ }) : null;
148
+ ctx.body = {
149
+ ...responseUser,
150
+ hasPassword: (0, import_sensitive_data.serializeAuthenticatedUser)(userWithPassword).hasPassword
151
+ };
152
+ return;
153
+ }
154
+ if (ctx.action.actionName === "signIn" && ((_b = ctx.body) == null ? void 0 : _b.user)) {
155
+ const response = (0, import_sensitive_data.redactSensitiveAuthenticationData)(ctx.body);
156
+ ctx.body = {
157
+ ...response,
158
+ user: (0, import_sensitive_data.serializeAuthenticatedUser)(ctx.body.user)
159
+ };
160
+ return;
161
+ }
162
+ if (ctx.body !== void 0) {
163
+ ctx.body = (0, import_sensitive_data.redactSensitiveAuthenticationData)(ctx.body);
164
+ }
165
+ },
166
+ { tag: "redactAuthenticationSecrets" }
167
+ );
133
168
  ["signIn", "signUp"].forEach((action) => this.app.acl.allow("auth", action));
134
169
  ["check", "signOut", "changePassword"].forEach((action) => this.app.acl.allow("auth", action, "loggedIn"));
135
170
  this.app.acl.allow("authenticators", "publicList");
@@ -0,0 +1,3 @@
1
+ export declare function isAuthenticationSecretKey(key: unknown): boolean;
2
+ export declare function redactSensitiveAuthenticationData<T>(value: T): T;
3
+ export declare function serializeAuthenticatedUser(user: any): any;
@@ -0,0 +1,103 @@
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 sensitive_data_exports = {};
19
+ __export(sensitive_data_exports, {
20
+ isAuthenticationSecretKey: () => isAuthenticationSecretKey,
21
+ redactSensitiveAuthenticationData: () => redactSensitiveAuthenticationData,
22
+ serializeAuthenticatedUser: () => serializeAuthenticatedUser
23
+ });
24
+ module.exports = __toCommonJS(sensitive_data_exports);
25
+ var import_server = require("@tego/server");
26
+ const AUTHENTICATION_SECRET_KEYS = /* @__PURE__ */ new Set(["password", "resetToken"]);
27
+ function isAuthenticationSecretKey(key) {
28
+ return typeof key === "string" && AUTHENTICATION_SECRET_KEYS.has(key);
29
+ }
30
+ function isSensitiveKeyValueEntry(value) {
31
+ if (!value || typeof value !== "object" || !Object.prototype.hasOwnProperty.call(value, "value")) {
32
+ return false;
33
+ }
34
+ const key = Reflect.get(value, "key");
35
+ return typeof key === "string" && key.split(".").some(isAuthenticationSecretKey);
36
+ }
37
+ function redact(value, seen) {
38
+ if (value === null || typeof value !== "object") {
39
+ return value;
40
+ }
41
+ if (value instanceof Date) {
42
+ return new Date(value.getTime());
43
+ }
44
+ if (seen.has(value)) {
45
+ return seen.get(value);
46
+ }
47
+ let serialized = value;
48
+ if (value instanceof import_server.Model) {
49
+ try {
50
+ serialized = value.get({ plain: true });
51
+ } catch {
52
+ serialized = value.dataValues;
53
+ }
54
+ }
55
+ if (serialized === null || typeof serialized !== "object") {
56
+ seen.set(value, serialized);
57
+ return serialized;
58
+ }
59
+ if (serialized instanceof Date) {
60
+ const result2 = new Date(serialized.getTime());
61
+ seen.set(value, result2);
62
+ return result2;
63
+ }
64
+ const result = Array.isArray(serialized) ? [] : {};
65
+ seen.set(value, result);
66
+ seen.set(serialized, result);
67
+ if (Array.isArray(serialized)) {
68
+ for (const item of serialized) {
69
+ if (!isSensitiveKeyValueEntry(item)) {
70
+ result.push(redact(item, seen));
71
+ }
72
+ }
73
+ return result;
74
+ }
75
+ for (const key of Reflect.ownKeys(serialized)) {
76
+ if (isAuthenticationSecretKey(key)) {
77
+ continue;
78
+ }
79
+ if (key === "toJSON" && typeof serialized[key] === "function") {
80
+ continue;
81
+ }
82
+ result[key] = redact(serialized[key], seen);
83
+ }
84
+ return result;
85
+ }
86
+ function redactSensitiveAuthenticationData(value) {
87
+ return redact(value, /* @__PURE__ */ new WeakMap());
88
+ }
89
+ function serializeAuthenticatedUser(user) {
90
+ var _a, _b;
91
+ const password = ((_a = user == null ? void 0 : user.get) == null ? void 0 : _a.call(user, "password")) ?? (user == null ? void 0 : user.password);
92
+ const hasPassword = password === void 0 ? ((_b = user == null ? void 0 : user.get) == null ? void 0 : _b.call(user, "hasPassword")) ?? (user == null ? void 0 : user.hasPassword) ?? false : typeof password === "string" ? password.length > 0 : password != null;
93
+ return {
94
+ ...redactSensitiveAuthenticationData(user ?? {}),
95
+ hasPassword
96
+ };
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ isAuthenticationSecretKey,
101
+ redactSensitiveAuthenticationData,
102
+ serializeAuthenticatedUser
103
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-auth",
3
3
  "displayName": "Authentication",
4
- "version": "1.6.33",
4
+ "version": "1.6.34",
5
5
  "description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
6
6
  "keywords": [
7
7
  "Authentication",
@@ -32,7 +32,7 @@
32
32
  "react": "18.3.1",
33
33
  "react-i18next": "16.2.1",
34
34
  "react-router-dom": "6.28.1",
35
- "@tachybase/client": "1.6.33"
35
+ "@tachybase/client": "1.6.34"
36
36
  },
37
37
  "description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
38
38
  "displayName.zh-CN": "用户认证",