@@ -383,7 +383,7 @@ describe("GatewayClient connect auth payload", () => {
383383 ) ;
384384 }
385385
386- it ( "uses explicit shared token and does not inject stored device token " , ( ) => {
386+ it ( "sends stored device token alongside explicit shared token for fallback auth " , ( ) => {
387387 loadDeviceAuthTokenMock . mockReturnValue ( { token : "stored-device-token" } ) ;
388388 const client = new GatewayClient ( {
389389 url : "ws://127.0.0.1:18789" ,
@@ -397,12 +397,12 @@ describe("GatewayClient connect auth payload", () => {
397397
398398 expect ( connectFrameFrom ( ws ) ) . toMatchObject ( {
399399 token : "shared-token" ,
400+ deviceToken : "stored-device-token" ,
400401 } ) ;
401- expect ( connectFrameFrom ( ws ) . deviceToken ) . toBeUndefined ( ) ;
402402 client . stop ( ) ;
403403 } ) ;
404404
405- it ( "uses explicit shared password and does not inject stored device token " , ( ) => {
405+ it ( "sends stored device token alongside explicit shared password for fallback auth " , ( ) => {
406406 loadDeviceAuthTokenMock . mockReturnValue ( { token : "stored-device-token" } ) ;
407407 const client = new GatewayClient ( {
408408 url : "ws://127.0.0.1:18789" ,
@@ -416,9 +416,11 @@ describe("GatewayClient connect auth payload", () => {
416416
417417 expect ( connectFrameFrom ( ws ) ) . toMatchObject ( {
418418 password : "shared-password" , // pragma: allowlist secret
419+ deviceToken : "stored-device-token" ,
419420 } ) ;
420- expect ( connectFrameFrom ( ws ) . token ) . toBeUndefined ( ) ;
421- expect ( connectFrameFrom ( ws ) . deviceToken ) . toBeUndefined ( ) ;
421+ // When password is the primary credential, auth.token falls back to
422+ // the resolved device token for legacy compatibility.
423+ expect ( connectFrameFrom ( ws ) . token ) . toBe ( "stored-device-token" ) ;
422424 client . stop ( ) ;
423425 } ) ;
424426
0 commit comments