diff --git a/package.json b/package.json index f4c27915..bd8b0299 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "start:admin-old": "cd server/admin-old && pnpm start", "build": "concurrently npm:build:web npm:build:server npm:build:admin npm:build:admin-old && cp -r client/web/dist/* server/dist/public", "build:web": "cd client/web && pnpm build", - "build:server": "cd server && pnpm build && echo \"Install server side plugin:\" && pnpm run plugin:install com.msgbyte.tasks com.msgbyte.linkmeta com.msgbyte.github com.msgbyte.simplenotify com.msgbyte.topic com.msgbyte.agora com.msgbyte.wxpusher com.msgbyte.welcome com.msgbyte.fim && mkdir -p ./dist/public && cp -r ./public/plugins ./dist/public && cp ./public/registry-be.json ./dist/public", + "build:server": "cd server && pnpm build && echo \"Install server side plugin:\" && pnpm run plugin:install com.msgbyte.tasks com.msgbyte.linkmeta com.msgbyte.github com.msgbyte.simplenotify com.msgbyte.topic com.msgbyte.agora com.msgbyte.wxpusher com.msgbyte.welcome com.msgbyte.iam && mkdir -p ./dist/public && cp -r ./public/plugins ./dist/public && cp ./public/registry-be.json ./dist/public", "build:admin": "cd server/admin && pnpm build", "build:admin-old": "cd server/admin-old && pnpm build", "check:type": "concurrently npm:check:type:client npm:check:type:server", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1643366c..ac31b29f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -575,7 +575,7 @@ importers: version: 0.32.11 zustand: specifier: ^4.3.6 - version: 4.3.6(immer@9.0.21)(react@18.2.0) + version: 4.3.6(immer@9.0.15)(react@18.2.0) devDependencies: '@types/crc': specifier: ^3.4.0 @@ -1886,35 +1886,7 @@ importers: version: 5.3.6(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) zustand: specifier: ^4.3.6 - version: 4.3.6(immer@9.0.21)(react@18.2.0) - - server/plugins/com.msgbyte.fim: - dependencies: - got: - specifier: 11.8.3 - version: 11.8.3 - tailchat-server-sdk: - specifier: '*' - version: link:../../packages/sdk - devDependencies: - '@types/react': - specifier: 18.0.20 - version: 18.0.20 - mini-star: - specifier: '*' - version: 1.3.1 - - server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim: - devDependencies: - '@types/styled-components': - specifier: ^5.1.26 - version: 5.1.26 - react: - specifier: 18.2.0 - version: 18.2.0 - styled-components: - specifier: ^5.3.6 - version: 5.3.6(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) + version: 4.3.6(immer@9.0.15)(react@18.2.0) server/plugins/com.msgbyte.getui: dependencies: @@ -1950,6 +1922,34 @@ importers: server/plugins/com.msgbyte.github/web/plugins/com.msgbyte.github: {} + server/plugins/com.msgbyte.iam: + dependencies: + got: + specifier: 11.8.3 + version: 11.8.3 + tailchat-server-sdk: + specifier: '*' + version: link:../../packages/sdk + devDependencies: + '@types/react': + specifier: 18.0.20 + version: 18.0.20 + mini-star: + specifier: '*' + version: 1.3.1 + + server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam: + devDependencies: + '@types/styled-components': + specifier: ^5.1.26 + version: 5.1.26 + react: + specifier: 18.2.0 + version: 18.2.0 + styled-components: + specifier: ^5.3.6 + version: 5.3.6(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) + server/plugins/com.msgbyte.linkmeta: dependencies: got: @@ -2092,7 +2092,7 @@ importers: version: 5.3.6(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) zustand: specifier: ^4.3.6 - version: 4.3.6(immer@9.0.21)(react@18.2.0) + version: 4.3.6(immer@9.0.15)(react@18.2.0) server/plugins/com.msgbyte.welcome: dependencies: @@ -21575,10 +21575,10 @@ packages: /immer@9.0.15: resolution: {integrity: sha512-2eB/sswms9AEUSkOm4SbV5Y7Vmt/bKRwByd52jfLkW4OLYeaTP3EEiJ9agqU0O/tq6Dk62Zfj+TJSqfm1rLVGQ==} - dev: false /immer@9.0.21: resolution: {integrity: sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==} + dev: false /import-fresh@2.0.0: resolution: {integrity: sha512-eZ5H8rcgYazHbKC3PG4ClHNykCSxtAhxSSEM+2mb+7evD2CKF5V7c0dNum7AdpDh0ZdICwZY9sRSn8f+KH96sg==} @@ -36085,7 +36085,6 @@ packages: immer: 9.0.15 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) - dev: false /zustand@4.3.6(immer@9.0.21)(react@18.2.0): resolution: {integrity: sha512-6J5zDxjxLE+yukC2XZWf/IyWVKnXT9b9HUv09VJ/bwGCpKNcaTqp7Ws28Xr8jnbvnZcdRaidztAPsXFBIqufiw==} @@ -36102,6 +36101,7 @@ packages: immer: 9.0.21 react: 18.2.0 use-sync-external-store: 1.2.0(react@18.2.0) + dev: false /zwitch@1.0.5: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/manifest.json b/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/manifest.json deleted file mode 100644 index e53f89b3..00000000 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "label": "Federated Identity Management", - "name": "com.msgbyte.fim", - "url": "{BACKEND}/plugins/com.msgbyte.fim/index.js", - "version": "0.0.0", - "author": "moonrailgun", - "description": "Unified identity authentication", - "requireRestart": true -} diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/index.tsx b/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/index.tsx deleted file mode 100644 index 28166d6b..00000000 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/index.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { regLoginAction } from '@capital/common'; -import { FimAction } from './FimAction'; - -console.log('Plugin Federated Identity Management is loaded'); - -regLoginAction({ - name: 'fim', - component: FimAction, -}); diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/request.ts b/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/request.ts deleted file mode 100644 index a2cdae52..00000000 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/request.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { createPluginRequest } from '@capital/common'; - -export const request = createPluginRequest('com.msgbyte.fim'); diff --git a/server/plugins/com.msgbyte.fim/.ministarrc.js b/server/plugins/com.msgbyte.iam/.ministarrc.js similarity index 100% rename from server/plugins/com.msgbyte.fim/.ministarrc.js rename to server/plugins/com.msgbyte.iam/.ministarrc.js diff --git a/server/plugins/com.msgbyte.fim/models/fim.ts b/server/plugins/com.msgbyte.iam/models/iam.ts similarity index 69% rename from server/plugins/com.msgbyte.fim/models/fim.ts rename to server/plugins/com.msgbyte.iam/models/iam.ts index 73ec744f..a83e54a5 100644 --- a/server/plugins/com.msgbyte.fim/models/fim.ts +++ b/server/plugins/com.msgbyte.iam/models/iam.ts @@ -3,10 +3,10 @@ const { getModelForClass, prop, modelOptions, TimeStamps } = db; @modelOptions({ options: { - customName: 'p_fim', + customName: 'p_iam', }, }) -export class Fim extends TimeStamps implements db.Base { +export class IAM extends TimeStamps implements db.Base { _id: db.Types.ObjectId; id: string; @@ -28,10 +28,10 @@ export class Fim extends TimeStamps implements db.Base { userId: string; } -export type FimDocument = db.DocumentType; +export type IAMDocument = db.DocumentType; -const model = getModelForClass(Fim); +const model = getModelForClass(IAM); -export type FimModel = typeof model; +export type IAMModel = typeof model; export default model; diff --git a/server/plugins/com.msgbyte.fim/package.json b/server/plugins/com.msgbyte.iam/package.json similarity index 92% rename from server/plugins/com.msgbyte.fim/package.json rename to server/plugins/com.msgbyte.iam/package.json index d78da91b..0fa19dc9 100644 --- a/server/plugins/com.msgbyte.fim/package.json +++ b/server/plugins/com.msgbyte.iam/package.json @@ -1,5 +1,5 @@ { - "name": "tailchat-plugin-fim", + "name": "tailchat-plugin-iam", "version": "1.0.0", "main": "index.js", "author": "moonrailgun", diff --git a/server/plugins/com.msgbyte.fim/services/fim.service.ts b/server/plugins/com.msgbyte.iam/services/iam.service.ts similarity index 89% rename from server/plugins/com.msgbyte.fim/services/fim.service.ts rename to server/plugins/com.msgbyte.iam/services/iam.service.ts index 2451523f..7ef4d680 100644 --- a/server/plugins/com.msgbyte.fim/services/fim.service.ts +++ b/server/plugins/com.msgbyte.iam/services/iam.service.ts @@ -6,7 +6,7 @@ import { UserStructWithToken, } from 'tailchat-server-sdk'; import { isValidStaticAssetsUrl } from '../../../lib/utils'; -import type { FimDocument, FimModel } from '../models/fim'; +import type { IAMDocument, IAMModel } from '../models/iam'; import { strategies } from '../strategies'; import type { StrategyType } from '../strategies/types'; @@ -15,14 +15,14 @@ import type { StrategyType } from '../strategies/types'; * * Unified identity authentication */ -interface FimService extends TcService, TcDbService {} -class FimService extends TcService { +interface IAMService extends TcService, TcDbService {} +class IAMService extends TcService { get serviceName() { - return 'plugin:com.msgbyte.fim'; + return 'plugin:com.msgbyte.iam'; } onInit() { - this.registerLocalDb(require('../models/fim').default); + this.registerLocalDb(require('../models/iam').default); const availableStrategies = strategies.filter((strategy) => strategy.checkAvailable() @@ -67,15 +67,15 @@ class FimService extends TcService { const providerUserInfo = await strategy.getUserInfo(code); - const fimRecord = await this.adapter.model.findOne({ + const iamRecord = await this.adapter.model.findOne({ provider: strategyName, providerId: providerUserInfo.id, }); - if (!!fimRecord) { + if (!!iamRecord) { // 存在记录,直接签发 token const token = await ctx.call('user.signUserToken', { - userId: fimRecord.userId, + userId: iamRecord.userId, }); return generatePostMessageHtml({ @@ -141,10 +141,10 @@ function generatePostMessageHtml(obj: Record) { return { __raw: true, html: `
Waiting for close
`, }; } -export default FimService; +export default IAMService; diff --git a/server/plugins/com.msgbyte.fim/strategies/github.ts b/server/plugins/com.msgbyte.iam/strategies/github.ts similarity index 92% rename from server/plugins/com.msgbyte.fim/strategies/github.ts rename to server/plugins/com.msgbyte.iam/strategies/github.ts index 11631a8d..9fbc80a5 100644 --- a/server/plugins/com.msgbyte.fim/strategies/github.ts +++ b/server/plugins/com.msgbyte.iam/strategies/github.ts @@ -3,14 +3,14 @@ import type { StrategyType } from './types'; import got from 'got'; const clientInfo = { - id: process.env.FIM_GITHUB_ID, - secret: process.env.FIM_GITHUB_SECRET, + id: process.env.IAM_GITHUB_ID, + secret: process.env.IAM_GITHUB_SECRET, }; const authorize_uri = 'https://github.com/login/oauth/authorize'; const access_token_uri = 'https://github.com/login/oauth/access_token'; const userinfo_uri = 'https://api.github.com/user'; -const redirect_uri = `${config.apiUrl}/api/plugin:com.msgbyte.fim/github/redirect`; +const redirect_uri = `${config.apiUrl}/api/plugin:com.msgbyte.iam/github/redirect`; export const GithubStrategy: StrategyType = { name: 'github', diff --git a/server/plugins/com.msgbyte.fim/strategies/index.ts b/server/plugins/com.msgbyte.iam/strategies/index.ts similarity index 100% rename from server/plugins/com.msgbyte.fim/strategies/index.ts rename to server/plugins/com.msgbyte.iam/strategies/index.ts diff --git a/server/plugins/com.msgbyte.fim/strategies/types.ts b/server/plugins/com.msgbyte.iam/strategies/types.ts similarity index 100% rename from server/plugins/com.msgbyte.fim/strategies/types.ts rename to server/plugins/com.msgbyte.iam/strategies/types.ts diff --git a/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/manifest.json b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/manifest.json new file mode 100644 index 00000000..02b7f6bb --- /dev/null +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/manifest.json @@ -0,0 +1,11 @@ +{ + "label": "Identity and Access Management", + "label.zh-CN": "IAM 插件", + "name": "com.msgbyte.iam", + "url": "{BACKEND}/plugins/com.msgbyte.iam/index.js", + "version": "0.0.0", + "author": "moonrailgun", + "description": "Provide Tailchat with the function of conveniently accessing external account systems", + "description.zh-CN": "为Tailchat提供方便的接入外部账户系统的功能", + "requireRestart": true +} diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/package.json b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/package.json similarity index 76% rename from server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/package.json rename to server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/package.json index ab6c849b..186b7928 100644 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/package.json +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/package.json @@ -1,8 +1,8 @@ { - "name": "@plugins/com.msgbyte.fim", + "name": "@plugins/com.msgbyte.iam", "main": "src/index.tsx", "version": "0.0.0", - "description": "Unified identity authentication", + "description": "Identity and Access Management", "private": true, "scripts": { "sync:declaration": "tailchat declaration github" diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/FimAction.tsx b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/IAMAction.tsx similarity index 94% rename from server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/FimAction.tsx rename to server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/IAMAction.tsx index 38bb5f03..4bc61a2d 100644 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/FimAction.tsx +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/IAMAction.tsx @@ -10,7 +10,7 @@ import { Divider, Image, Tooltip } from '@capital/component'; import { request } from './request'; import { Translate } from './translate'; -export const FimAction: React.FC = React.memo(() => { +export const IAMAction: React.FC = React.memo(() => { const { loading, value: strategies } = useAsync(async () => { const { data: strategies } = await request.get('availableStrategies'); @@ -55,7 +55,7 @@ export const FimAction: React.FC = React.memo(() => { if (Array.isArray(strategies) && strategies.length > 0) { return (
- {Translate.fimLogin} + {Translate.iamLogin}
{strategies.map((s) => ( @@ -87,4 +87,4 @@ export const FimAction: React.FC = React.memo(() => { return null; }); -FimAction.displayName = 'FimAction'; +IAMAction.displayName = 'IAMAction'; diff --git a/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/index.tsx b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/index.tsx new file mode 100644 index 00000000..cb93ab78 --- /dev/null +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/index.tsx @@ -0,0 +1,9 @@ +import { regLoginAction } from '@capital/common'; +import { IAMAction } from './IAMAction'; + +console.log('Plugin Identity and Access Management is loaded'); + +regLoginAction({ + name: 'plugin:com.msgbyte.iam/loginAction', + component: IAMAction, +}); diff --git a/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/request.ts b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/request.ts new file mode 100644 index 00000000..0da13e3c --- /dev/null +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/request.ts @@ -0,0 +1,3 @@ +import { createPluginRequest } from '@capital/common'; + +export const request = createPluginRequest('com.msgbyte.iam'); diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/translate.ts b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/translate.ts similarity index 95% rename from server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/translate.ts rename to server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/translate.ts index 8635d708..14f58b28 100644 --- a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/translate.ts +++ b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/src/translate.ts @@ -1,7 +1,7 @@ import { localTrans } from '@capital/common'; export const Translate = { - fimLogin: localTrans({ + iamLogin: localTrans({ 'zh-CN': '第三方登录', 'en-US': 'Third party login', }), diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/tsconfig.json b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/tsconfig.json similarity index 100% rename from server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/tsconfig.json rename to server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/tsconfig.json diff --git a/server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/types/tailchat.d.ts b/server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/types/tailchat.d.ts similarity index 100% rename from server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/types/tailchat.d.ts rename to server/plugins/com.msgbyte.iam/web/plugins/com.msgbyte.iam/types/tailchat.d.ts