@pwrdrvr/microapps-cdk 0.4.0-alpha.11 → 0.4.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +98 -52
- package/API.md +28 -10
- package/changelog.md +1 -1
- package/lib/MicroApps.d.ts +5 -1
- package/lib/MicroApps.js +4 -3
- package/lib/MicroAppsAPIGwy.js +1 -1
- package/lib/MicroAppsCF.js +1 -1
- package/lib/MicroAppsChildDeployer.d.ts +3 -1
- package/lib/MicroAppsChildDeployer.js +3 -3
- package/lib/MicroAppsEdgeToOrigin.js +1 -1
- package/lib/MicroAppsS3.js +1 -1
- package/lib/MicroAppsSvcs.d.ts +5 -1
- package/lib/MicroAppsSvcs.js +5 -4
- package/lib/MicroAppsTable.js +1 -1
- package/lib/microapps-deployer/index.js +46 -46
- package/lib/microapps-deployer/index.js.map +4 -4
- package/lib/microapps-edge-to-origin/index.js +1 -1
- package/lib/microapps-edge-to-origin/index.js.map +2 -2
- package/package.json +1 -1
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
|
@@ -72,7 +72,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
72
72
|
- undefined - Do not sign origin requests`,default:"",env:"SIGNING_MODE"})],qe.prototype,"signingMode",2),_r([Ut.Property({doc:"Add X-Forwarded-Host header with value of Host header on the Edge",default:!0,env:"ADD_X_FORWARDED_HOST_HEADER"})],qe.prototype,"addXForwardedHostHeader",2),_r([Ut.Property({doc:`Set the Host header to the Origin host name
|
|
73
73
|
This is useful when the OriginRequestPolicy is set to forward all headers
|
|
74
74
|
API Gateway and Lambda Function URLs will both reject the request if the Host header is set
|
|
75
|
-
to the Edge host name.`,default:!0,env:"REPLACE_HOST_HEADER"})],qe.prototype,"replaceHostHeader",2),_r([Ut.Property({doc:"Allow 2nd generation routing by forwarding the request to the Lambda Function URL of the target version.",env:"TABLE_NAME",default:""})],qe.prototype,"tableName",2),_r([Ut.Property({doc:"Path prefix for this deployment",default:"",env:"ROOT_PATH_PREFIX"})],qe.prototype,"rootPathPrefix",2),_r([Ut.Property({doc:"Allowed locales for pages",default:[],env:"LOCALES"})],qe.prototype,"locales",2),qe=_r([Ut.Config({file:"config.yml",validationMethod:"strict",parser:{extension:["yml","yaml"],parse:oV},formats:{url:Xv.url,ipaddress:Xv.ipaddress}})],qe);var gK=pr(vC()),Qo=class{};Qo.Instance=new gK.LambdaLog({silent:process.env.JEST_WORKER_ID!==void 0});var fr=Qo.Instance,mr=qe.instance,H1e=(0,Xo.normalizePathPrefix)(qe.instance.rootPathPrefix),W1e=(0,Xo.loadAppFrame)({basePath:__dirname});fr.info("loaded config",{config:mr});var J1e="2023-02-01-01";fr.info("Edge-to-origin build trigger",{buildTrigger:J1e});var Zv,Rx=new vK.DynamoDBClient({maxAttempts:8,region:mr.originRegion});function Y1e(e){Zv=e.dbManager,Rx=e.dynamoClient}Zv=mr.tableName&&Rx?new SK.DBManager({dynamoClient:Rx,tableName:mr.tableName}):void 0;var Q1e=new Nx.SignatureV4({credentials:(0,Px.defaultProvider)(),region:mr.originRegion||"us-east-2",service:"lambda",sha256:Ox.Sha256}),X1e=new Nx.SignatureV4({credentials:(0,Px.defaultProvider)(),region:mr.originRegion||"us-east-2",service:"execute-api",sha256:Ox.Sha256}),Z1e=async(e,t)=>{var n,i,s,o,a,c,l,f,m,p,h,g,y,b,I,T,F,se;let r=e.Records[0].cf.request;try{let Qe=r;if(fr.debug("got request",{event:e,context:t}),((i=(n=r.origin)==null?void 0:n.s3)==null?void 0:i.domainName)&&((c=(a=(o=(s=r.origin)==null?void 0:s.s3)==null?void 0:o.customHeaders["x-microapps-origin"])==null?void 0:a[0])==null?void 0:c.value)==="s3")return fr.
|
|
75
|
+
to the Edge host name.`,default:!0,env:"REPLACE_HOST_HEADER"})],qe.prototype,"replaceHostHeader",2),_r([Ut.Property({doc:"Allow 2nd generation routing by forwarding the request to the Lambda Function URL of the target version.",env:"TABLE_NAME",default:""})],qe.prototype,"tableName",2),_r([Ut.Property({doc:"Path prefix for this deployment",default:"",env:"ROOT_PATH_PREFIX"})],qe.prototype,"rootPathPrefix",2),_r([Ut.Property({doc:"Allowed locales for pages",default:[],env:"LOCALES"})],qe.prototype,"locales",2),qe=_r([Ut.Config({file:"config.yml",validationMethod:"strict",parser:{extension:["yml","yaml"],parse:oV},formats:{url:Xv.url,ipaddress:Xv.ipaddress}})],qe);var gK=pr(vC()),Qo=class{};Qo.Instance=new gK.LambdaLog({silent:process.env.JEST_WORKER_ID!==void 0});var fr=Qo.Instance,mr=qe.instance,H1e=(0,Xo.normalizePathPrefix)(qe.instance.rootPathPrefix),W1e=(0,Xo.loadAppFrame)({basePath:__dirname});fr.info("loaded config",{config:mr});var J1e="2023-02-01-01";fr.info("Edge-to-origin build trigger",{buildTrigger:J1e});var Zv,Rx=new vK.DynamoDBClient({maxAttempts:8,region:mr.originRegion});function Y1e(e){Zv=e.dbManager,Rx=e.dynamoClient}Zv=mr.tableName&&Rx?new SK.DBManager({dynamoClient:Rx,tableName:mr.tableName}):void 0;var Q1e=new Nx.SignatureV4({credentials:(0,Px.defaultProvider)(),region:mr.originRegion||"us-east-2",service:"lambda",sha256:Ox.Sha256}),X1e=new Nx.SignatureV4({credentials:(0,Px.defaultProvider)(),region:mr.originRegion||"us-east-2",service:"execute-api",sha256:Ox.Sha256}),Z1e=async(e,t)=>{var n,i,s,o,a,c,l,f,m,p,h,g,y,b,I,T,F,se;let r=e.Records[0].cf.request;try{let Qe=r;if(fr.debug("got request",{event:e,context:t}),((i=(n=r.origin)==null?void 0:n.s3)==null?void 0:i.domainName)&&((c=(a=(o=(s=r.origin)==null?void 0:s.s3)==null?void 0:o.customHeaders["x-microapps-origin"])==null?void 0:a[0])==null?void 0:c.value)==="s3")return fr.debug("request is for S3 origin",{request:r}),((f=(l=r.headers.host)==null?void 0:l[0])==null?void 0:f.value)&&((p=(m=r.headers.host)==null?void 0:m[0])==null?void 0:p.value)!==((g=(h=r.origin)==null?void 0:h.s3)==null?void 0:g.domainName)&&(r.headers.host=[{key:"Host",value:(b=(y=r.origin)==null?void 0:y.s3)==null?void 0:b.domainName}]),r;mr.addXForwardedHostHeader&&r.headers.host&&(r.headers["x-forwarded-host"]=[{key:"X-Forwarded-Host",value:r.headers.host[0].value}]);let et=(T=(I=r.origin)==null?void 0:I.custom)==null?void 0:T.domainName,Qt="api-gateway";if(Zv){let M=new URL(`https://localhost${r.uri}${r.querystring?`?${r.querystring}`:""}`),V=await(0,Xo.GetRoute)({dbManager:Zv,locales:mr.locales,rawPath:e.Records[0].cf.request.uri,queryStringParameters:M.searchParams,normalizedPathPrefix:H1e});if(fr.debug("got route info",{route:V}),V.startupType==="iframe"&&V.iFrameAppVersionPath){let ce=W1e.replace("{{iframeSrc}}",V.iFrameAppVersionPath);return fr.debug("returning app frame",{frameHTML:ce}),{status:"200",headers:{"content-type":[{key:"Content-Type",value:"text/html; charset=UTF-8"}],"cache-control":[{key:"Cache-Control",value:"private"}]},body:ce,bodyEncoding:"text"}}if(V.redirectLocation)return{status:`${V.statusCode}`,headers:{location:[{key:"Location",value:V.redirectLocation}]}};if(V.statusCode&&V.statusCode!==200)return{status:`${V.statusCode}`,statusDescription:V.errorMessage};V.url&&(V.type==="url"||V.type==="lambda-url")&&(fr.debug("rewriting to url",{url:V.url}),Qt=V.type,et=new URL(V.url).hostname),V.appName&&(r.headers["x-microapps-appname"]=[{key:"X-MicroApps-AppName",value:V.appName}]),V.semVer&&(r.headers["x-microapps-semver"]=[{key:"X-MicroApps-SemVer",value:V.semVer}])}if(!et)return fr.error("No origin found",{request:r}),{status:"404",statusDescription:"Origin Domain Missing"};(mr.tableName||mr.replaceHostHeader&&et||Qt==="lambda-url"||Qt==="url")&&(r.headers.host=[{key:"Host",value:et}]),(se=(F=r.origin)==null?void 0:F.custom)!=null&&se.domainName?(r.origin={...r.origin},r.origin.custom.domainName=et):r.origin={custom:{domainName:et,keepaliveTimeout:5,port:443,protocol:"https",readTimeout:30,sslProtocols:["TLSv1.2"],customHeaders:{},path:""}},r.querystring=(r.querystring??"").replace(/&?appver=[^&]*/,"");let Bt=et.includes(".lambda-url.")?Q1e:X1e;return mr.signingMode==="sign"?(fr.debug("signing request"),Qe=await a$(r,t,Bt)):mr.signingMode==="presign"?(fr.error("presign not yet implemented"),Qe=await c$(r,t,Bt)):fr.info("not signing request"),Qe}catch(Qe){return fr.error("caught exception at top level",{error:Qe}),{status:"500",statusDescription:"Failed Modifying Origin Request"}}};0&&(module.exports={handler,overrideDBManager});
|
|
76
76
|
/*! *****************************************************************************
|
|
77
77
|
Copyright (C) Microsoft. All rights reserved.
|
|
78
78
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|