@tachybase/module-auth 0.23.47 → 0.23.58

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,16 +1,16 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "0.23.47",
3
+ "@tachybase/client": "0.23.58",
4
4
  "react-router-dom": "6.28.1",
5
- "@tachybase/utils": "0.23.47",
6
- "@tachybase/auth": "0.23.47",
7
- "@tachybase/database": "0.23.47",
8
- "@tachybase/cache": "0.23.47",
9
- "@tachybase/server": "0.23.47",
10
- "@tachybase/test": "0.23.47",
5
+ "@tachybase/utils": "0.23.58",
6
+ "@tachybase/auth": "0.23.58",
7
+ "@tachybase/database": "0.23.58",
8
+ "@tachybase/cache": "0.23.58",
9
+ "@tachybase/server": "0.23.58",
10
+ "@tachybase/test": "0.23.58",
11
11
  "antd": "5.22.5",
12
- "@tachybase/schema": "0.23.47",
12
+ "@tachybase/schema": "0.23.58",
13
13
  "react-i18next": "15.2.0",
14
14
  "@ant-design/icons": "5.3.7",
15
- "@tachybase/actions": "0.23.47"
15
+ "@tachybase/actions": "0.23.58"
16
16
  };
@@ -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":"2025-02-21T02:25:45.083Z"}
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":"2025-03-06T09:57:23.111Z"}
@@ -32,6 +32,13 @@ var users_authenticators_default = (0, import_database.defineCollection)({
32
32
  updatedBy: true,
33
33
  logging: true,
34
34
  fields: [
35
+ {
36
+ name: "id",
37
+ type: "bigInt",
38
+ autoIncrement: true,
39
+ primaryKey: true,
40
+ allowNull: false
41
+ },
35
42
  /**
36
43
  * uuid:
37
44
  * Unique user id of the authentication method, such as wechat openid, phone number, etc.
@@ -64,8 +64,10 @@ class PluginAuthServer extends import_server.Plugin {
64
64
  store: "memory"
65
65
  });
66
66
  const storer = new import_storer.Storer({
67
+ app: this.app,
67
68
  db: this.db,
68
- cache: this.cache
69
+ cache: this.cache,
70
+ authManager: this.app.authManager
69
71
  });
70
72
  this.app.authManager.setStorer(storer);
71
73
  if (!this.app.authManager.jwt.blacklist) {
@@ -1,15 +1,21 @@
1
- import { Storer as IStorer } from '@tachybase/auth';
1
+ import { AuthManager, Storer as IStorer } from '@tachybase/auth';
2
2
  import { Cache } from '@tachybase/cache';
3
3
  import { Database } from '@tachybase/database';
4
+ import { Application } from '@tachybase/server';
4
5
  import { AuthModel } from './model/authenticator';
5
6
  export declare class Storer implements IStorer {
6
7
  db: Database;
7
8
  cache: Cache;
9
+ app: Application;
10
+ authManager: AuthManager;
8
11
  key: string;
9
- constructor({ db, cache }: {
12
+ constructor({ app, db, cache, authManager, }: {
13
+ app?: Application;
10
14
  db: Database;
11
15
  cache: Cache;
16
+ authManager: AuthManager;
12
17
  });
18
+ renderJsonTemplate(authenticator: any): any;
13
19
  getCache(): Promise<AuthModel[]>;
14
20
  setCache(authenticators: AuthModel[]): Promise<void>;
15
21
  get(name: string): Promise<AuthModel>;
@@ -21,21 +21,43 @@ __export(storer_exports, {
21
21
  });
22
22
  module.exports = __toCommonJS(storer_exports);
23
23
  class Storer {
24
- constructor({ db, cache }) {
24
+ constructor({
25
+ app,
26
+ db,
27
+ cache,
28
+ authManager
29
+ }) {
25
30
  this.key = "authenticators";
31
+ this.app = app;
26
32
  this.db = db;
27
33
  this.cache = cache;
34
+ this.authManager = authManager;
28
35
  this.db.on("authenticators.afterSave", async (model) => {
29
36
  if (!model.enabled) {
30
37
  await this.cache.delValueInObject(this.key, model.name);
31
38
  return;
32
39
  }
33
- await this.cache.setValueInObject(this.key, model.name, model);
40
+ await this.cache.setValueInObject(this.key, model.name, this.renderJsonTemplate(model));
34
41
  });
35
42
  this.db.on("authenticators.afterDestroy", async (model) => {
36
43
  await this.cache.delValueInObject(this.key, model.name);
37
44
  });
38
45
  }
46
+ renderJsonTemplate(authenticator) {
47
+ var _a, _b;
48
+ if (!authenticator) {
49
+ return authenticator;
50
+ }
51
+ const $env = (_a = this.app) == null ? void 0 : _a.environment;
52
+ if (!$env) {
53
+ return authenticator;
54
+ }
55
+ const config = this.authManager.getAuthConfig(authenticator.authType);
56
+ authenticator.dataValues.options = $env.renderJsonTemplate(authenticator.dataValues.options, {
57
+ omit: (_b = config == null ? void 0 : config.auth) == null ? void 0 : _b["optionsKeysNotAllowedInEnv"]
58
+ });
59
+ return authenticator;
60
+ }
39
61
  async getCache() {
40
62
  const authenticators = await this.cache.get(this.key);
41
63
  if (!authenticators) {
@@ -45,7 +67,7 @@ class Storer {
45
67
  }
46
68
  async setCache(authenticators) {
47
69
  const obj = authenticators.reduce((obj2, authenticator) => {
48
- obj2[authenticator.name] = authenticator;
70
+ obj2[authenticator.name] = this.renderJsonTemplate(authenticator);
49
71
  return obj2;
50
72
  }, {});
51
73
  await this.cache.set(this.key, obj);
@@ -56,6 +78,7 @@ class Storer {
56
78
  const repo = this.db.getRepository("authenticators");
57
79
  authenticators = await repo.find({ filter: { enabled: true } });
58
80
  await this.setCache(authenticators);
81
+ authenticators = await this.getCache();
59
82
  }
60
83
  const authenticator = authenticators.find((authenticator2) => authenticator2.name === name);
61
84
  return authenticator || authenticators[0];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-auth",
3
3
  "displayName": "Authentication",
4
- "version": "0.23.47",
4
+ "version": "0.23.58",
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"
@@ -15,17 +15,17 @@
15
15
  "react": "^18.3.1",
16
16
  "react-i18next": "^15.2.0",
17
17
  "react-router-dom": "6.28.1",
18
- "@tachybase/schema": "0.23.47"
18
+ "@tachybase/schema": "0.23.58"
19
19
  },
20
20
  "peerDependencies": {
21
- "@tachybase/actions": "0.23.47",
22
- "@tachybase/auth": "0.23.47",
23
- "@tachybase/client": "0.23.47",
24
- "@tachybase/database": "0.23.47",
25
- "@tachybase/server": "0.23.47",
26
- "@tachybase/cache": "0.23.47",
27
- "@tachybase/test": "0.23.47",
28
- "@tachybase/utils": "0.23.47"
21
+ "@tachybase/actions": "0.23.58",
22
+ "@tachybase/auth": "0.23.58",
23
+ "@tachybase/cache": "0.23.58",
24
+ "@tachybase/client": "0.23.58",
25
+ "@tachybase/database": "0.23.58",
26
+ "@tachybase/server": "0.23.58",
27
+ "@tachybase/test": "0.23.58",
28
+ "@tachybase/utils": "0.23.58"
29
29
  },
30
30
  "description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
31
31
  "displayName.zh-CN": "用户认证",