🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(oidc): replace the toby client with a dedicated lobot-mobile client (#23617)
Arvin Xu865a3d2d5982
diff --git a/packages/const/src/desktop.ts b/packages/const/src/desktop.tsindex f3a075c09a9..ce7356230d3 100644--- a/packages/const/src/desktop.ts+++ b/packages/const/src/desktop.ts@@ -20,6 +20,9 @@ export const LOBEHUB_DESKTOP_CLIENT_ID = 'lobehub-desktop';*/export const LOBOT_DESKTOP_CLIENT_ID = 'lobot-desktop';+/** OIDC client the Lobot iOS app signs in with, through an HTTPS universal-link callback. */+export const LOBOT_MOBILE_CLIENT_ID = 'lobot-mobile';+/** Desktop apps that sign in through the `/oidc/callback/desktop` handoff. */export const DESKTOP_OIDC_CLIENT_IDS: readonly string[] = [LOBEHUB_DESKTOP_CLIENT_ID,diff --git a/src/features/Auth/OAuthConsent/Consent/index.tsx b/src/features/Auth/OAuthConsent/Consent/index.tsxindex 22a5ee55a10..e82beaf9f88 100644--- a/src/features/Auth/OAuthConsent/Consent/index.tsx+++ b/src/features/Auth/OAuthConsent/Consent/index.tsx@@ -1,6 +1,6 @@'use client';-import { DESKTOP_OIDC_CLIENT_IDS } from '@lobechat/const';+import { DESKTOP_OIDC_CLIENT_IDS, LOBOT_MOBILE_CLIENT_ID } from '@lobechat/const';import { Block, Button, Flexbox, Text } from '@lobehub/ui';import React, { memo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -35,7 +35,7 @@ const BUILTIN_CLIENTS = new Set([...DESKTOP_OIDC_CLIENT_IDS,'lobehub-mobile','lobehub-market',- 'toby',+ LOBOT_MOBILE_CLIENT_ID,]);const ConsentClient = memo<ClientProps>(diff --git a/src/libs/oidc-provider/config.ts b/src/libs/oidc-provider/config.tsindex 6a132e5d7eb..15c9285bfc2 100644--- a/src/libs/oidc-provider/config.ts+++ b/src/libs/oidc-provider/config.ts@@ -7,6 +7,7 @@ import {ACCEPTANCE_REVIEW_SCOPE,LOBEHUB_DESKTOP_CLIENT_ID,LOBOT_DESKTOP_CLIENT_ID,+ LOBOT_MOBILE_CLIENT_ID,} from '@lobechat/const';import { type ClientMetadata } from 'oidc-provider';import urlJoin from 'url-join';@@ -86,13 +87,16 @@ const builtinClients: ClientMetadata[] = [},{application_type: 'native',- client_id: 'toby',- client_name: 'toby',+ client_id: LOBOT_MOBILE_CLIENT_ID,+ client_name: 'Lobot',grant_types: ['authorization_code', 'refresh_token'],+ logo_uri: 'https://hub-apac-1.lobeobjects.space/lobot-desktop-icon.png',post_logout_redirect_uris: [],// Universal-link callback: iOS only hands it to the app listed in the AASA webcredentials,- // so another app cannot impersonate toby the way it could with a custom scheme.- redirect_uris: desktopAppOrigins.map((origin) => urlJoin(origin, '/oidc/callback/toby')),+ // so another app cannot impersonate Lobot the way it could with a custom scheme.+ redirect_uris: desktopAppOrigins.map((origin) =>+ urlJoin(origin, `/oidc/callback/${LOBOT_MOBILE_CLIENT_ID}`),+ ),response_types: ['code'],token_endpoint_auth_method: 'none',},diff --git a/src/libs/oidc-provider/provider.test.ts b/src/libs/oidc-provider/provider.test.tsindex e666afc1f5d..aa414f19470 100644--- a/src/libs/oidc-provider/provider.test.ts+++ b/src/libs/oidc-provider/provider.test.ts@@ -93,7 +93,7 @@ describe('OIDC Provider - Market Client Integration', () => {vi.doUnmock('@/envs/app');});- it('should register toby as a public native client with an https callback only', async () => {+ it('should register lobot-mobile as a public native client with an https callback only', async () => {vi.doMock('@/envs/app', () => ({appEnv: {APP_URL: 'https://app.lobehub.com',@@ -104,17 +104,22 @@ describe('OIDC Provider - Market Client Integration', () => {const { default: Provider } = await import('oidc-provider');const { defaultClients } = await import('./config');const provider = new Provider('https://app.lobehub.com/oidc', { clients: defaultClients });- const tobyClient = await provider.Client.find('toby');+ const lobotClient = await provider.Client.find('lobot-mobile');- expect(tobyClient?.applicationType).toBe('native');- expect(tobyClient?.tokenEndpointAuthMethod).toBe('none');- expect(tobyClient?.grantTypes).toEqual(['authorization_code', 'refresh_token']);- expect(tobyClient?.redirectUriAllowed('https://app.lobehub.com/oidc/callback/toby')).toBe(- true,- );- expect(tobyClient?.redirectUriAllowed('https://lobehub.com/oidc/callback/toby')).toBe(true);- expect(tobyClient?.redirectUriAllowed('com.lobehub.toby://auth/callback')).toBe(false);- expect(tobyClient?.redirectUriAllowed('https://example.com/oidc/callback/toby')).toBe(false);+ expect(await provider.Client.find('toby')).toBeUndefined();+ expect(lobotClient?.applicationType).toBe('native');+ expect(lobotClient?.tokenEndpointAuthMethod).toBe('none');+ expect(lobotClient?.grantTypes).toEqual(['authorization_code', 'refresh_token']);+ expect(+ lobotClient?.redirectUriAllowed('https://app.lobehub.com/oidc/callback/lobot-mobile'),+ ).toBe(true);+ expect(+ lobotClient?.redirectUriAllowed('https://lobehub.com/oidc/callback/lobot-mobile'),+ ).toBe(true);+ expect(lobotClient?.redirectUriAllowed('com.lobehub.lobot://auth/callback')).toBe(false);+ expect(+ lobotClient?.redirectUriAllowed('https://example.com/oidc/callback/lobot-mobile'),+ ).toBe(false);vi.doUnmock('@/envs/app');});