@@ -169,7 +169,7 @@ export const validateCredentialsWithId = (credentials: Credentials, type: string
169169 if ( pathCred . roles !== undefined && ! Array . isArray ( pathCred . roles ) ) {
170170 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_ROLES_KEY_TYPE , [ type , typeId , id ] ) ;
171171 }
172- if ( pathCred . context !== undefined && typeof pathCred . context !== 'string' ) {
172+ if ( pathCred . context !== undefined && ( typeof pathCred . context !== 'string' && typeof pathCred . context !== 'object' ) ) {
173173 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_CONTEXT , [ type , typeId , id ] ) ;
174174 }
175175 }
@@ -184,7 +184,7 @@ export const validateCredentialsWithId = (credentials: Credentials, type: string
184184 if ( stringCred . roles !== undefined && ! Array . isArray ( stringCred . roles ) ) {
185185 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_ROLES_KEY_TYPE , [ type , typeId , id ] ) ;
186186 }
187- if ( stringCred . context !== undefined && typeof stringCred . context !== 'string' ) {
187+ if ( stringCred . context !== undefined && ( typeof stringCred . context !== 'string' && typeof stringCred . context !== 'object' ) ) {
188188 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_CONTEXT , [ type , typeId , id ] ) ;
189189 }
190190 }
@@ -295,7 +295,7 @@ export const validateSkyflowCredentials = (credentials: Credentials, logLevel: L
295295 if ( pathCred . roles !== undefined && ! Array . isArray ( pathCred . roles ) ) {
296296 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_ROLES_KEY_TYPE ) ;
297297 }
298- if ( pathCred . context !== undefined && typeof pathCred . context !== 'string' ) {
298+ if ( pathCred . context !== undefined && ( typeof pathCred . context !== 'string' && typeof pathCred . context !== 'object' ) ) {
299299 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_CONTEXT ) ;
300300 }
301301 }
@@ -310,7 +310,8 @@ export const validateSkyflowCredentials = (credentials: Credentials, logLevel: L
310310 if ( stringCred . roles !== undefined && ! Array . isArray ( stringCred . roles ) ) {
311311 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_ROLES_KEY_TYPE ) ;
312312 }
313- if ( stringCred . context !== undefined && typeof stringCred . context !== 'string' ) {
313+ // validate both string | Record<string, any>
314+ if ( stringCred . context !== undefined && ( typeof stringCred . context !== 'string' && typeof stringCred . context !== 'object' ) ) {
314315 throw new SkyflowError ( SKYFLOW_ERROR_CODE . INVALID_CONTEXT ) ;
315316 }
316317 }
0 commit comments