@@ -299,7 +299,7 @@ describe('AuthManager', () => {
299299 } ) ;
300300
301301 describe ( 'plugin registration' , ( ) => {
302- it ( 'should not include any plugins when no plugin config is provided ' , ( ) => {
302+ it ( 'should always register the bearer plugin even with no plugin config' , ( ) => {
303303 let capturedConfig : any ;
304304 ( betterAuth as any ) . mockImplementation ( ( config : any ) => {
305305 capturedConfig = config ;
@@ -314,7 +314,7 @@ describe('AuthManager', () => {
314314 manager . getAuthInstance ( ) ;
315315 warnSpy . mockRestore ( ) ;
316316
317- expect ( capturedConfig . plugins ) . toEqual ( [ ] ) ;
317+ expect ( capturedConfig . plugins . map ( ( p : any ) => p . id ) ) . toEqual ( [ 'bearer' ] ) ;
318318 } ) ;
319319
320320 it ( 'should register organization plugin with schema mapping when enabled' , ( ) => {
@@ -404,13 +404,35 @@ describe('AuthManager', () => {
404404 manager . getAuthInstance ( ) ;
405405 warnSpy . mockRestore ( ) ;
406406
407- expect ( capturedConfig . plugins ) . toHaveLength ( 3 ) ;
407+ expect ( capturedConfig . plugins ) . toHaveLength ( 4 ) ;
408408 expect ( capturedConfig . plugins . map ( ( p : any ) => p . id ) . sort ( ) ) . toEqual (
409- [ 'magic-link' , 'organization' , 'two-factor' ] ,
409+ [ 'bearer' , ' magic-link', 'organization' , 'two-factor' ] ,
410410 ) ;
411411 } ) ;
412412 } ) ;
413413
414+ describe ( 'bearer plugin (cross-origin / mobile token auth)' , ( ) => {
415+ it ( 'should always register the bearer plugin regardless of other flags' , ( ) => {
416+ let capturedConfig : any ;
417+ ( betterAuth as any ) . mockImplementation ( ( config : any ) => {
418+ capturedConfig = config ;
419+ return { handler : vi . fn ( ) , api : { } } ;
420+ } ) ;
421+
422+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
423+ const manager = new AuthManager ( {
424+ secret : 'test-secret-at-least-32-chars-long' ,
425+ baseUrl : 'http://localhost:3000' ,
426+ plugins : { organization : true } ,
427+ } ) ;
428+ manager . getAuthInstance ( ) ;
429+ warnSpy . mockRestore ( ) ;
430+
431+ const bearerPlugin = capturedConfig . plugins . find ( ( p : any ) => p . id === 'bearer' ) ;
432+ expect ( bearerPlugin ) . toBeDefined ( ) ;
433+ } ) ;
434+ } ) ;
435+
414436 describe ( 'trustedOrigins passthrough' , ( ) => {
415437 it ( 'should forward trustedOrigins to betterAuth when provided' , ( ) => {
416438 let capturedConfig : any ;
0 commit comments