@igstack/app-catalog-backend-core 6.1.4 → 6.1.5-alpha-20260927032305

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 +1 @@
1
- {"version":3,"file":"authRouter.d.mts","names":[],"sources":["../../../src/modules/auth/authRouter.ts"],"mappings":";;;;;;;;;AAWA;;;iBAAgB,gBAAA,CACd,CAAA,EAAG,cAAA,CAAe,aAAA,WAClB,IAAA,GAAO,UAAA,EACP,OAAA;EAAY,eAAA;AAAA,kBAA2B,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6D7B,UAAA,GAAa,UAAA,QAAkB,gBAAA"}
1
+ {"version":3,"file":"authRouter.d.mts","names":[],"sources":["../../../src/modules/auth/authRouter.ts"],"mappings":";;;;;;;;;AAWA;;;iBAAgB,gBAAA,CACd,CAAA,EAAG,cAAA,CAAe,aAAA,WAClB,IAAA,GAAO,UAAA,EACP,OAAA;EAAY,eAAA;AAAA,kBAA2B,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0D7B,UAAA,GAAa,UAAA,QAAkB,gBAAA"}
@@ -26,8 +26,8 @@ function createAuthRouter(t, auth, options) {
26
26
  });
27
27
  }
28
28
  if (authOptions?.plugins) authOptions.plugins.forEach((plugin) => {
29
- const pluginWithConfig = plugin;
30
- if (pluginWithConfig.id === "generic-oauth" && pluginWithConfig.options?.config) (Array.isArray(pluginWithConfig.options.config) ? pluginWithConfig.options.config : [pluginWithConfig.options.config]).forEach((config) => {
29
+ if (plugin.id !== "generic-oauth" || !plugin.options?.config) return;
30
+ (Array.isArray(plugin.options.config) ? plugin.options.config : [plugin.options.config]).forEach((config) => {
31
31
  if (config.providerId) providers.push(config.providerId);
32
32
  });
33
33
  });
@@ -1 +1 @@
1
- {"version":3,"file":"authRouter.mjs","names":[],"sources":["../../../src/modules/auth/authRouter.ts"],"sourcesContent":["import type { BetterAuthPlugin } from 'better-auth'\nimport type { TRPCRootObject } from '@trpc/server'\nimport type { AcTrpcContext } from '../../server/acTrpcContext'\nimport type { BetterAuth } from './auth'\n\n/**\n * Create auth tRPC procedures\n * @param t - tRPC instance\n * @param auth - Better Auth instance (optional, for future extensions)\n * @returns tRPC router with auth procedures\n */\nexport function createAuthRouter(\n t: TRPCRootObject<AcTrpcContext, {}, {}>,\n auth?: BetterAuth,\n options?: { devLoginEnabled?: boolean },\n) {\n const router = t.router\n const publicProcedure = t.procedure\n\n return router({\n getSession: publicProcedure.query(async ({ ctx }) => {\n return {\n user: ctx.user ?? null,\n isAuthenticated: !!ctx.user,\n isAdmin: ctx.isAdmin,\n }\n }),\n getProviders: publicProcedure.query(() => {\n // Return configured social providers and OAuth providers from plugins\n const providers: string[] = []\n const authOptions = auth?.options\n\n // Add built-in social providers (github, google, etc.)\n if (authOptions?.socialProviders) {\n const socialProviders = authOptions.socialProviders as Record<\n string,\n unknown\n >\n Object.keys(socialProviders).forEach((key) => {\n if (socialProviders[key]) {\n providers.push(key)\n }\n })\n }\n\n // Add OAuth providers from plugins (like Okta via genericOAuth)\n if (authOptions?.plugins) {\n const plugins = authOptions.plugins\n plugins.forEach((plugin: BetterAuthPlugin) => {\n const pluginWithConfig = plugin as BetterAuthPlugin & {\n options?: {\n config?: { providerId?: string }[]\n }\n }\n if (\n pluginWithConfig.id === 'generic-oauth' &&\n pluginWithConfig.options?.config\n ) {\n const configs = Array.isArray(pluginWithConfig.options.config)\n ? pluginWithConfig.options.config\n : [pluginWithConfig.options.config]\n configs.forEach((config) => {\n if (config.providerId) {\n providers.push(config.providerId)\n }\n })\n }\n })\n }\n\n return { providers, devLoginEnabled: options?.devLoginEnabled ?? false }\n }),\n })\n}\n\nexport type AuthRouter = ReturnType<typeof createAuthRouter>\n"],"mappings":";;;;;;;AAWA,SAAgB,iBACd,GACA,MACA,SACA;CACA,MAAM,SAAS,EAAE;CACjB,MAAM,kBAAkB,EAAE;AAE1B,QAAO,OAAO;EACZ,YAAY,gBAAgB,MAAM,OAAO,EAAE,UAAU;AACnD,UAAO;IACL,MAAM,IAAI,QAAQ;IAClB,iBAAiB,CAAC,CAAC,IAAI;IACvB,SAAS,IAAI;IACd;IACD;EACF,cAAc,gBAAgB,YAAY;GAExC,MAAM,YAAsB,EAAE;GAC9B,MAAM,cAAc,MAAM;AAG1B,OAAI,aAAa,iBAAiB;IAChC,MAAM,kBAAkB,YAAY;AAIpC,WAAO,KAAK,gBAAgB,CAAC,SAAS,QAAQ;AAC5C,SAAI,gBAAgB,KAClB,WAAU,KAAK,IAAI;MAErB;;AAIJ,OAAI,aAAa,QAEf,CADgB,YAAY,QACpB,SAAS,WAA6B;IAC5C,MAAM,mBAAmB;AAKzB,QACE,iBAAiB,OAAO,mBACxB,iBAAiB,SAAS,OAK1B,EAHgB,MAAM,QAAQ,iBAAiB,QAAQ,OAAO,GAC1D,iBAAiB,QAAQ,SACzB,CAAC,iBAAiB,QAAQ,OAAO,EAC7B,SAAS,WAAW;AAC1B,SAAI,OAAO,WACT,WAAU,KAAK,OAAO,WAAW;MAEnC;KAEJ;AAGJ,UAAO;IAAE;IAAW,iBAAiB,SAAS,mBAAmB;IAAO;IACxE;EACH,CAAC"}
1
+ {"version":3,"file":"authRouter.mjs","names":[],"sources":["../../../src/modules/auth/authRouter.ts"],"sourcesContent":["import type { BetterAuthPlugin } from 'better-auth'\nimport type { TRPCRootObject } from '@trpc/server'\nimport type { AcTrpcContext } from '../../server/acTrpcContext'\nimport type { BetterAuth } from './auth'\n\n/**\n * Create auth tRPC procedures\n * @param t - tRPC instance\n * @param auth - Better Auth instance (optional, for future extensions)\n * @returns tRPC router with auth procedures\n */\nexport function createAuthRouter(\n t: TRPCRootObject<AcTrpcContext, {}, {}>,\n auth?: BetterAuth,\n options?: { devLoginEnabled?: boolean },\n) {\n const router = t.router\n const publicProcedure = t.procedure\n\n return router({\n getSession: publicProcedure.query(async ({ ctx }) => {\n return {\n user: ctx.user ?? null,\n isAuthenticated: !!ctx.user,\n isAdmin: ctx.isAdmin,\n }\n }),\n getProviders: publicProcedure.query(() => {\n // Return configured social providers and OAuth providers from plugins\n const providers: string[] = []\n const authOptions = auth?.options\n\n // Add built-in social providers (github, google, etc.)\n if (authOptions?.socialProviders) {\n const socialProviders = authOptions.socialProviders as Record<\n string,\n unknown\n >\n Object.keys(socialProviders).forEach((key) => {\n if (socialProviders[key]) {\n providers.push(key)\n }\n })\n }\n\n // Add OAuth providers from plugins (like Okta via genericOAuth). They are\n // absent from socialProviders above: the plugin only merges them into the\n // auth context at init time, not into the static options.\n if (authOptions?.plugins) {\n const plugins = authOptions.plugins\n plugins.forEach((plugin: BetterAuthPlugin) => {\n if (plugin.id !== 'generic-oauth' || !plugin.options?.config) {\n return\n }\n const configs: { providerId?: string }[] = Array.isArray(\n plugin.options.config,\n )\n ? plugin.options.config\n : [plugin.options.config]\n configs.forEach((config) => {\n if (config.providerId) {\n providers.push(config.providerId)\n }\n })\n })\n }\n\n return { providers, devLoginEnabled: options?.devLoginEnabled ?? false }\n }),\n })\n}\n\nexport type AuthRouter = ReturnType<typeof createAuthRouter>\n"],"mappings":";;;;;;;AAWA,SAAgB,iBACd,GACA,MACA,SACA;CACA,MAAM,SAAS,EAAE;CACjB,MAAM,kBAAkB,EAAE;AAE1B,QAAO,OAAO;EACZ,YAAY,gBAAgB,MAAM,OAAO,EAAE,UAAU;AACnD,UAAO;IACL,MAAM,IAAI,QAAQ;IAClB,iBAAiB,CAAC,CAAC,IAAI;IACvB,SAAS,IAAI;IACd;IACD;EACF,cAAc,gBAAgB,YAAY;GAExC,MAAM,YAAsB,EAAE;GAC9B,MAAM,cAAc,MAAM;AAG1B,OAAI,aAAa,iBAAiB;IAChC,MAAM,kBAAkB,YAAY;AAIpC,WAAO,KAAK,gBAAgB,CAAC,SAAS,QAAQ;AAC5C,SAAI,gBAAgB,KAClB,WAAU,KAAK,IAAI;MAErB;;AAMJ,OAAI,aAAa,QAEf,CADgB,YAAY,QACpB,SAAS,WAA6B;AAC5C,QAAI,OAAO,OAAO,mBAAmB,CAAC,OAAO,SAAS,OACpD;AAOF,KAL2C,MAAM,QAC/C,OAAO,QAAQ,OAChB,GACG,OAAO,QAAQ,SACf,CAAC,OAAO,QAAQ,OAAO,EACnB,SAAS,WAAW;AAC1B,SAAI,OAAO,WACT,WAAU,KAAK,OAAO,WAAW;MAEnC;KACF;AAGJ,UAAO;IAAE;IAAW,iBAAiB,SAAS,mBAAmB;IAAO;IACxE;EACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igstack/app-catalog-backend-core",
3
- "version": "6.1.4",
3
+ "version": "6.1.5-alpha-20260927032305",
4
4
  "description": "Backend core library for App Catalog",
5
5
  "homepage": "https://github.com/lislon/app-catalog",
6
6
  "repository": {
@@ -25,13 +25,13 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@ai-sdk/mcp": "1.0.70",
28
- "@better-auth/prisma-adapter": "^1.5.3",
28
+ "@better-auth/prisma-adapter": "^1.7.0",
29
29
  "@kubernetes/client-node": "^1.2.0",
30
30
  "@modelcontextprotocol/sdk": "^1.27.1",
31
31
  "@trpc/client": "^11.8.1",
32
32
  "@trpc/server": "^11.4.2",
33
33
  "ai": "6.0.250",
34
- "better-auth": ">=1.4.18 <1.7.0",
34
+ "better-auth": "^1.7.0",
35
35
  "cors": "^2.8.5",
36
36
  "dotenv": "^17.3.1",
37
37
  "dotenv-defaults": "5.0.2",
@@ -45,8 +45,8 @@
45
45
  "tsyringe": "^4.10.0",
46
46
  "yaml": "^2.8.0",
47
47
  "zod": "^4.3.5",
48
- "@igstack/app-catalog-shared-core": "6.1.4",
49
- "@igstack/app-catalog-table-sync": "6.1.4"
48
+ "@igstack/app-catalog-shared-core": "6.1.5-alpha-20260927032305",
49
+ "@igstack/app-catalog-table-sync": "6.1.5-alpha-20260927032305"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@tanstack/vite-config": "^0.4.3",
@@ -73,7 +73,7 @@
73
73
  "engines": {
74
74
  "node": ">=24"
75
75
  },
76
- "gitHead": "e78dca96022d2060cf5afa3330b58850c356fc79",
76
+ "gitHead": "8adfb7e156a0de494589ce825ddb38da71823a48",
77
77
  "scripts": {
78
78
  "build": "tsdown",
79
79
  "build:lenient": "tsdown",
@@ -0,0 +1,66 @@
1
+ import { genericOAuth } from 'better-auth/plugins'
2
+ import { describe, expect, it } from 'vitest'
3
+ import { createAuthRouter } from '../modules/auth/authRouter'
4
+ import type { BetterAuth } from '../modules/auth/auth'
5
+ import type { AcTrpcContext } from '../server/acTrpcContext'
6
+ import { t } from '../server/trpcSetup'
7
+
8
+ // The sign-in page renders one button per name getProviders returns, so an
9
+ // upstream rename of the plugin id or of `options.config` silently leaves users
10
+ // with no way to sign in. The real plugin is instantiated here on purpose --
11
+ // a hand-written stub of its shape would keep passing through that rename.
12
+ function providers(auth: Partial<BetterAuth>) {
13
+ const caller = createAuthRouter(t, auth as BetterAuth).createCaller(
14
+ {} as AcTrpcContext,
15
+ )
16
+ return caller.getProviders()
17
+ }
18
+
19
+ describe('auth getProviders', () => {
20
+ it('lists a provider registered through the generic OAuth plugin', async () => {
21
+ const { providers: names } = await providers({
22
+ options: {
23
+ plugins: [
24
+ genericOAuth({
25
+ config: [
26
+ {
27
+ providerId: 'okta',
28
+ clientId: 'id',
29
+ clientSecret: 'secret',
30
+ discoveryUrl:
31
+ 'https://example.invalid/.well-known/openid-configuration',
32
+ },
33
+ ],
34
+ }),
35
+ ],
36
+ },
37
+ })
38
+
39
+ expect(names).toEqual(['okta'])
40
+ })
41
+
42
+ it('lists built-in social providers alongside plugin ones', async () => {
43
+ const { providers: names } = await providers({
44
+ options: {
45
+ socialProviders: {
46
+ github: { clientId: 'id', clientSecret: 'secret' },
47
+ },
48
+ plugins: [
49
+ genericOAuth({
50
+ config: [
51
+ {
52
+ providerId: 'okta',
53
+ clientId: 'id',
54
+ clientSecret: 'secret',
55
+ discoveryUrl:
56
+ 'https://example.invalid/.well-known/openid-configuration',
57
+ },
58
+ ],
59
+ }),
60
+ ],
61
+ },
62
+ })
63
+
64
+ expect(names).toEqual(['github', 'okta'])
65
+ })
66
+ })
@@ -43,28 +43,25 @@ export function createAuthRouter(
43
43
  })
44
44
  }
45
45
 
46
- // Add OAuth providers from plugins (like Okta via genericOAuth)
46
+ // Add OAuth providers from plugins (like Okta via genericOAuth). They are
47
+ // absent from socialProviders above: the plugin only merges them into the
48
+ // auth context at init time, not into the static options.
47
49
  if (authOptions?.plugins) {
48
50
  const plugins = authOptions.plugins
49
51
  plugins.forEach((plugin: BetterAuthPlugin) => {
50
- const pluginWithConfig = plugin as BetterAuthPlugin & {
51
- options?: {
52
- config?: { providerId?: string }[]
53
- }
54
- }
55
- if (
56
- pluginWithConfig.id === 'generic-oauth' &&
57
- pluginWithConfig.options?.config
58
- ) {
59
- const configs = Array.isArray(pluginWithConfig.options.config)
60
- ? pluginWithConfig.options.config
61
- : [pluginWithConfig.options.config]
62
- configs.forEach((config) => {
63
- if (config.providerId) {
64
- providers.push(config.providerId)
65
- }
66
- })
52
+ if (plugin.id !== 'generic-oauth' || !plugin.options?.config) {
53
+ return
67
54
  }
55
+ const configs: { providerId?: string }[] = Array.isArray(
56
+ plugin.options.config,
57
+ )
58
+ ? plugin.options.config
59
+ : [plugin.options.config]
60
+ configs.forEach((config) => {
61
+ if (config.providerId) {
62
+ providers.push(config.providerId)
63
+ }
64
+ })
68
65
  })
69
66
  }
70
67