@@ -10,6 +10,7 @@ describe("authorizeClient", () => {
1010 secretKeyHash : "secret-hash" ,
1111 bundleId : null ,
1212 origin : "example.com" ,
13+ incomingServiceApiKey : null ,
1314 } ;
1415
1516 it ( "should authorize client with valid secret key" , ( ) => {
@@ -27,6 +28,7 @@ describe("authorizeClient", () => {
2728 secretKeyHash : null ,
2829 bundleId : null ,
2930 origin : "sub.example.com" ,
31+ incomingServiceApiKey : null ,
3032 } ;
3133
3234 const result = authorizeClient (
@@ -43,6 +45,7 @@ describe("authorizeClient", () => {
4345 secretKeyHash : null ,
4446 bundleId : null ,
4547 origin : null ,
48+ incomingServiceApiKey : null ,
4649 } ;
4750
4851 const validProjectResponseAnyDomain = {
@@ -67,6 +70,7 @@ describe("authorizeClient", () => {
6770 secretKeyHash : null ,
6871 bundleId : "com.foo.bar" ,
6972 origin : null ,
73+ incomingServiceApiKey : null ,
7074 } ;
7175
7276 const result = authorizeClient (
@@ -87,6 +91,7 @@ describe("authorizeClient", () => {
8791 secretKeyHash : null ,
8892 bundleId : null ,
8993 origin : "unauthorized.com" ,
94+ incomingServiceApiKey : null ,
9095 } ;
9196
9297 const result = authorizeClient (
@@ -101,4 +106,21 @@ describe("authorizeClient", () => {
101106 expect ( result . errorCode ) . toBe ( "ORIGIN_UNAUTHORIZED" ) ;
102107 expect ( result . status ) . toBe ( 401 ) ;
103108 } ) ;
109+
110+ it ( "should authorize client with incoming service api key" , ( ) => {
111+ const authOptionsWithServiceKey : ClientAuthorizationPayload = {
112+ secretKeyHash : null ,
113+ bundleId : null ,
114+ origin : "unauthorized.com" , // Even unauthorized origin should work with service key
115+ incomingServiceApiKey : "test-service-key" ,
116+ } ;
117+
118+ const result = authorizeClient (
119+ authOptionsWithServiceKey ,
120+ validTeamAndProjectResponse ,
121+ // biome-ignore lint/suspicious/noExplicitAny: test only
122+ ) as any ;
123+ expect ( result . authorized ) . toBe ( true ) ;
124+ expect ( result . project ) . toEqual ( validTeamAndProjectResponse . project ) ;
125+ } ) ;
104126} ) ;
0 commit comments