@@ -25,9 +25,12 @@ const coreLogger = require('@adobe/aio-lib-core-logging')
2525const { getReasonPhrase } = require ( 'http-status-codes' )
2626
2727const utils = require ( './app-helper' )
28- const { SERVER_HOST , SERVER_DEFAULT_PORT , BUNDLER_DEFAULT_PORT , DEV_API_PREFIX , DEV_API_WEB_PREFIX , BUNDLE_OPTIONS , CHANGED_ASSETS_PRINT_LIMIT } = require ( './constants' )
28+ const { SERVER_HOST , SERVER_DEFAULT_PORT , BUNDLER_DEFAULT_PORT , DEV_API_PREFIX , DEV_API_WEB_PREFIX , BUNDLE_OPTIONS , CHANGED_ASSETS_PRINT_LIMIT , IMS_OAUTH_S2S_ENV_KEY } = require ( './constants' )
2929const RAW_CONTENT_TYPES = [ 'application/octet-stream' , 'multipart/form-data' ]
3030
31+ // for the include-ims-credentials annotation
32+ let imsAuthObject = null
33+
3134/* global Request, Response */
3235
3336/**
@@ -86,6 +89,11 @@ async function runDev (runOptions, config, _inprocHookRunner) {
8689 // ex. console.log('AIO_DEV ', process.env.AIO_DEV ? 'dev' : 'prod')
8790 process . env . AIO_DEV = 'true'
8891
92+ // for the include-ims-credentials annotation
93+ try {
94+ imsAuthObject = JSON . parse ( process . env [ IMS_OAUTH_S2S_ENV_KEY ] )
95+ } catch ( e ) { }
96+
8997 const serverPortToUse = parseInt ( process . env . PORT ) || SERVER_DEFAULT_PORT
9098 const serverPort = await getPort ( { port : serverPortToUse } )
9199
@@ -346,6 +354,13 @@ async function invokeAction ({ actionRequestContext, logger }) {
346354 }
347355 }
348356
357+ // process the include-ims-credentials annotation
358+ const newInputs = rtLib . utils . getIncludeIMSCredentialsAnnotationInputs ( action , imsAuthObject )
359+ if ( newInputs ) {
360+ Object . entries ( newInputs ) . forEach ( ( [ k , v ] ) => { params [ k ] = v } )
361+ logger . debug ( `Added IMS credentials to action params for action '${ actionName } '.` )
362+ }
363+
349364 // if we run an action, we will restore the process.env after the call
350365 // we must do this before we load the action because code can execute on require/import
351366 const preCallEnv = { ...process . env }
0 commit comments